@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_back_office_orders_mdl { |
3 | 3 | function __construct() { |
4 | 4 | |
@@ -12,25 +12,25 @@ discard block |
||
12 | 12 | $order_meta = get_post_meta($oid, '_order_postmeta', true); |
13 | 13 | |
14 | 14 | // Send email is checked |
15 | - if( !empty($send_email) ) { |
|
15 | + if (!empty($send_email)) { |
|
16 | 16 | // New object wps_message_ctr |
17 | 17 | $wps_message = new wps_message_ctr(); |
18 | 18 | |
19 | 19 | // Get order current content |
20 | 20 | $user = get_post_meta($oid, '_order_info', true); |
21 | 21 | |
22 | - $email = isset($user['billing']['address']['address_user_email']) ? $user['billing']['address']['address_user_email'] :''; |
|
22 | + $email = isset($user['billing']['address']['address_user_email']) ? $user['billing']['address']['address_user_email'] : ''; |
|
23 | 23 | |
24 | 24 | /** Si pas d'email trouvé, utilises l'adresse email par défault du client */ |
25 | - if(empty($email)) { |
|
26 | - $customer_id = get_post_meta( $oid, '_wpshop_order_customer_id', true ); |
|
25 | + if (empty($email)) { |
|
26 | + $customer_id = get_post_meta($oid, '_wpshop_order_customer_id', true); |
|
27 | 27 | $user_info = get_userdata($customer_id); |
28 | 28 | $email = $user_info->user_email; |
29 | 29 | } |
30 | - $first_name = isset($user['billing']['address']['address_first_name'])?$user['billing']['address']['address_first_name']:''; |
|
31 | - $last_name = isset($user['billing']['address']['address_last_name'])?$user['billing']['address']['address_last_name']:''; |
|
30 | + $first_name = isset($user['billing']['address']['address_first_name']) ? $user['billing']['address']['address_first_name'] : ''; |
|
31 | + $last_name = isset($user['billing']['address']['address_last_name']) ? $user['billing']['address']['address_last_name'] : ''; |
|
32 | 32 | |
33 | - $object = array('object_type'=>'order','object_id'=>$oid); |
|
33 | + $object = array('object_type'=>'order', 'object_id'=>$oid); |
|
34 | 34 | /* Envoie du message de confirmation de commande au client */ |
35 | 35 | $wps_message->wpshop_prepared_email( |
36 | 36 | $email, |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | $object |
40 | 40 | ); |
41 | 41 | // Copy to Administrator |
42 | - if ( !empty($copy_to_administrator) ) { |
|
43 | - $email = get_option( 'wpshop_emails' ); |
|
42 | + if (!empty($copy_to_administrator)) { |
|
43 | + $email = get_option('wpshop_emails'); |
|
44 | 44 | $email = $email['contact_email']; |
45 | 45 | $wps_message->wpshop_prepared_email( |
46 | 46 | $email, |
47 | 47 | 'WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE', |
48 | - array( 'order_id' => $oid, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_key' => $order_meta['order_key'], 'message' => $comment, 'order_addresses' => '', 'order_billing_address' => '', 'order_shipping_address' => ''), |
|
48 | + array('order_id' => $oid, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_key' => $order_meta['order_key'], 'message' => $comment, 'order_addresses' => '', 'order_billing_address' => '', 'order_shipping_address' => ''), |
|
49 | 49 | $object |
50 | 50 | ); |
51 | 51 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | |
54 | 54 | // Private comment informations |
55 | 55 | $order_private_comments[] = array( |
56 | - 'comment_date' => current_time('mysql',0), |
|
56 | + 'comment_date' => current_time('mysql', 0), |
|
57 | 57 | 'send_email' => $send_email, |
58 | 58 | 'send_sms' => $send_sms, |
59 | 59 | 'comment' => $comment, |
60 | 60 | 'author' => get_current_user_id() |
61 | 61 | ); |
62 | 62 | // Save it |
63 | - if(is_array($order_private_comments)) { |
|
63 | + if (is_array($order_private_comments)) { |
|
64 | 64 | update_post_meta($oid, '_order_private_comments', $order_private_comments); |
65 | 65 | return true; |
66 | 66 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_back_office_orders_mdl { |
3 | 5 | function __construct() { |
4 | 6 | |
@@ -63,7 +65,8 @@ discard block |
||
63 | 65 | if(is_array($order_private_comments)) { |
64 | 66 | update_post_meta($oid, '_order_private_comments', $order_private_comments); |
65 | 67 | return true; |
68 | + } else { |
|
69 | + return false; |
|
66 | 70 | } |
67 | - else return false; |
|
68 | 71 | } |
69 | 72 | } |
70 | 73 | \ No newline at end of file |
@@ -1,14 +1,14 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | -class wps_orders_mdl{ |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | +class wps_orders_mdl { |
|
3 | 3 | |
4 | 4 | function __construct() { |
5 | 5 | |
6 | 6 | } |
7 | 7 | |
8 | - function get_customer_orders( $customer_id ) { |
|
8 | + function get_customer_orders($customer_id) { |
|
9 | 9 | global $wpdb; |
10 | - $query = $wpdb->prepare( 'SELECT * FROM '.$wpdb->posts. ' WHERE post_author = %d AND post_type = %s AND post_status != %s AND post_status != %s ORDER BY ID DESC', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'auto-draft', 'trash' ); |
|
11 | - $orders = $wpdb->get_results( $query ); |
|
10 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s AND post_status != %s AND post_status != %s ORDER BY ID DESC', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'auto-draft', 'trash'); |
|
11 | + $orders = $wpdb->get_results($query); |
|
12 | 12 | |
13 | 13 | return $orders; |
14 | 14 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Bootstrap file |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -DEFINE('WPS_EXPORT_DIR', basename(dirname(__FILE__)) ); |
|
10 | -DEFINE('WPS_EXPORT_PATH', str_replace( "\\", "/", str_replace( WPS_EXPORT_DIR, "", dirname( __FILE__ ) ) ) ); |
|
11 | -DEFINE('WPS_EXPORT_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPS_EXPORT_PATH ) ); |
|
9 | +DEFINE('WPS_EXPORT_DIR', basename(dirname(__FILE__))); |
|
10 | +DEFINE('WPS_EXPORT_PATH', str_replace("\\", "/", str_replace(WPS_EXPORT_DIR, "", dirname(__FILE__)))); |
|
11 | +DEFINE('WPS_EXPORT_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPS_EXPORT_PATH)); |
|
12 | 12 | |
13 | -load_plugin_textdomain( 'wps_export', false, dirname(plugin_basename( __FILE__ )).'/languages/' ); |
|
13 | +load_plugin_textdomain('wps_export', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
14 | 14 | |
15 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_export_ctr.php' ); |
|
16 | -include( plugin_dir_path( __FILE__ ).'/model/wps_export_mdl.php' ); |
|
15 | +include(plugin_dir_path(__FILE__) . '/controller/wps_export_ctr.php'); |
|
16 | +include(plugin_dir_path(__FILE__) . '/model/wps_export_mdl.php'); |
|
17 | 17 | |
18 | 18 | $wps_export = new wps_export_ctr(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_export_mdl { |
3 | 3 | |
4 | 4 | /** |
@@ -8,88 +8,88 @@ discard block |
||
8 | 8 | * @param date $dt2 may be null |
9 | 9 | * @return array |
10 | 10 | */ |
11 | - function get_customers($term, $dt1=null, $dt2=null) { |
|
11 | + function get_customers($term, $dt1 = null, $dt2 = null) { |
|
12 | 12 | global $wpdb; |
13 | 13 | $users; |
14 | 14 | switch ($term) { |
15 | 15 | case 'users_all': |
16 | - $query = $wpdb->prepare( "SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1); |
|
16 | + $query = $wpdb->prepare("SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1); |
|
17 | 17 | $list_users = $wpdb->get_results($query, OBJECT); |
18 | 18 | break; |
19 | 19 | case 'customers_all': |
20 | - $query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order' ); |
|
20 | + $query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order'); |
|
21 | 21 | $list_users = $wpdb->get_results($query, OBJECT); |
22 | 22 | break; |
23 | 23 | case 'newsletters_site': |
24 | - $query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;' ); |
|
24 | + $query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;'); |
|
25 | 25 | $list_users = $wpdb->get_results($query, OBJECT); |
26 | 26 | break; |
27 | 27 | case 'newsletters_site_partners': |
28 | - $query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;' ); |
|
28 | + $query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;'); |
|
29 | 29 | $list_users = $wpdb->get_results($query, OBJECT); |
30 | 30 | break; |
31 | 31 | case 'date': |
32 | - $query = $wpdb->prepare( "SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", 'wpshop_shop_order', date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2))) ); |
|
32 | + $query = $wpdb->prepare("SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", 'wpshop_shop_order', date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2)))); |
|
33 | 33 | $list_users = $wpdb->get_results($query, OBJECT); |
34 | 34 | break; |
35 | 35 | case 'orders': |
36 | - $query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order' ); |
|
36 | + $query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order'); |
|
37 | 37 | $list_users = $wpdb->get_results($query, OBJECT); |
38 | 38 | break; |
39 | 39 | } |
40 | 40 | $users_array = array(); |
41 | 41 | $users_array[] = array( |
42 | - 'name' => __( 'Name', 'wps_export' ), |
|
43 | - 'first_name' => __( 'First name', 'wps_export' ), |
|
44 | - 'email' => __( 'Mail', 'wps_export' ), |
|
45 | - 'tel' => __( 'Phone', 'wps_export' ), |
|
46 | - 'registered' => __( 'Registered', 'wps_export' ) |
|
42 | + 'name' => __('Name', 'wps_export'), |
|
43 | + 'first_name' => __('First name', 'wps_export'), |
|
44 | + 'email' => __('Mail', 'wps_export'), |
|
45 | + 'tel' => __('Phone', 'wps_export'), |
|
46 | + 'registered' => __('Registered', 'wps_export') |
|
47 | 47 | ); |
48 | - if ( !empty( $list_users ) ) { |
|
48 | + if (!empty($list_users)) { |
|
49 | 49 | $billing_address_indicator = get_option('wpshop_billing_address'); |
50 | 50 | $billing_address_indicator = $billing_address_indicator['choice']; |
51 | - foreach( $list_users as $user_post ) { |
|
52 | - if($term == 'orders') { |
|
51 | + foreach ($list_users as $user_post) { |
|
52 | + if ($term == 'orders') { |
|
53 | 53 | $vuser = false; |
54 | 54 | } |
55 | - $user = get_userdata( $user_post->USER_ID ); |
|
55 | + $user = get_userdata($user_post->USER_ID); |
|
56 | 56 | $tmp_array = array(); |
57 | - $last_name = get_user_meta( $user->ID, 'last_name', true ); |
|
58 | - $first_name = get_user_meta( $user->ID, 'first_name', true ); |
|
59 | - if( empty($last_name) ) |
|
57 | + $last_name = get_user_meta($user->ID, 'last_name', true); |
|
58 | + $first_name = get_user_meta($user->ID, 'first_name', true); |
|
59 | + if (empty($last_name)) |
|
60 | 60 | $last_name = $user->display_name; |
61 | - if( empty($first_name) ) |
|
61 | + if (empty($first_name)) |
|
62 | 62 | $first_name = '-'; |
63 | 63 | $tmp_array['name'] = $last_name; |
64 | 64 | $tmp_array['first_name'] = $first_name; |
65 | 65 | $tmp_array['email'] = $user->user_email; |
66 | 66 | $tmp_array['tel'] = ''; |
67 | 67 | $result = wps_address::get_addresses_list($user->ID); |
68 | - if( !empty($result) && !empty($result[$billing_address_indicator]) ) { |
|
69 | - foreach($result[$billing_address_indicator] as $address_id => $address_data) { |
|
70 | - if( !empty($address_data['phone']) ) { |
|
68 | + if (!empty($result) && !empty($result[$billing_address_indicator])) { |
|
69 | + foreach ($result[$billing_address_indicator] as $address_id => $address_data) { |
|
70 | + if (!empty($address_data['phone'])) { |
|
71 | 71 | $tmp_array['tel'] = $address_data['phone']; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | $tmp_array['registered'] = date('d M Y H:i', strtotime($user->user_registered)); |
76 | 76 | $posts_id = explode(',', $user_post->POST_ID); |
77 | - $orders = get_posts( array( |
|
77 | + $orders = get_posts(array( |
|
78 | 78 | 'include' => $posts_id, |
79 | 79 | 'post_type' => 'wpshop_shop_order', |
80 | 80 | 'posts_per_page' => -1 |
81 | 81 | )); |
82 | - foreach( $orders as $order ) { |
|
83 | - if($term == 'orders') { |
|
84 | - $command = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
85 | - if( ( !empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1 ) || ( !empty($dt2) && $dt2===true && $command['order_payment']['customer_choice']['method'] == 'free' ) ) { |
|
82 | + foreach ($orders as $order) { |
|
83 | + if ($term == 'orders') { |
|
84 | + $command = get_post_meta($order->ID, '_order_postmeta', true); |
|
85 | + if ((!empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1) || (!empty($dt2) && $dt2 === true && $command['order_payment']['customer_choice']['method'] == 'free')) { |
|
86 | 86 | $vuser = true; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | - if($term != 'orders') { |
|
90 | + if ($term != 'orders') { |
|
91 | 91 | $users_array[] = $tmp_array; |
92 | - } elseif($vuser) { |
|
92 | + } elseif ($vuser) { |
|
93 | 93 | $users_array[] = $tmp_array; |
94 | 94 | } |
95 | 95 | } |
@@ -104,66 +104,66 @@ discard block |
||
104 | 104 | * @param date $dt2 |
105 | 105 | * @return array |
106 | 106 | */ |
107 | - function get_orders($term, $dt1=null, $dt2=null) { |
|
107 | + function get_orders($term, $dt1 = null, $dt2 = null) { |
|
108 | 108 | $commands_array = array(); |
109 | 109 | $commands_array[] = array( |
110 | - 'order_type' => __( 'Order type', 'wps_export' ), |
|
111 | - 'order_invoice_ref' => __( 'Identifier', 'wps_export' ), |
|
112 | - 'name' => __( 'Name', 'wps_export' ), |
|
113 | - 'first_name' => __( 'First name', 'wps_export' ), |
|
114 | - 'email' => __( 'Mail', 'wps_export' ), |
|
115 | - 'tel' => __( 'Phone', 'wps_export' ), |
|
116 | - 'date_order' => __( 'Order date', 'wps_export' ), |
|
117 | - 'order_total_et' => __( 'Products ET', 'wps_export' ), |
|
118 | - 'order_shipping_cost_et' => __( 'Shipping ET', 'wps_export' ), |
|
119 | - 'order_shipping_cost_ati' => __( 'Shipping ATI', 'wps_export' ), |
|
120 | - 'order_discount_amount' => __( 'Order discount', 'wps_export' ), |
|
121 | - 'order_grand_total' => __( 'Order ATI', 'wps_export' ) |
|
110 | + 'order_type' => __('Order type', 'wps_export'), |
|
111 | + 'order_invoice_ref' => __('Identifier', 'wps_export'), |
|
112 | + 'name' => __('Name', 'wps_export'), |
|
113 | + 'first_name' => __('First name', 'wps_export'), |
|
114 | + 'email' => __('Mail', 'wps_export'), |
|
115 | + 'tel' => __('Phone', 'wps_export'), |
|
116 | + 'date_order' => __('Order date', 'wps_export'), |
|
117 | + 'order_total_et' => __('Products ET', 'wps_export'), |
|
118 | + 'order_shipping_cost_et' => __('Shipping ET', 'wps_export'), |
|
119 | + 'order_shipping_cost_ati' => __('Shipping ATI', 'wps_export'), |
|
120 | + 'order_discount_amount' => __('Order discount', 'wps_export'), |
|
121 | + 'order_grand_total' => __('Order ATI', 'wps_export') |
|
122 | 122 | ); |
123 | - $orders = get_posts( array( |
|
123 | + $orders = get_posts(array( |
|
124 | 124 | 'post_type' => 'wpshop_shop_order', |
125 | 125 | 'posts_per_page' => -1 |
126 | - ) ); |
|
127 | - if ( !empty( $orders ) ) { |
|
128 | - foreach( $orders as $order ) { |
|
129 | - if( !empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2)) ) { |
|
126 | + )); |
|
127 | + if (!empty($orders)) { |
|
128 | + foreach ($orders as $order) { |
|
129 | + if (!empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2))) { |
|
130 | 130 | $user = get_userdata($order->post_author); |
131 | 131 | $tmp_array = array(); |
132 | - $order_postmeta = get_post_meta( $order->ID, '_order_postmeta', true); |
|
133 | - $tmp_array['order_type'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? __( 'Invoice', 'wps_export' ) : ( ( !empty($order_postmeta['order_key']) ) ? __( 'Order', 'wps_export' ) : __( 'Quotation', 'wps_export' ) ); |
|
134 | - $tmp_array['order_invoice_ref'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? $order_postmeta['order_invoice_ref'] : ( ( !empty($order_postmeta['order_key']) ) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key'] ); |
|
135 | - $tmp_array['name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'last_name', true ) : ''; |
|
136 | - $tmp_array['first_name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'first_name', true ) : ''; |
|
137 | - $tmp_array['email'] = ( !empty($user->user_email) ) ? $user->user_email : ''; |
|
132 | + $order_postmeta = get_post_meta($order->ID, '_order_postmeta', true); |
|
133 | + $tmp_array['order_type'] = (!empty($order_postmeta['order_invoice_ref'])) ? __('Invoice', 'wps_export') : ((!empty($order_postmeta['order_key'])) ? __('Order', 'wps_export') : __('Quotation', 'wps_export')); |
|
134 | + $tmp_array['order_invoice_ref'] = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ((!empty($order_postmeta['order_key'])) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key']); |
|
135 | + $tmp_array['name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'last_name', true) : ''; |
|
136 | + $tmp_array['first_name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'first_name', true) : ''; |
|
137 | + $tmp_array['email'] = (!empty($user->user_email)) ? $user->user_email : ''; |
|
138 | 138 | $tmp_array['tel'] = ''; |
139 | - $order_info = get_post_meta( $order->ID, '_order_info', true); |
|
140 | - if( !empty($order_info) && !empty($order_info['billing']['address']['phone']) ) { |
|
139 | + $order_info = get_post_meta($order->ID, '_order_info', true); |
|
140 | + if (!empty($order_info) && !empty($order_info['billing']['address']['phone'])) { |
|
141 | 141 | $tmp_array['tel'] .= $order_info['billing']['address']['phone']; |
142 | 142 | } |
143 | 143 | $tmp_array['date_order'] = ''; |
144 | - if( !empty($order->post_date) ) { |
|
145 | - $tmp_array['date_order'] = mysql2date( get_option( 'date_format' ), $order->post_date, true ); |
|
144 | + if (!empty($order->post_date)) { |
|
145 | + $tmp_array['date_order'] = mysql2date(get_option('date_format'), $order->post_date, true); |
|
146 | 146 | } |
147 | - $tmp_array['order_total_et'] = number_format( ( !empty($order_postmeta['order_total_ht']) ) ? $order_postmeta['order_total_ht'] : 0, 2, '.', '' ); |
|
147 | + $tmp_array['order_total_et'] = number_format((!empty($order_postmeta['order_total_ht'])) ? $order_postmeta['order_total_ht'] : 0, 2, '.', ''); |
|
148 | 148 | //$tmp_array['order_total_ati'] = number_format( ( !empty($order_postmeta['order_total_ttc']) ) ? $order_postmeta['order_total_ttc'] : 0, 2, '.', '' ); |
149 | - $order_shipping_cost = ( !empty($order_postmeta['order_shipping_cost']) ) ? $order_postmeta['order_shipping_cost'] : 0; |
|
150 | - $price_piloting_option = get_option( 'wpshop_shop_price_piloting' ); |
|
151 | - if( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) { |
|
149 | + $order_shipping_cost = (!empty($order_postmeta['order_shipping_cost'])) ? $order_postmeta['order_shipping_cost'] : 0; |
|
150 | + $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
151 | + if (!empty($price_piloting_option) && $price_piloting_option == 'HT') { |
|
152 | 152 | $shipati = $order_shipping_cost * 1.2; |
153 | 153 | $shipet = $order_shipping_cost; |
154 | 154 | } else { |
155 | 155 | $shipet = $order_shipping_cost / 1.2; |
156 | 156 | $shipati = $order_shipping_cost; |
157 | 157 | } |
158 | - $tmp_array['order_shipping_cost_et'] = number_format( $shipet, 2, '.', '' ); |
|
159 | - $tmp_array['order_shipping_cost_ati'] = number_format( $shipati, 2, '.', '' ); |
|
160 | - $tmp_array['order_discount_amount'] = number_format( ( !empty($order_postmeta['order_discount_amount_total_cart']) ) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', '' ); |
|
161 | - $tmp_array['order_grand_total'] = number_format( ( !empty($order_postmeta['order_grand_total']) ) ? $order_postmeta['order_grand_total'] : 0, 2, '.', '' ); |
|
158 | + $tmp_array['order_shipping_cost_et'] = number_format($shipet, 2, '.', ''); |
|
159 | + $tmp_array['order_shipping_cost_ati'] = number_format($shipati, 2, '.', ''); |
|
160 | + $tmp_array['order_discount_amount'] = number_format((!empty($order_postmeta['order_discount_amount_total_cart'])) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', ''); |
|
161 | + $tmp_array['order_grand_total'] = number_format((!empty($order_postmeta['order_grand_total'])) ? $order_postmeta['order_grand_total'] : 0, 2, '.', ''); |
|
162 | 162 | $commands_array[] = $tmp_array; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | - $commands_array = apply_filters( 'wps_order_export_filter', $commands_array, $orders, $dt1, $dt2 ); |
|
166 | + $commands_array = apply_filters('wps_order_export_filter', $commands_array, $orders, $dt1, $dt2); |
|
167 | 167 | return $commands_array; |
168 | 168 | } |
169 | 169 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_export_mdl { |
3 | 5 | |
4 | 6 | /** |
@@ -56,10 +58,12 @@ discard block |
||
56 | 58 | $tmp_array = array(); |
57 | 59 | $last_name = get_user_meta( $user->ID, 'last_name', true ); |
58 | 60 | $first_name = get_user_meta( $user->ID, 'first_name', true ); |
59 | - if( empty($last_name) ) |
|
60 | - $last_name = $user->display_name; |
|
61 | - if( empty($first_name) ) |
|
62 | - $first_name = '-'; |
|
61 | + if( empty($last_name) ) { |
|
62 | + $last_name = $user->display_name; |
|
63 | + } |
|
64 | + if( empty($first_name) ) { |
|
65 | + $first_name = '-'; |
|
66 | + } |
|
63 | 67 | $tmp_array['name'] = $last_name; |
64 | 68 | $tmp_array['first_name'] = $first_name; |
65 | 69 | $tmp_array['email'] = $user->user_email; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | /** |
5 | 5 | * Get customers with a term: all, newsletters_site, newsletters_site_partners, date(between 2 dates) or if order is higher than. |
6 | 6 | * @param string $term |
7 | - * @param price/date $dt1 may be null |
|
7 | + * @param string|boolean $dt1 may be null |
|
8 | 8 | * @param date $dt2 may be null |
9 | 9 | * @return array |
10 | 10 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * @author ALLEGRE Jérôme - Eoxia dev team <[email protected]> |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | |
10 | 10 | /** Template Global vars **/ |
11 | 11 | DEFINE('WPS_MARKETING_TOOLS_DIR', basename(dirname(__FILE__))); |
12 | -DEFINE('WPS_MARKETING_TOOLS_PATH', str_replace( "\\", "/", str_replace( WPS_MARKETING_TOOLS_DIR, "", dirname( __FILE__ ) ) ) ); |
|
13 | -DEFINE('WPS_MARKETING_TOOLS_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPS_MARKETING_TOOLS_PATH ) ); |
|
12 | +DEFINE('WPS_MARKETING_TOOLS_PATH', str_replace("\\", "/", str_replace(WPS_MARKETING_TOOLS_DIR, "", dirname(__FILE__)))); |
|
13 | +DEFINE('WPS_MARKETING_TOOLS_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPS_MARKETING_TOOLS_PATH)); |
|
14 | 14 | |
15 | 15 | |
16 | 16 | |
17 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_marketing_tools_ctr.php' ); |
|
17 | +include(plugin_dir_path(__FILE__) . '/controller/wps_marketing_tools_ctr.php'); |
|
18 | 18 | // include( plugin_dir_path( __FILE__ ).'/model/wps_message_mdl.php' ); |
19 | 19 | |
20 | 20 | $wps_marketing_tools = new wps_marketing_tools_ctr(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_marketing_tools_ctr { |
3 | 3 | /** Define the main directory containing the template for the current plugin |
4 | 4 | * @var string |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | // Template loading... |
15 | 15 | $this->template_dir = WPS_MARKETING_TOOLS_PATH . WPS_MARKETING_TOOLS_DIR . "/templates/"; |
16 | 16 | |
17 | - add_action('wsphop_options', array( $this, 'declare_options'), 8); |
|
18 | - add_action('wpshop_free_shipping_cost_alert', array( $this, 'display_free_shipping_cost_alert')); |
|
19 | - add_shortcode('display_save_money_message', array( $this, 'display_save_money_message')); |
|
17 | + add_action('wsphop_options', array($this, 'declare_options'), 8); |
|
18 | + add_action('wpshop_free_shipping_cost_alert', array($this, 'display_free_shipping_cost_alert')); |
|
19 | + add_shortcode('display_save_money_message', array($this, 'display_save_money_message')); |
|
20 | 20 | |
21 | - add_shortcode( 'wps_low_stock_alert', array($this, 'display_alert_stock_message' ) ); |
|
21 | + add_shortcode('wps_low_stock_alert', array($this, 'display_alert_stock_message')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * OPTIONS - Declare options |
26 | 26 | */ |
27 | - function declare_options () { |
|
28 | - if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) { |
|
29 | - $wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
|
30 | - $old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
|
27 | + function declare_options() { |
|
28 | + if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') { |
|
29 | + $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
30 | + $old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : ''; |
|
31 | 31 | |
32 | - if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' ) |
|
33 | - && ( $old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation' ) ) { |
|
32 | + if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation') |
|
33 | + && ($old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation')) { |
|
34 | 34 | register_setting('wpshop_options', 'wpshop_cart_option', array($this, 'wpshop_options_validate_free_shipping_cost_alert')); |
35 | - add_settings_field('wpshop_free_shipping_cost_alert', __('Display a free shipping cost alert in the cart', 'wpshop'), array( $this, 'wpshop_free_shipping_cost_alert_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
35 | + add_settings_field('wpshop_free_shipping_cost_alert', __('Display a free shipping cost alert in the cart', 'wpshop'), array($this, 'wpshop_free_shipping_cost_alert_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
36 | 36 | // Low stock alert option |
37 | 37 | register_setting('wpshop_options', 'wpshop_low_stock_alert_options', array($this, 'wpshop_low_stock_alert_validator')); |
38 | 38 | add_settings_field('wpshop_display_low_stock', __('Display Low stock Alert message', 'wpshop'), array($this, 'wpshop_display_low_stock_alert_interface'), 'wpshop_display_option', 'wpshop_display_options_sections'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * OPTIONS - Display Free Shipping alert option field |
46 | 46 | */ |
47 | - function wpshop_free_shipping_cost_alert_field () { |
|
47 | + function wpshop_free_shipping_cost_alert_field() { |
|
48 | 48 | $cart_option = get_option('wpshop_cart_option'); |
49 | 49 | $input_def = array(); |
50 | 50 | $input_def['name'] = ''; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $input_def['valueToPut'] = 'index'; |
54 | 54 | $input_def['value'] = !empty($cart_option['free_shipping_cost_alert']) ? $cart_option['free_shipping_cost_alert'][0] : ''; |
55 | 55 | $input_def['possible_value'] = 'yes'; |
56 | - $output = wpshop_form::check_input_type($input_def, 'wpshop_cart_option[free_shipping_cost_alert]') . '<a href="#" title="'.__('Check this box if you want to display an free shipping cost in the mini-cart','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
56 | + $output = wpshop_form::check_input_type($input_def, 'wpshop_cart_option[free_shipping_cost_alert]') . '<a href="#" title="' . __('Check this box if you want to display an free shipping cost in the mini-cart', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
57 | 57 | |
58 | 58 | echo $output; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param unknown_type $input |
64 | 64 | * @return unknown |
65 | 65 | */ |
66 | - function wpshop_options_validate_free_shipping_cost_alert ($input) { |
|
66 | + function wpshop_options_validate_free_shipping_cost_alert($input) { |
|
67 | 67 | return $input; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $input |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - function wpshop_low_stock_alert_validator ($input) { |
|
75 | + function wpshop_low_stock_alert_validator($input) { |
|
76 | 76 | return $input; |
77 | 77 | } |
78 | 78 | |
@@ -81,48 +81,48 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function wpshop_display_low_stock_alert_interface() { |
83 | 83 | $low_stock_option = get_option('wpshop_low_stock_alert_options'); |
84 | - $activate_low_stock_alert = ( (!empty($low_stock_option) && !empty($low_stock_option['active']) && $low_stock_option['active'] == 'on') ? 'checked="checked"' : null); |
|
85 | - $based_on_stock = ( !empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'yes') ? 'checked="checked"' : null; |
|
86 | - $not_based_on_stock = ( !empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'no') ? 'checked="checked"' : null; |
|
87 | - $alert_limit = ( !empty($low_stock_option) && !empty($low_stock_option['alert_limit']) ) ? $low_stock_option['alert_limit'] : ''; |
|
84 | + $activate_low_stock_alert = ((!empty($low_stock_option) && !empty($low_stock_option['active']) && $low_stock_option['active'] == 'on') ? 'checked="checked"' : null); |
|
85 | + $based_on_stock = (!empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'yes') ? 'checked="checked"' : null; |
|
86 | + $not_based_on_stock = (!empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'no') ? 'checked="checked"' : null; |
|
87 | + $alert_limit = (!empty($low_stock_option) && !empty($low_stock_option['alert_limit'])) ? $low_stock_option['alert_limit'] : ''; |
|
88 | 88 | |
89 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_low_stock_alert_configuration_interface") ); |
|
89 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_low_stock_alert_configuration_interface")); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Display a free Shipping cost alert in cart and shop |
94 | 94 | */ |
95 | - function display_free_shipping_cost_alert () { |
|
95 | + function display_free_shipping_cost_alert() { |
|
96 | 96 | global $wpdb; |
97 | 97 | |
98 | 98 | $output = ''; |
99 | - $cart = ( !empty($_SESSION['cart']) && is_array($_SESSION['cart']) ) ? $_SESSION['cart'] : null; |
|
99 | + $cart = (!empty($_SESSION['cart']) && is_array($_SESSION['cart'])) ? $_SESSION['cart'] : null; |
|
100 | 100 | $cart_option = get_option('wpshop_cart_option'); |
101 | 101 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
102 | 102 | |
103 | 103 | // Get a shipping mode, in order : selected, else default, else first, else shipping_rules. |
104 | - $shipping_modes = get_option( 'wps_shipping_mode' ); |
|
105 | - if( !empty($shipping_modes) && !empty($shipping_modes['modes']) ) { |
|
106 | - if( !empty($shipping_modes['default_choice']) && !empty( $shipping_modes['modes'][$shipping_modes['default_choice']] ) ) { |
|
104 | + $shipping_modes = get_option('wps_shipping_mode'); |
|
105 | + if (!empty($shipping_modes) && !empty($shipping_modes['modes'])) { |
|
106 | + if (!empty($shipping_modes['default_choice']) && !empty($shipping_modes['modes'][$shipping_modes['default_choice']])) { |
|
107 | 107 | $shipping_rules_option = $shipping_modes['modes'][$shipping_modes['default_choice']]; |
108 | - } elseif( !empty($shipping_modes['modes']['default_shipping_mode']) ) { |
|
108 | + } elseif (!empty($shipping_modes['modes']['default_shipping_mode'])) { |
|
109 | 109 | $shipping_rules_option = $shipping_modes['modes']['default_shipping_mode']; |
110 | 110 | } else { |
111 | - $shipping_rules_option = reset( $shipping_modes['modes'] ); |
|
111 | + $shipping_rules_option = reset($shipping_modes['modes']); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - $shipping_rules_option = get_option( 'wpshop_shipping_rules' ); |
|
114 | + $shipping_rules_option = get_option('wpshop_shipping_rules'); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) |
|
117 | + if (!empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0) |
|
118 | 118 | $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
119 | - if ( !empty($cart_option) && !empty($cart_option['free_shipping_cost_alert']) ) { |
|
120 | - if ( !empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
|
121 | - $order_amount = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
|
122 | - if ( $order_amount < $free_shipping_cost_limit ) { |
|
119 | + if (!empty($cart_option) && !empty($cart_option['free_shipping_cost_alert'])) { |
|
120 | + if (!empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
|
121 | + $order_amount = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
|
122 | + if ($order_amount < $free_shipping_cost_limit) { |
|
123 | 123 | $free_in = number_format((float)($free_shipping_cost_limit - $order_amount), 2, '.', ''); |
124 | 124 | $currency = wpshop_tools::wpshop_get_currency(); |
125 | - $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in. ' ' . $currency); |
|
125 | + $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in . ' ' . $currency); |
|
126 | 126 | } |
127 | 127 | else { |
128 | 128 | $output = __('Free shipping cost', 'wpshop'); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | * @param string $price_infos |
138 | 138 | * @return string |
139 | 139 | */ |
140 | - function display_message_you_save_money ( $price_infos ) { |
|
140 | + function display_message_you_save_money($price_infos) { |
|
141 | 141 | $output = ''; |
142 | - if ( !empty($price_infos) ) { |
|
143 | - if ( !empty($price_infos) && !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) ) { |
|
142 | + if (!empty($price_infos)) { |
|
143 | + if (!empty($price_infos) && !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist'])) { |
|
144 | 144 | $tax_piloting_option = get_option('wpshop_shop_price_piloting'); |
145 | - $save_amount = ( !empty($tax_piloting_option) && $tax_piloting_option == 'HT') ? ( $price_infos['et'] - $price_infos['discount']['discount_et_price'] ) : ( $price_infos['ati'] - $price_infos['discount']['discount_ati_price'] ); |
|
145 | + $save_amount = (!empty($tax_piloting_option) && $tax_piloting_option == 'HT') ? ($price_infos['et'] - $price_infos['discount']['discount_et_price']) : ($price_infos['ati'] - $price_infos['discount']['discount_ati_price']); |
|
146 | 146 | ob_start(); |
147 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_marketing_save_money_message") ); |
|
147 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_marketing_save_money_message")); |
|
148 | 148 | $message .= ob_get_contents(); |
149 | 149 | ob_end_clean(); |
150 | 150 | } |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | * @param integer $order_id |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - function display_ecommerce_ga_tracker( $order_id ) { |
|
160 | + function display_ecommerce_ga_tracker($order_id) { |
|
161 | 161 | global $wpdb; |
162 | 162 | $tracker = ''; |
163 | - if( !empty($order_id) ) { |
|
163 | + if (!empty($order_id)) { |
|
164 | 164 | $ga_account_id = get_option('wpshop_ga_account_id'); |
165 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true); |
|
166 | - $order_info = get_post_meta( $order_id, '_order_info', true); |
|
167 | - if( !empty($ga_account_id) && !empty($order_meta) && !empty($order_info) ) { |
|
165 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
166 | + $order_info = get_post_meta($order_id, '_order_info', true); |
|
167 | + if (!empty($ga_account_id) && !empty($order_meta) && !empty($order_info)) { |
|
168 | 168 | ob_start(); |
169 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_ga_order_tracker") ); |
|
169 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_ga_order_tracker")); |
|
170 | 170 | $message .= ob_get_contents(); |
171 | 171 | ob_end_clean(); |
172 | 172 | } |
@@ -179,20 +179,20 @@ discard block |
||
179 | 179 | * @param string $args |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - function display_alert_stock_message( $args ) { |
|
182 | + function display_alert_stock_message($args) { |
|
183 | 183 | $message = ''; |
184 | - $post_ID = ( !empty($args) && !empty($args['id']) ) ? $args['id'] : ''; |
|
185 | - $low_stock_alert_option = get_option('wpshop_low_stock_alert_options'); |
|
184 | + $post_ID = (!empty($args) && !empty($args['id'])) ? $args['id'] : ''; |
|
185 | + $low_stock_alert_option = get_option('wpshop_low_stock_alert_options'); |
|
186 | 186 | |
187 | - if ( !empty( $low_stock_alert_option ) && !empty($low_stock_alert_option['active']) && !empty($post_ID) ) { |
|
188 | - $product = wpshop_products::get_product_data( $post_ID ); |
|
187 | + if (!empty($low_stock_alert_option) && !empty($low_stock_alert_option['active']) && !empty($post_ID)) { |
|
188 | + $product = wpshop_products::get_product_data($post_ID); |
|
189 | 189 | |
190 | 190 | $product_stock = $product['product_stock']; |
191 | - $manage_product_stock = (!empty($product['manage_stock']) && ( strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop')) )) ? true : false; |
|
191 | + $manage_product_stock = (!empty($product['manage_stock']) && (strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop')))) ? true : false; |
|
192 | 192 | |
193 | - if ( ( $product_stock > 0 ) && ( empty( $low_stock_alert_option['based_on_stock'] ) || ( ('no' == $low_stock_alert_option['based_on_stock'] ) || ( ( 'yes' == $low_stock_alert_option['based_on_stock'] ) && ( $low_stock_alert_option[ 'alert_limit' ] >= $product_stock ) ) ) ) ) { |
|
193 | + if (($product_stock > 0) && (empty($low_stock_alert_option['based_on_stock']) || (('no' == $low_stock_alert_option['based_on_stock']) || (('yes' == $low_stock_alert_option['based_on_stock']) && ($low_stock_alert_option['alert_limit'] >= $product_stock))))) { |
|
194 | 194 | ob_start(); |
195 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_low_stock_alert_message") ); |
|
195 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_low_stock_alert_message")); |
|
196 | 196 | $message .= ob_get_contents(); |
197 | 197 | ob_end_clean(); |
198 | 198 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_marketing_tools_ctr { |
3 | 5 | /** Define the main directory containing the template for the current plugin |
4 | 6 | * @var string |
@@ -114,8 +116,9 @@ discard block |
||
114 | 116 | $shipping_rules_option = get_option( 'wpshop_shipping_rules' ); |
115 | 117 | } |
116 | 118 | |
117 | - if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) |
|
118 | - $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
|
119 | + if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) { |
|
120 | + $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
|
121 | + } |
|
119 | 122 | if ( !empty($cart_option) && !empty($cart_option['free_shipping_cost_alert']) ) { |
120 | 123 | if ( !empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
121 | 124 | $order_amount = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
@@ -123,8 +126,7 @@ discard block |
||
123 | 126 | $free_in = number_format((float)($free_shipping_cost_limit - $order_amount), 2, '.', ''); |
124 | 127 | $currency = wpshop_tools::wpshop_get_currency(); |
125 | 128 | $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in. ' ' . $currency); |
126 | - } |
|
127 | - else { |
|
129 | + } else { |
|
128 | 130 | $output = __('Free shipping cost', 'wpshop'); |
129 | 131 | } |
130 | 132 | } |
@@ -1,5 +1,5 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <span class="wpshop_save_money_message wps-label-vert"> |
4 | - <?php _e('Saving', 'wpshop'); ?> <?php echo number_format($save_amount,2); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?> |
|
4 | + <?php _e('Saving', 'wpshop'); ?> <?php echo number_format($save_amount, 2); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?> |
|
5 | 5 | </span> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,8 +1,8 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | $extradata = ''; |
3 | -if ( !empty($low_stock_alert_option['based_on_stock']) && $low_stock_alert_option['based_on_stock'] == 'yes' && !empty( $low_stock_alert_option['alert_limit']) ) : ?> |
|
4 | - <?php if ( $product_stock <= $low_stock_alert_option['alert_limit'] ) : |
|
5 | - $extradata = ', '. sprintf( __('%s products in stock', 'wpshop'), number_format( $product_stock, 0 ) ); |
|
3 | +if (!empty($low_stock_alert_option['based_on_stock']) && $low_stock_alert_option['based_on_stock'] == 'yes' && !empty($low_stock_alert_option['alert_limit'])) : ?> |
|
4 | + <?php if ($product_stock <= $low_stock_alert_option['alert_limit']) : |
|
5 | + $extradata = ', ' . sprintf(__('%s products in stock', 'wpshop'), number_format($product_stock, 0)); |
|
6 | 6 | endif; ?> |
7 | 7 | <?php endif; ?> |
8 | 8 | <div class="wps-product-section"> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,34 +1,34 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | - $company_infos = get_option( 'wpshop_company_info' ); ?> |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | + $company_infos = get_option('wpshop_company_info'); ?> |
|
3 | 3 | <script type="text/javascript"> |
4 | 4 | var _gaq = _gaq || []; |
5 | 5 | _gaq.push( ['_setAccount', '<?php echo $ga_account_id; ?>'] ); |
6 | 6 | _gaq.push( ['_trackPageview'] ); |
7 | 7 | _gaq.push(['_addTrans', |
8 | 8 | '<?php echo $order_id; ?>', |
9 | - '<?php echo ( !empty($company_infos) && !empty($company_infos['company_name']) ? $company_infos['company_name'] : '' ) ; ?>', |
|
9 | + '<?php echo (!empty($company_infos) && !empty($company_infos['company_name']) ? $company_infos['company_name'] : ''); ?>', |
|
10 | 10 | '<?php echo number_format($order_meta['order_grand_total'], 2, '.', ''); ?>', '<?php echo number_format($total_tva, 2, '.', ''); ?>', |
11 | - '<?php echo ( ( !empty($order_meta['order_shipping_cost']) ) ? $order_meta['order_shipping_cost'] : 0); ?>', |
|
12 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['city']) ) ? $order_info['billing']['address']['city'] : ''); ?>', |
|
13 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['state']) ) ? $order_info['billing']['address']['state'] : ''); ?>', |
|
14 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['country']) ) ? $order_info['billing']['address']['country'] : ''); ?>']); |
|
11 | + '<?php echo ((!empty($order_meta['order_shipping_cost'])) ? $order_meta['order_shipping_cost'] : 0); ?>', |
|
12 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['city'])) ? $order_info['billing']['address']['city'] : ''); ?>', |
|
13 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['state'])) ? $order_info['billing']['address']['state'] : ''); ?>', |
|
14 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['country'])) ? $order_info['billing']['address']['country'] : ''); ?>']); |
|
15 | 15 | |
16 | - <?php if ( !empty( $order_meta['order_items'] ) && is_array( $order_meta['order_items'] ) ) : ?> |
|
17 | - <?php foreach( $order_meta['order_items'] as $item ) : |
|
16 | + <?php if (!empty($order_meta['order_items']) && is_array($order_meta['order_items'])) : ?> |
|
17 | + <?php foreach ($order_meta['order_items'] as $item) : |
|
18 | 18 | /** Variation **/ |
19 | 19 | $variation = ''; |
20 | - $variation_definition = get_post_meta( $item['item_id'], '_wpshop_variations_attribute_def', true); |
|
21 | - if ( !empty($variation_definition) && is_array($variation_definition) ) : |
|
22 | - foreach( $variation_definition as $k => $value ) : |
|
23 | - $attribute_def = wpshop_attributes::getElement( $k, '"valid"', 'code' ); |
|
24 | - if ( !empty($attribute_def) ) : |
|
25 | - $variation .= $attribute_def->frontend_label.' : '; |
|
26 | - if ( $attribute_def->data_type_to_use == 'custom' ) : |
|
27 | - $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $value ); |
|
28 | - $variation .= $wpdb->get_var( $query ); |
|
20 | + $variation_definition = get_post_meta($item['item_id'], '_wpshop_variations_attribute_def', true); |
|
21 | + if (!empty($variation_definition) && is_array($variation_definition)) : |
|
22 | + foreach ($variation_definition as $k => $value) : |
|
23 | + $attribute_def = wpshop_attributes::getElement($k, '"valid"', 'code'); |
|
24 | + if (!empty($attribute_def)) : |
|
25 | + $variation .= $attribute_def->frontend_label . ' : '; |
|
26 | + if ($attribute_def->data_type_to_use == 'custom') : |
|
27 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $value); |
|
28 | + $variation .= $wpdb->get_var($query); |
|
29 | 29 | |
30 | 30 | else : |
31 | - $variation .= get_the_title( $value ); |
|
31 | + $variation .= get_the_title($value); |
|
32 | 32 | endif; |
33 | 33 | endif; |
34 | 34 | endforeach; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ?> |
38 | 38 | _gaq.push(['_addItem', |
39 | 39 | '<?php echo $order_id; ?>', |
40 | - '<?php echo ( (!empty($item_meta) && !empty($item_meta['barcode']) ) ? $item_meta['barcode'] : ''); ?>', |
|
40 | + '<?php echo ((!empty($item_meta) && !empty($item_meta['barcode'])) ? $item_meta['barcode'] : ''); ?>', |
|
41 | 41 | '<?php echo $item['item_name']; ?>', |
42 | 42 | '<?php echo $variation; ?>', |
43 | 43 | '<?php echo $item['item_pu_ttc']; ?>', |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | $company_infos = get_option( 'wpshop_company_info' ); ?> |
3 | 5 | <script type="text/javascript"> |
4 | 6 | var _gaq = _gaq || []; |
@@ -27,8 +29,10 @@ discard block |
||
27 | 29 | $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $value ); |
28 | 30 | $variation .= $wpdb->get_var( $query ); |
29 | 31 | |
30 | - else : |
|
32 | + else { |
|
33 | + : |
|
31 | 34 | $variation .= get_the_title( $value ); |
35 | + } |
|
32 | 36 | endif; |
33 | 37 | endif; |
34 | 38 | endforeach; |