@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<?php esc_html_e( 'Thanks, your order has been received', 'wpshop' ); ?> |
|
19 | +<?php esc_html_e('Thanks, your order has been received', 'wpshop'); ?> |
|
20 | 20 | |
21 | 21 | <ul> |
22 | - <li><?php esc_html_e( 'Order number', 'wpshop' ); ?> : <strong><?php echo esc_html( $order->data['title'] ); ?></strong></li> |
|
23 | - <li><?php esc_html_e( 'Date', 'wpshop' ); ?> : <strong><?php echo esc_html( $order->data['date_commande']['rendered']['date'] ); ?></strong></li> |
|
24 | - <li><?php esc_html_e( 'Total', 'wpshop' ); ?> : <strong><?php echo esc_html( number_format( $order->data['total_ttc'], 2 ) ); ?>€</strong></li> |
|
25 | - <li><?php esc_html_e( 'Method of payment', 'wpshop' ); ?> : |
|
26 | - <strong><?php echo esc_html( Payment::g()->get_payment_title( $order->data['payment_method'] ) ); ?></strong> |
|
22 | + <li><?php esc_html_e('Order number', 'wpshop'); ?> : <strong><?php echo esc_html($order->data['title']); ?></strong></li> |
|
23 | + <li><?php esc_html_e('Date', 'wpshop'); ?> : <strong><?php echo esc_html($order->data['date_commande']['rendered']['date']); ?></strong></li> |
|
24 | + <li><?php esc_html_e('Total', 'wpshop'); ?> : <strong><?php echo esc_html(number_format($order->data['total_ttc'], 2)); ?>€</strong></li> |
|
25 | + <li><?php esc_html_e('Method of payment', 'wpshop'); ?> : |
|
26 | + <strong><?php echo esc_html(Payment::g()->get_payment_title($order->data['payment_method'])); ?></strong> |
|
27 | 27 | </li> |
28 | 28 | </ul> |
29 | 29 | |
30 | -<h2><?php esc_html_e( 'Order detail', 'wpshop' ); ?></h2> |
|
30 | +<h2><?php esc_html_e('Order detail', 'wpshop'); ?></h2> |
|
31 | 31 | |
32 | 32 | <table class="wpeo-table"> |
33 | 33 | <thead> |
34 | 34 | <tr> |
35 | 35 | <th></th> |
36 | - <th data-title="<?php esc_html_e( 'Product name', 'wpshop' ); ?>"><?php esc_html_e( 'Product name', 'wpshop' ); ?></th> |
|
37 | - <th data-title="<?php esc_html_e( 'VAT', 'wpshop' ); ?>"><?php esc_html_e( 'VAT', 'wpshop' ); ?></th> |
|
38 | - <th data-title="<?php esc_html_e( 'P.U. HT', 'wpshop' ); ?>"><?php esc_html_e( 'P.U HT', 'wpshop' ); ?></th> |
|
39 | - <th data-title="<?php esc_html_e( 'Quantity', 'wpshop' ); ?>"><?php esc_html_e( 'Quantity', 'wpshop' ); ?></th> |
|
40 | - <th data-title="<?php esc_html_e( 'Total HT', 'wpshop' ); ?>"><?php esc_html_e( 'Total HT', 'wpshop' ); ?></th> |
|
36 | + <th data-title="<?php esc_html_e('Product name', 'wpshop'); ?>"><?php esc_html_e('Product name', 'wpshop'); ?></th> |
|
37 | + <th data-title="<?php esc_html_e('VAT', 'wpshop'); ?>"><?php esc_html_e('VAT', 'wpshop'); ?></th> |
|
38 | + <th data-title="<?php esc_html_e('P.U. HT', 'wpshop'); ?>"><?php esc_html_e('P.U HT', 'wpshop'); ?></th> |
|
39 | + <th data-title="<?php esc_html_e('Quantity', 'wpshop'); ?>"><?php esc_html_e('Quantity', 'wpshop'); ?></th> |
|
40 | + <th data-title="<?php esc_html_e('Total HT', 'wpshop'); ?>"><?php esc_html_e('Total HT', 'wpshop'); ?></th> |
|
41 | 41 | </tr> |
42 | 42 | </thead> |
43 | 43 | <tbody> |
44 | 44 | <?php |
45 | - if ( ! empty( $order->data['lines'] ) ) : |
|
46 | - foreach ( $order->data['lines'] as $line ) : |
|
45 | + if (!empty($order->data['lines'])) : |
|
46 | + foreach ($order->data['lines'] as $line) : |
|
47 | 47 | ?> |
48 | 48 | <tr> |
49 | - <td><?php echo get_the_post_thumbnail( $line['id'], array( 80, 80 ) ); ?></td> |
|
50 | - <td><a href="<?php echo esc_url( get_permalink( $line['id'] ) ); ?>"><?php echo esc_html( $line['libelle'] ); ?></a></td> |
|
51 | - <td><?php echo esc_html( number_format( $line['tva_tx'], 2, ',', '' ) ); ?>%</td> |
|
52 | - <td><?php echo esc_html( number_format( $line['price'], 2, ',', '' ) ); ?>€</td> |
|
53 | - <td><?php echo esc_html( $line['qty'] ); ?></td> |
|
54 | - <td><?php echo esc_html( number_format( $line['price'] * $line['qty'], 2, ',', '' ) ); ?>€</td> |
|
49 | + <td><?php echo get_the_post_thumbnail($line['id'], array(80, 80)); ?></td> |
|
50 | + <td><a href="<?php echo esc_url(get_permalink($line['id'])); ?>"><?php echo esc_html($line['libelle']); ?></a></td> |
|
51 | + <td><?php echo esc_html(number_format($line['tva_tx'], 2, ',', '')); ?>%</td> |
|
52 | + <td><?php echo esc_html(number_format($line['price'], 2, ',', '')); ?>€</td> |
|
53 | + <td><?php echo esc_html($line['qty']); ?></td> |
|
54 | + <td><?php echo esc_html(number_format($line['price'] * $line['qty'], 2, ',', '')); ?>€</td> |
|
55 | 55 | </tr> |
56 | 56 | <?php |
57 | 57 | endforeach; |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | </tbody> |
61 | 61 | <tfoot> |
62 | 62 | <tr> |
63 | - <td colspan="5"><strong><?php esc_html_e( 'Total HT', 'wpshop' ); ?></strong></td> |
|
64 | - <td><?php echo number_format( $order->data['total_ht'], 2, ',', '' ); ?>€</td> |
|
63 | + <td colspan="5"><strong><?php esc_html_e('Total HT', 'wpshop'); ?></strong></td> |
|
64 | + <td><?php echo number_format($order->data['total_ht'], 2, ',', ''); ?>€</td> |
|
65 | 65 | </tr> |
66 | 66 | <?php |
67 | - if ( ! empty( $tva_lines ) ) : |
|
68 | - foreach ( $tva_lines as $key => $tva_line ) : |
|
67 | + if (!empty($tva_lines)) : |
|
68 | + foreach ($tva_lines as $key => $tva_line) : |
|
69 | 69 | ?> |
70 | 70 | <tr> |
71 | - <td colspan="5"><strong><?php esc_html_e( 'Total VAT', 'wpshop' ); ?> <?php echo number_format( $key, 2, ',', '' ); ?>%</strong></td> |
|
72 | - <td><?php echo number_format( $tva_line, 2, ',', '' ); ?>€</td> |
|
71 | + <td colspan="5"><strong><?php esc_html_e('Total VAT', 'wpshop'); ?> <?php echo number_format($key, 2, ',', ''); ?>%</strong></td> |
|
72 | + <td><?php echo number_format($tva_line, 2, ',', ''); ?>€</td> |
|
73 | 73 | </tr> |
74 | 74 | <?php |
75 | 75 | endforeach; |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | ?> |
78 | 78 | |
79 | 79 | <tr> |
80 | - <td colspan="5"><strong><?php esc_html_e( 'Total TTC', 'wpshop' ); ?></strong></td> |
|
81 | - <td><strong><?php echo number_format( $order->data['total_ttc'], 2, ',', '' ); ?>€</strong></td> |
|
80 | + <td colspan="5"><strong><?php esc_html_e('Total TTC', 'wpshop'); ?></strong></td> |
|
81 | + <td><strong><?php echo number_format($order->data['total_ttc'], 2, ',', ''); ?>€</strong></td> |
|
82 | 82 | </tr> |
83 | 83 | </tfoot> |
84 | 84 | </table> |
85 | 85 | |
86 | 86 | <a href="<?php echo Pages::g()->get_account_link(); ?>orders/" class="wpeo-button button-main"> |
87 | - <span><?php esc_html_e( 'See my orders', 'wpshop' ); ?></span> |
|
87 | + <span><?php esc_html_e('See my orders', 'wpshop'); ?></span> |
|
88 | 88 | </a> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Payement Class. |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | $this->default_options = array( |
40 | 40 | 'cheque' => array( |
41 | 41 | 'active' => true, |
42 | - 'title' => __( 'Cheque', 'wpshop' ), |
|
43 | - 'description' => __( 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'wpshop' ), |
|
42 | + 'title' => __('Cheque', 'wpshop'), |
|
43 | + 'description' => __('Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'wpshop'), |
|
44 | 44 | ), |
45 | 45 | 'payment_in_shop' => array( |
46 | 46 | 'active' => true, |
47 | - 'title' => __( 'Payment in shop', 'wpshop' ), |
|
48 | - 'description' => __( 'Pay and pick up directly your products at the shop.', 'wpshop' ), |
|
47 | + 'title' => __('Payment in shop', 'wpshop'), |
|
48 | + 'description' => __('Pay and pick up directly your products at the shop.', 'wpshop'), |
|
49 | 49 | ), |
50 | 50 | 'paypal' => array( |
51 | 51 | 'active' => true, |
52 | - 'title' => __( 'PayPal', 'wpshop' ), |
|
53 | - 'description' => __( 'Accept payments via PayPal using account balance or credit card.', 'wpshop' ), |
|
52 | + 'title' => __('PayPal', 'wpshop'), |
|
53 | + 'description' => __('Accept payments via PayPal using account balance or credit card.', 'wpshop'), |
|
54 | 54 | 'paypal_email' => '', |
55 | 55 | 'use_paypal_sandbox' => false, |
56 | 56 | ), |
57 | 57 | 'stripe' => array( |
58 | 58 | 'active' => true, |
59 | - 'title' => __( 'Stripe', 'wpshop' ), |
|
60 | - 'description' => __( 'Use your credit card to place your order', 'wpshop' ), |
|
59 | + 'title' => __('Stripe', 'wpshop'), |
|
60 | + 'description' => __('Use your credit card to place your order', 'wpshop'), |
|
61 | 61 | 'publish_key' => '', |
62 | 62 | 'secret_key' => '', |
63 | 63 | 'use_stripe_sandbox' => false, |
64 | 64 | ), |
65 | 65 | ); |
66 | 66 | |
67 | - $this->default_options = apply_filters( 'wps_payment_methods', $this->default_options ); |
|
67 | + $this->default_options = apply_filters('wps_payment_methods', $this->default_options); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array Les données de la méthode de paiement. |
78 | 78 | */ |
79 | - public function get_payment_option( $slug = '' ) { |
|
80 | - $payment_methods_option = get_option( 'wps_payment_methods', $this->default_options ); |
|
79 | + public function get_payment_option($slug = '') { |
|
80 | + $payment_methods_option = get_option('wps_payment_methods', $this->default_options); |
|
81 | 81 | |
82 | - if ( empty( $slug ) || ! isset( $payment_methods_option[ $slug ] ) ) { |
|
82 | + if (empty($slug) || !isset($payment_methods_option[$slug])) { |
|
83 | 83 | return $payment_methods_option; |
84 | 84 | } |
85 | 85 | |
86 | - return $payment_methods_option[ $slug ]; |
|
86 | + return $payment_methods_option[$slug]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array Le titre de la méthode de paiement. |
99 | 99 | */ |
100 | - public function get_payment_title( $slug ) { |
|
101 | - $payment_methods_option = get_option( 'wps_payment_methods', $this->default_options ); |
|
102 | - $payment_method = $payment_methods_option[ $slug ]; |
|
100 | + public function get_payment_title($slug) { |
|
101 | + $payment_methods_option = get_option('wps_payment_methods', $this->default_options); |
|
102 | + $payment_method = $payment_methods_option[$slug]; |
|
103 | 103 | |
104 | - if ( empty( $payment_method ) ) { |
|
104 | + if (empty($payment_method)) { |
|
105 | 105 | return null; |
106 | 106 | } |
107 | 107 | |
@@ -118,38 +118,38 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return string Le message |
120 | 120 | */ |
121 | - public function convert_status( $object ) { |
|
121 | + public function convert_status($object) { |
|
122 | 122 | $statut = ''; |
123 | 123 | |
124 | - if ( 'wps-order' === $object['type'] ) { |
|
125 | - switch ( $object['payment_method'] ) { |
|
124 | + if ('wps-order' === $object['type']) { |
|
125 | + switch ($object['payment_method']) { |
|
126 | 126 | case 'cheque': |
127 | - if ( $object['billed'] ) { |
|
127 | + if ($object['billed']) { |
|
128 | 128 | $statut = 'Payée'; |
129 | 129 | } else { |
130 | 130 | $statut = 'En attente du chèque'; |
131 | 131 | } |
132 | 132 | break; |
133 | 133 | case 'paypal': |
134 | - if ( $object['billed'] ) { |
|
134 | + if ($object['billed']) { |
|
135 | 135 | $statut = 'Payée'; |
136 | - } elseif ( $object['payment_failed'] ) { |
|
136 | + } elseif ($object['payment_failed']) { |
|
137 | 137 | $statut = 'Paiment échoué.'; |
138 | 138 | } else { |
139 | 139 | $statut = 'En attente du paiement'; |
140 | 140 | } |
141 | 141 | break; |
142 | 142 | case 'payment_in_shop': |
143 | - if ( $object['billed'] ) { |
|
143 | + if ($object['billed']) { |
|
144 | 144 | $statut = 'Payée'; |
145 | 145 | } else { |
146 | 146 | $statut = 'En attente du paiement.<br />Paiement a régler en boutique'; |
147 | 147 | } |
148 | 148 | break; |
149 | 149 | case 'stripe': |
150 | - if ( $object['billed'] ) { |
|
150 | + if ($object['billed']) { |
|
151 | 151 | $statut = 'Payée'; |
152 | - } elseif ( $object['payment_failed'] ) { |
|
152 | + } elseif ($object['payment_failed']) { |
|
153 | 153 | $statut = 'Paiment échoué.'; |
154 | 154 | } else { |
155 | 155 | $statut = 'En attente du paiement'; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | default: |
159 | 159 | break; |
160 | 160 | } |
161 | - } elseif ( 'wps-doli-invoice' === $object['type'] ) { |
|
162 | - if ( $object['paye'] ) { |
|
161 | + } elseif ('wps-doli-invoice' === $object['type']) { |
|
162 | + if ($object['paye']) { |
|
163 | 163 | $statut = 'Payée'; |
164 | 164 | } else { |
165 | 165 | $statut = 'Impayée'; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Payment Action Class. |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'wps_setting_payment_method_payment_in_shop', array( $this, 'callback_setting_payment_method' ), 10, 0 ); |
|
31 | - add_action( 'admin_post_wps_update_method_payment_payment_in_shop', array( $this, 'update_method_payment_in_shop' ) ); |
|
30 | + add_action('wps_setting_payment_method_payment_in_shop', array($this, 'callback_setting_payment_method'), 10, 0); |
|
31 | + add_action('admin_post_wps_update_method_payment_payment_in_shop', array($this, 'update_method_payment_in_shop')); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | * @since 2.0.0 |
39 | 39 | */ |
40 | 40 | public function callback_setting_payment_method() { |
41 | - $payment_data = Payment::g()->get_payment_option( 'payment_in_shop' ); |
|
41 | + $payment_data = Payment::g()->get_payment_option('payment_in_shop'); |
|
42 | 42 | |
43 | - \eoxia\View_Util::exec( 'wpshop', 'settings', 'payment-method-single-form', array( |
|
43 | + \eoxia\View_Util::exec('wpshop', 'settings', 'payment-method-single-form', array( |
|
44 | 44 | 'payment_data' => $payment_data, |
45 | - ) ); |
|
45 | + )); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -53,25 +53,25 @@ discard block |
||
53 | 53 | * @since 2.0.0 |
54 | 54 | */ |
55 | 55 | public function update_method_payment_in_shop() { |
56 | - check_admin_referer( 'update_method_payment_in_shop' ); |
|
56 | + check_admin_referer('update_method_payment_in_shop'); |
|
57 | 57 | |
58 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
58 | + if (!current_user_can('manage_options')) { |
|
59 | 59 | wp_die(); |
60 | 60 | } |
61 | 61 | |
62 | - $title = ! empty( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : ''; |
|
63 | - $description = ! empty( $_POST['description'] ) ? stripslashes( $_POST['description'] ) : ''; |
|
62 | + $title = !empty($_POST['title']) ? sanitize_text_field($_POST['title']) : ''; |
|
63 | + $description = !empty($_POST['description']) ? stripslashes($_POST['description']) : ''; |
|
64 | 64 | |
65 | - $payment_methods_option = get_option( 'wps_payment_methods', Payment::g()->default_options ); |
|
65 | + $payment_methods_option = get_option('wps_payment_methods', Payment::g()->default_options); |
|
66 | 66 | |
67 | 67 | $payment_methods_option['payment_in_shop']['title'] = $title; |
68 | 68 | $payment_methods_option['payment_in_shop']['description'] = $description; |
69 | 69 | |
70 | - update_option( 'wps_payment_methods', $payment_methods_option ); |
|
70 | + update_option('wps_payment_methods', $payment_methods_option); |
|
71 | 71 | |
72 | - set_transient( 'updated_wpshop_option_' . get_current_user_id(), __( 'Your settings have been saved.', 'wpshop' ), 30 ); |
|
72 | + set_transient('updated_wpshop_option_' . get_current_user_id(), __('Your settings have been saved.', 'wpshop'), 30); |
|
73 | 73 | |
74 | - wp_redirect( admin_url( 'admin.php?page=wps-settings&tab=payment_method§ion=payment_in_shop' ) ); |
|
74 | + wp_redirect(admin_url('admin.php?page=wps-settings&tab=payment_method§ion=payment_in_shop')); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * API Action Class. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'rest_api_init', array( $this, 'callback_rest_api_init' ) ); |
|
30 | + add_action('rest_api_init', array($this, 'callback_rest_api_init')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | * @since 2.0.0 |
37 | 37 | */ |
38 | 38 | public function callback_rest_api_init() { |
39 | - register_rest_route( 'wpshop/v2', '/wps_gateway_paypal', array( |
|
40 | - 'methods' => array( 'GET', 'POST' ), |
|
41 | - 'callback' => array( $this, 'callback_wps_gateway_paypal' ), |
|
42 | - ) ); |
|
39 | + register_rest_route('wpshop/v2', '/wps_gateway_paypal', array( |
|
40 | + 'methods' => array('GET', 'POST'), |
|
41 | + 'callback' => array($this, 'callback_wps_gateway_paypal'), |
|
42 | + )); |
|
43 | 43 | |
44 | - register_rest_route( 'wpshop/v2', '/wps_gateway_stripe', array( |
|
45 | - 'methods' => array( 'GET', 'POST' ), |
|
46 | - 'callback' => array( $this, 'callback_wps_gateway_stripe' ), |
|
47 | - ) ); |
|
44 | + register_rest_route('wpshop/v2', '/wps_gateway_stripe', array( |
|
45 | + 'methods' => array('GET', 'POST'), |
|
46 | + 'callback' => array($this, 'callback_wps_gateway_stripe'), |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | * @param WP_Request $request L'objet contenant les informations de la |
56 | 56 | * requête. |
57 | 57 | */ |
58 | - public function callback_wps_gateway_paypal( $request ) { |
|
58 | + public function callback_wps_gateway_paypal($request) { |
|
59 | 59 | $data = $request->get_body_params(); |
60 | - $txn_id = get_post_meta( $data['custom'], 'payment_txn_id', true ); |
|
60 | + $txn_id = get_post_meta($data['custom'], 'payment_txn_id', true); |
|
61 | 61 | |
62 | - if ( $txn_id !== $data['txn_id'] ) { |
|
63 | - update_post_meta( $data['custom'], 'payment_data', $data ); |
|
64 | - update_post_meta( $data['custom'], 'payment_txn_id', $data['txn_id'] ); |
|
65 | - update_post_meta( $data['custom'], 'payment_method', 'paypal' ); |
|
62 | + if ($txn_id !== $data['txn_id']) { |
|
63 | + update_post_meta($data['custom'], 'payment_data', $data); |
|
64 | + update_post_meta($data['custom'], 'payment_txn_id', $data['txn_id']); |
|
65 | + update_post_meta($data['custom'], 'payment_method', 'paypal'); |
|
66 | 66 | |
67 | - do_action( 'wps_gateway_paypal', $data ); |
|
67 | + do_action('wps_gateway_paypal', $data); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,23 +76,23 @@ discard block |
||
76 | 76 | * @param WP_Request $request L'objet contenant les informations de la |
77 | 77 | * requête. |
78 | 78 | */ |
79 | - public function callback_wps_gateway_stripe( $request ) { |
|
80 | - $param = json_decode( $request->get_body(), true ); |
|
79 | + public function callback_wps_gateway_stripe($request) { |
|
80 | + $param = json_decode($request->get_body(), true); |
|
81 | 81 | |
82 | - $order = Doli_Order::g()->get( array( |
|
82 | + $order = Doli_Order::g()->get(array( |
|
83 | 83 | 'meta_key' => '_external_data', |
84 | 84 | 'meta_compare' => 'LIKE', |
85 | 85 | 'meta_value' => $param['data']['object']['id'], |
86 | - ), true ); |
|
86 | + ), true); |
|
87 | 87 | |
88 | - if ( ! empty( $order ) ) { |
|
89 | - update_post_meta( $order->data['id'], 'payment_data', $param ); |
|
90 | - update_post_meta( $order->data['id'], 'payment_txn_id', $param['data']['object']['id'] ); |
|
91 | - update_post_meta( $order->data['id'], 'payment_method', 'stripe' ); |
|
88 | + if (!empty($order)) { |
|
89 | + update_post_meta($order->data['id'], 'payment_data', $param); |
|
90 | + update_post_meta($order->data['id'], 'payment_txn_id', $param['data']['object']['id']); |
|
91 | + update_post_meta($order->data['id'], 'payment_method', 'stripe'); |
|
92 | 92 | |
93 | 93 | $param['custom'] = $order->data['id']; |
94 | 94 | |
95 | - do_action( 'wps_gateway_stripe', $param ); |
|
95 | + do_action('wps_gateway_stripe', $param); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Doli Invoice Action Class. |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'init', array( $this, 'create_tmp_invoice_dir' ) ); |
|
31 | - add_action( 'wps_payment_complete', array( $this, 'create_invoice' ), 20, 1 ); |
|
30 | + add_action('init', array($this, 'create_tmp_invoice_dir')); |
|
31 | + add_action('wps_payment_complete', array($this, 'create_invoice'), 20, 1); |
|
32 | 32 | |
33 | - add_action( 'admin_post_wps_download_invoice', array( $this, 'download_invoice' ) ); |
|
33 | + add_action('admin_post_wps_download_invoice', array($this, 'download_invoice')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | |
44 | 44 | $path = $dir['basedir'] . '/invoices'; |
45 | 45 | |
46 | - if ( wp_mkdir_p( $path ) && ! file_exists( $path . '/.htaccess' ) ) { |
|
47 | - $f = fopen( $path . '/.htaccess', 'a+' ); |
|
48 | - fwrite( $f, "Options -Indexes\r\ndeny from all" ); |
|
49 | - fclose( $f ); |
|
46 | + if (wp_mkdir_p($path) && !file_exists($path . '/.htaccess')) { |
|
47 | + $f = fopen($path . '/.htaccess', 'a+'); |
|
48 | + fwrite($f, "Options -Indexes\r\ndeny from all"); |
|
49 | + fclose($f); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -57,52 +57,52 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @param array $data Les données venant de PayPal. |
59 | 59 | */ |
60 | - public function create_invoice( $data ) { |
|
61 | - $order = Doli_Order::g()->get( array( 'id' => (int) $data['custom'] ), true ); |
|
60 | + public function create_invoice($data) { |
|
61 | + $order = Doli_Order::g()->get(array('id' => (int)$data['custom']), true); |
|
62 | 62 | |
63 | - $doli_invoice = Request_Util::post( 'invoices/createfromorder/' . $order->data['external_id'] ); |
|
64 | - $doli_invoice = Request_Util::post( 'invoices/' . $doli_invoice->id . '/validate', array( |
|
63 | + $doli_invoice = Request_Util::post('invoices/createfromorder/' . $order->data['external_id']); |
|
64 | + $doli_invoice = Request_Util::post('invoices/' . $doli_invoice->id . '/validate', array( |
|
65 | 65 | 'notrigger' => 0, |
66 | - ) ); |
|
67 | - $doli_invoice = Request_Util::post( 'invoices/' . $doli_invoice->id . '/settopaid' ); |
|
66 | + )); |
|
67 | + $doli_invoice = Request_Util::post('invoices/' . $doli_invoice->id . '/settopaid'); |
|
68 | 68 | |
69 | - Request_Util::put( 'documents/builddoc', array( |
|
69 | + Request_Util::put('documents/builddoc', array( |
|
70 | 70 | 'module_part' => 'invoice', |
71 | 71 | 'original_file' => $doli_invoice->ref . '/' . $doli_invoice->ref . '.pdf', |
72 | 72 | 'doc_template' => 'crabe', |
73 | 73 | 'langcode' => 'fr_FR', |
74 | - ) ); |
|
74 | + )); |
|
75 | 75 | |
76 | - $wp_invoice = Doli_Invoice::g()->get( array( 'schema' => true ), true ); |
|
77 | - $wp_invoice = Doli_Invoice::g()->doli_to_wp( $doli_invoice, $wp_invoice ); |
|
76 | + $wp_invoice = Doli_Invoice::g()->get(array('schema' => true), true); |
|
77 | + $wp_invoice = Doli_Invoice::g()->doli_to_wp($doli_invoice, $wp_invoice); |
|
78 | 78 | |
79 | 79 | $wp_invoice->data['author_id'] = $order->data['author_id']; |
80 | 80 | |
81 | - Doli_Invoice::g()->update( $wp_invoice->data ); |
|
81 | + Doli_Invoice::g()->update($wp_invoice->data); |
|
82 | 82 | |
83 | - $third_party = Third_Party::g()->get( array( 'id' => $order->data['parent_id'] ), true ); |
|
84 | - $contact = Contact::g()->get( array( 'id' => $wp_invoice->data['author_id'] ), true ); |
|
83 | + $third_party = Third_Party::g()->get(array('id' => $order->data['parent_id']), true); |
|
84 | + $contact = Contact::g()->get(array('id' => $wp_invoice->data['author_id']), true); |
|
85 | 85 | |
86 | - $invoice_file = Request_Util::get( 'documents/download?module_part=facture&original_file=' . $wp_invoice->data['title'] . '/' . $wp_invoice->data['title'] . '.pdf' ); |
|
87 | - $content = base64_decode( $invoice_file->content ); |
|
86 | + $invoice_file = Request_Util::get('documents/download?module_part=facture&original_file=' . $wp_invoice->data['title'] . '/' . $wp_invoice->data['title'] . '.pdf'); |
|
87 | + $content = base64_decode($invoice_file->content); |
|
88 | 88 | |
89 | 89 | $dir = wp_upload_dir(); |
90 | 90 | $path = $dir['basedir'] . '/invoices'; |
91 | 91 | $path_file = $path . '/' . $wp_invoice->data['title'] . '.pdf'; |
92 | 92 | |
93 | - $f = fopen( $path . '/' . $wp_invoice->data['title'] . '.pdf', 'a+' ); |
|
94 | - fwrite( $f, $content ); |
|
95 | - fclose( $f ); |
|
93 | + $f = fopen($path . '/' . $wp_invoice->data['title'] . '.pdf', 'a+'); |
|
94 | + fwrite($f, $content); |
|
95 | + fclose($f); |
|
96 | 96 | |
97 | - Emails::g()->send_mail( $contact->data['email'], 'wps_email_customer_invoice', array( |
|
97 | + Emails::g()->send_mail($contact->data['email'], 'wps_email_customer_invoice', array( |
|
98 | 98 | 'order' => $order, |
99 | 99 | 'invoice' => $wp_invoice, |
100 | 100 | 'third_party' => $third_party, |
101 | 101 | 'contact' => $contact, |
102 | - 'attachments' => array( $path_file ), |
|
103 | - ) ); |
|
102 | + 'attachments' => array($path_file), |
|
103 | + )); |
|
104 | 104 | |
105 | - unlink( $path_file ); |
|
105 | + unlink($path_file); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * @since 2.0.0 |
112 | 112 | */ |
113 | 113 | public function download_invoice() { |
114 | - check_admin_referer( 'download_invoice' ); |
|
114 | + check_admin_referer('download_invoice'); |
|
115 | 115 | |
116 | - $order_id = ! empty( $_GET['order_id'] ) ? (int) $_GET['order_id'] : 0; |
|
116 | + $order_id = !empty($_GET['order_id']) ? (int)$_GET['order_id'] : 0; |
|
117 | 117 | |
118 | - if ( ! $order_id ) { |
|
118 | + if (!$order_id) { |
|
119 | 119 | exit; |
120 | 120 | } |
121 | 121 | |
122 | - $contact = Contact::g()->get( array( 'id' => get_current_user_id() ), true ); |
|
123 | - $third_party = Third_Party::g()->get( array( 'id' => $contact->data['third_party_id'] ), true ); |
|
124 | - $order = Doli_Order::g()->get( array( 'id' => $order_id ), true ); |
|
125 | - $invoice = Doli_Invoice::g()->get( array( 'post_parent' => $order_id ), true ); |
|
122 | + $contact = Contact::g()->get(array('id' => get_current_user_id()), true); |
|
123 | + $third_party = Third_Party::g()->get(array('id' => $contact->data['third_party_id']), true); |
|
124 | + $order = Doli_Order::g()->get(array('id' => $order_id), true); |
|
125 | + $invoice = Doli_Invoice::g()->get(array('post_parent' => $order_id), true); |
|
126 | 126 | |
127 | - if ( ( isset( $third_party->data ) && $order->data['parent_id'] != $third_party->data['id'] ) && ! current_user_can( 'administrator' ) ) { |
|
127 | + if ((isset($third_party->data) && $order->data['parent_id'] != $third_party->data['id']) && !current_user_can('administrator')) { |
|
128 | 128 | exit; |
129 | 129 | } |
130 | 130 | |
131 | - $invoice_file = Request_Util::get( 'documents/download?module_part=facture&original_file=' . $invoice->data['title'] . '/' . $invoice->data['title'] . '.pdf' ); |
|
131 | + $invoice_file = Request_Util::get('documents/download?module_part=facture&original_file=' . $invoice->data['title'] . '/' . $invoice->data['title'] . '.pdf'); |
|
132 | 132 | |
133 | - $content = base64_decode( $invoice_file->content ); |
|
133 | + $content = base64_decode($invoice_file->content); |
|
134 | 134 | |
135 | - header( 'Cache-Control: no-cache' ); |
|
136 | - header( 'Content-Type: application/pdf' ); |
|
137 | - header( 'Content-Disposition: inline; filename="' . $invoice->data['title'] . '.pdf"' ); |
|
138 | - header( 'Content-Length: ' . strlen( $content ) ); |
|
135 | + header('Cache-Control: no-cache'); |
|
136 | + header('Content-Type: application/pdf'); |
|
137 | + header('Content-Disposition: inline; filename="' . $invoice->data['title'] . '.pdf"'); |
|
138 | + header('Content-Length: ' . strlen($content)); |
|
139 | 139 | |
140 | 140 | echo $content; |
141 | 141 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Cart Shortcode Class. |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @since 2.0.0 |
36 | 36 | */ |
37 | 37 | public function callback_init() { |
38 | - add_shortcode( 'wps_cart', array( $this, 'callback_cart' ) ); |
|
38 | + add_shortcode('wps_cart', array($this, 'callback_cart')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | public function callback_cart() { |
47 | 47 | $cart_contents = Cart_Session::g()->cart_contents; |
48 | 48 | |
49 | - $shipping_cost_option = get_option( 'wps_shipping_cost', Settings::g()->shipping_cost_default_settings ); |
|
49 | + $shipping_cost_option = get_option('wps_shipping_cost', Settings::g()->shipping_cost_default_settings); |
|
50 | 50 | |
51 | - if ( ! empty( $cart_contents ) ) { |
|
52 | - include( Template_Util::get_template_part( 'cart', 'cart' ) ); |
|
51 | + if (!empty($cart_contents)) { |
|
52 | + include(Template_Util::get_template_part('cart', 'cart')); |
|
53 | 53 | } else { |
54 | - include( Template_Util::get_template_part( 'cart', 'empty-cart' ) ); |
|
54 | + include(Template_Util::get_template_part('cart', 'empty-cart')); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Cart Class. |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param Product_Model $product Les données du produit. |
37 | 37 | */ |
38 | - public function add_to_cart( $product ) { |
|
38 | + public function add_to_cart($product) { |
|
39 | 39 | $data = array_merge( |
40 | - array( 'qty' => 1 ), |
|
40 | + array('qty' => 1), |
|
41 | 41 | $product->data |
42 | 42 | ); |
43 | 43 | |
44 | 44 | $index = -1; |
45 | 45 | |
46 | - if ( ! empty( Cart_Session::g()->cart_contents ) ) { |
|
47 | - foreach ( Cart_Session::g()->cart_contents as $key => $line ) { |
|
48 | - if ( $line['id'] == $product->data['id'] ) { |
|
46 | + if (!empty(Cart_Session::g()->cart_contents)) { |
|
47 | + foreach (Cart_Session::g()->cart_contents as $key => $line) { |
|
48 | + if ($line['id'] == $product->data['id']) { |
|
49 | 49 | $data['qty'] = $line['qty'] + 1; |
50 | 50 | $index = $key; |
51 | 51 | break; |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | if ( -1 === $index ) { |
57 | - Cart_Session::g()->add_product( $data ); |
|
57 | + Cart_Session::g()->add_product($data); |
|
58 | 58 | } else { |
59 | - Cart_Session::g()->update_product( $index, $data ); |
|
59 | + Cart_Session::g()->update_product($index, $data); |
|
60 | 60 | } |
61 | 61 | |
62 | - do_action( 'wps_add_to_cart' ); |
|
63 | - do_action( 'wps_before_calculate_totals' ); |
|
64 | - do_action( 'wps_calculate_totals' ); |
|
65 | - do_action( 'wps_after_calculate_totals' ); |
|
62 | + do_action('wps_add_to_cart'); |
|
63 | + do_action('wps_before_calculate_totals'); |
|
64 | + do_action('wps_calculate_totals'); |
|
65 | + do_action('wps_after_calculate_totals'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param Product_Model $product Les données du produit. |
74 | 74 | */ |
75 | - public function update_cart( $product ) { |
|
76 | - if ( ! empty( Cart_Session::g()->cart_contents ) ) { |
|
77 | - foreach ( Cart_Session::g()->cart_contents as $key => $line ) { |
|
78 | - if ( $line['id'] == $product['id'] ) { |
|
75 | + public function update_cart($product) { |
|
76 | + if (!empty(Cart_Session::g()->cart_contents)) { |
|
77 | + foreach (Cart_Session::g()->cart_contents as $key => $line) { |
|
78 | + if ($line['id'] == $product['id']) { |
|
79 | 79 | $line['qty'] = $product['qty']; |
80 | - Cart_Session::g()->update_product( $key, $line ); |
|
80 | + Cart_Session::g()->update_product($key, $line); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'wps_update_cart' ); |
|
86 | - do_action( 'wps_before_calculate_totals' ); |
|
87 | - do_action( 'wps_calculate_totals' ); |
|
88 | - do_action( 'wps_after_calculate_totals' ); |
|
85 | + do_action('wps_update_cart'); |
|
86 | + do_action('wps_before_calculate_totals'); |
|
87 | + do_action('wps_calculate_totals'); |
|
88 | + do_action('wps_after_calculate_totals'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param integer $key La clé du produit dans le tableau. |
97 | 97 | */ |
98 | - public function delete_product( $key ) { |
|
99 | - Cart_Session::g()->remove_product_by_key( $key ); |
|
98 | + public function delete_product($key) { |
|
99 | + Cart_Session::g()->remove_product_by_key($key); |
|
100 | 100 | |
101 | - do_action( 'wps_delete_to_cart', $key ); |
|
102 | - do_action( 'wps_before_calculate_totals' ); |
|
103 | - do_action( 'wps_calculate_totals' ); |
|
104 | - do_action( 'wps_after_calculate_totals' ); |
|
101 | + do_action('wps_delete_to_cart', $key); |
|
102 | + do_action('wps_before_calculate_totals'); |
|
103 | + do_action('wps_calculate_totals'); |
|
104 | + do_action('wps_after_calculate_totals'); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Cart Session Class. |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * @since 2.0.0 |
89 | 89 | */ |
90 | 90 | protected function construct() { |
91 | - $this->cart_contents = isset( $_SESSION['wps_cart'] ) ? $_SESSION['wps_cart'] : array(); |
|
92 | - $this->total_price = isset( $_SESSION['wps_total_price'] ) ? $_SESSION['wps_total_price'] : null; |
|
93 | - $this->total_price_no_shipping = isset( $_SESSION['wps_total_price_no_shipping'] ) ? $_SESSION['wps_total_price_no_shipping'] : null; |
|
94 | - $this->total_price_ttc = isset( $_SESSION['wps_total_price_ttc'] ) ? $_SESSION['wps_total_price_ttc'] : null; |
|
95 | - $this->proposal_id = isset( $_SESSION['wps_proposal_id'] ) ? $_SESSION['wps_proposal_id'] : null; |
|
96 | - $this->order_id = isset( $_SESSION['wps_order_id'] ) ? $_SESSION['wps_order_id'] : null; |
|
97 | - $this->external_data = isset( $_SESSION['wps_external_data'] ) ? $_SESSION['wps_external_data'] : array(); |
|
91 | + $this->cart_contents = isset($_SESSION['wps_cart']) ? $_SESSION['wps_cart'] : array(); |
|
92 | + $this->total_price = isset($_SESSION['wps_total_price']) ? $_SESSION['wps_total_price'] : null; |
|
93 | + $this->total_price_no_shipping = isset($_SESSION['wps_total_price_no_shipping']) ? $_SESSION['wps_total_price_no_shipping'] : null; |
|
94 | + $this->total_price_ttc = isset($_SESSION['wps_total_price_ttc']) ? $_SESSION['wps_total_price_ttc'] : null; |
|
95 | + $this->proposal_id = isset($_SESSION['wps_proposal_id']) ? $_SESSION['wps_proposal_id'] : null; |
|
96 | + $this->order_id = isset($_SESSION['wps_order_id']) ? $_SESSION['wps_order_id'] : null; |
|
97 | + $this->external_data = isset($_SESSION['wps_external_data']) ? $_SESSION['wps_external_data'] : array(); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param string $property Le nom. |
106 | 106 | * @param mixed $value La valeur. |
107 | 107 | */ |
108 | - public function add_external_data( $property, $value ) { |
|
109 | - $this->external_data[ $property ] = $value; |
|
108 | + public function add_external_data($property, $value) { |
|
109 | + $this->external_data[$property] = $value; |
|
110 | 110 | $this->update_session(); |
111 | 111 | } |
112 | 112 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @since 2.0.0 |
132 | 132 | */ |
133 | 133 | public function destroy() { |
134 | - unset( $_SESSION['wps_cart'] ); |
|
135 | - unset( $_SESSION['wps_total_price'] ); |
|
136 | - unset( $_SESSION['wps_total_price_no_shipping'] ); |
|
137 | - unset( $_SESSION['wps_total_price_ttc'] ); |
|
138 | - unset( $_SESSION['wps_proposal_id'] ); |
|
139 | - unset( $_SESSION['wps_order_id'] ); |
|
140 | - unset( $_SESSION['wps_external_data'] ); |
|
134 | + unset($_SESSION['wps_cart']); |
|
135 | + unset($_SESSION['wps_total_price']); |
|
136 | + unset($_SESSION['wps_total_price_no_shipping']); |
|
137 | + unset($_SESSION['wps_total_price_ttc']); |
|
138 | + unset($_SESSION['wps_proposal_id']); |
|
139 | + unset($_SESSION['wps_order_id']); |
|
140 | + unset($_SESSION['wps_external_data']); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param Product $data Les données du produit. |
149 | 149 | */ |
150 | - public function add_product( $data ) { |
|
150 | + public function add_product($data) { |
|
151 | 151 | $this->cart_contents[] = $data; |
152 | 152 | $this->update_session(); |
153 | 153 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param integer $index L'index du produit dans le tableau cart_contents. |
162 | 162 | * @param Product $data Les données du produit. |
163 | 163 | */ |
164 | - public function update_product( $index, $data ) { |
|
165 | - $this->cart_contents[ $index ] = $data; |
|
164 | + public function update_product($index, $data) { |
|
165 | + $this->cart_contents[$index] = $data; |
|
166 | 166 | $this->update_session(); |
167 | 167 | } |
168 | 168 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param string $property Le nom de la propriété. |
175 | 175 | * @param mixed $value La valeur de la propriété. |
176 | 176 | */ |
177 | - public function update( $property, $value ) { |
|
177 | + public function update($property, $value) { |
|
178 | 178 | $this->$property = $value; |
179 | 179 | $this->update_session(); |
180 | 180 | } |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return boolean True si trouvé. Sinon false. |
190 | 190 | */ |
191 | - public function has_product( $id ) { |
|
192 | - if ( ! empty( $this->cart_contents ) ) { |
|
193 | - foreach ( $this->cart_contents as $cart_content ) { |
|
194 | - if ( $cart_content['id'] === $id ) { |
|
191 | + public function has_product($id) { |
|
192 | + if (!empty($this->cart_contents)) { |
|
193 | + foreach ($this->cart_contents as $cart_content) { |
|
194 | + if ($cart_content['id'] === $id) { |
|
195 | 195 | return true; |
196 | 196 | } |
197 | 197 | } |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param integer $id L'ID du produit. |
209 | 209 | */ |
210 | - public function remove_product( $id ) { |
|
211 | - if ( ! empty( $this->cart_contents ) ) { |
|
212 | - foreach ( $this->cart_contents as $key => $cart_content ) { |
|
213 | - if ( $cart_content['id'] === $id ) { |
|
214 | - array_splice( $this->cart_contents, $key, 1 ); |
|
210 | + public function remove_product($id) { |
|
211 | + if (!empty($this->cart_contents)) { |
|
212 | + foreach ($this->cart_contents as $key => $cart_content) { |
|
213 | + if ($cart_content['id'] === $id) { |
|
214 | + array_splice($this->cart_contents, $key, 1); |
|
215 | 215 | break; |
216 | 216 | } |
217 | 217 | } |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @param integer $key L'index dans le tableau cart_contents. |
230 | 230 | */ |
231 | - public function remove_product_by_key( $key ) { |
|
232 | - array_splice( $this->cart_contents, $key, 1 ); |
|
231 | + public function remove_product_by_key($key) { |
|
232 | + array_splice($this->cart_contents, $key, 1); |
|
233 | 233 | |
234 | 234 | $this->update_session(); |
235 | 235 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Cart Action Class. |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | |
31 | - add_action( 'init', array( Cart_Shortcode::g(), 'callback_init' ), 5 ); |
|
31 | + add_action('init', array(Cart_Shortcode::g(), 'callback_init'), 5); |
|
32 | 32 | |
33 | - add_action( 'wps_calculate_totals', array( $this, 'callback_calculate_totals' ) ); |
|
33 | + add_action('wps_calculate_totals', array($this, 'callback_calculate_totals')); |
|
34 | 34 | |
35 | - add_action( 'wp_ajax_nopriv_add_to_cart', array( $this, 'ajax_add_to_cart' ) ); |
|
36 | - add_action( 'wp_ajax_add_to_cart', array( $this, 'ajax_add_to_cart' ) ); |
|
35 | + add_action('wp_ajax_nopriv_add_to_cart', array($this, 'ajax_add_to_cart')); |
|
36 | + add_action('wp_ajax_add_to_cart', array($this, 'ajax_add_to_cart')); |
|
37 | 37 | |
38 | - add_action( 'wp_ajax_nopriv_wps_update_cart', array( $this, 'ajax_update_cart' ) ); |
|
39 | - add_action( 'wp_ajax_wps_update_cart', array( $this, 'ajax_update_cart' ) ); |
|
38 | + add_action('wp_ajax_nopriv_wps_update_cart', array($this, 'ajax_update_cart')); |
|
39 | + add_action('wp_ajax_wps_update_cart', array($this, 'ajax_update_cart')); |
|
40 | 40 | |
41 | - add_action( 'wp_ajax_nopriv_delete_product_from_cart', array( $this, 'ajax_delete_product_from_cart' ) ); |
|
42 | - add_action( 'wp_ajax_delete_product_from_cart', array( $this, 'ajax_delete_product_from_cart' ) ); |
|
41 | + add_action('wp_ajax_nopriv_delete_product_from_cart', array($this, 'ajax_delete_product_from_cart')); |
|
42 | + add_action('wp_ajax_delete_product_from_cart', array($this, 'ajax_delete_product_from_cart')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -48,26 +48,26 @@ discard block |
||
48 | 48 | * @since 2.0.0 |
49 | 49 | */ |
50 | 50 | public function callback_calculate_totals() { |
51 | - $shipping_cost_option = get_option( 'wps_shipping_cost', Settings::g()->shipping_cost_default_settings ); |
|
51 | + $shipping_cost_option = get_option('wps_shipping_cost', Settings::g()->shipping_cost_default_settings); |
|
52 | 52 | |
53 | 53 | $price = 0; |
54 | 54 | $price_no_shipping = 0; |
55 | 55 | $price_ttc = 0; |
56 | 56 | |
57 | - if ( ! empty( Cart_Session::g()->cart_contents ) ) { |
|
58 | - foreach ( Cart_Session::g()->cart_contents as $key => $line ) { |
|
57 | + if (!empty(Cart_Session::g()->cart_contents)) { |
|
58 | + foreach (Cart_Session::g()->cart_contents as $key => $line) { |
|
59 | 59 | $price += $line['price'] * $line['qty']; |
60 | 60 | $price_ttc += $line['price_ttc'] * $line['qty']; |
61 | 61 | |
62 | - if ( $shipping_cost_option['shipping_product_id'] != $line['id'] ) { |
|
62 | + if ($shipping_cost_option['shipping_product_id'] != $line['id']) { |
|
63 | 63 | $price_no_shipping += $line['price'] * $line['qty']; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - Cart_Session::g()->update( 'total_price', $price ); |
|
69 | - Cart_Session::g()->update( 'total_price_no_shipping', $price_no_shipping ); |
|
70 | - Cart_Session::g()->update( 'total_price_ttc', $price_ttc ); |
|
68 | + Cart_Session::g()->update('total_price', $price); |
|
69 | + Cart_Session::g()->update('total_price_no_shipping', $price_no_shipping); |
|
70 | + Cart_Session::g()->update('total_price_ttc', $price_ttc); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,26 +76,26 @@ discard block |
||
76 | 76 | * @since 2.0.0 |
77 | 77 | */ |
78 | 78 | public function ajax_add_to_cart() { |
79 | - check_ajax_referer( 'add_to_cart' ); |
|
79 | + check_ajax_referer('add_to_cart'); |
|
80 | 80 | |
81 | - $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
81 | + $id = !empty($_POST['id']) ? (int)$_POST['id'] : 0; |
|
82 | 82 | |
83 | - if ( empty( $id ) ) { |
|
83 | + if (empty($id)) { |
|
84 | 84 | wp_send_json_error(); |
85 | 85 | } |
86 | 86 | |
87 | - $product = Product::g()->get( array( 'id' => $id ), true ); |
|
87 | + $product = Product::g()->get(array('id' => $id), true); |
|
88 | 88 | |
89 | - Cart::g()->add_to_cart( $product ); |
|
89 | + Cart::g()->add_to_cart($product); |
|
90 | 90 | |
91 | 91 | ob_start(); |
92 | - include( Template_Util::get_template_part( 'cart', 'link-cart' ) ); |
|
93 | - wp_send_json_success( array( |
|
92 | + include(Template_Util::get_template_part('cart', 'link-cart')); |
|
93 | + wp_send_json_success(array( |
|
94 | 94 | 'namespace' => 'wpshopFrontend', |
95 | 95 | 'module' => 'cart', |
96 | 96 | 'callback_success' => 'addedToCart', |
97 | 97 | 'view' => ob_get_clean(), |
98 | - ) ); |
|
98 | + )); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,36 +104,36 @@ discard block |
||
104 | 104 | * @since 2.0.0 |
105 | 105 | */ |
106 | 106 | public function ajax_update_cart() { |
107 | - check_ajax_referer( 'ajax_update_cart' ); |
|
107 | + check_ajax_referer('ajax_update_cart'); |
|
108 | 108 | |
109 | - $products = ! empty( $_POST['products'] ) ? (array) $_POST['products'] : array(); |
|
109 | + $products = !empty($_POST['products']) ? (array)$_POST['products'] : array(); |
|
110 | 110 | |
111 | - if ( empty( $products ) ) { |
|
111 | + if (empty($products)) { |
|
112 | 112 | wp_send_json_error(); |
113 | 113 | } |
114 | 114 | |
115 | - if ( ! empty( $products ) ) { |
|
116 | - foreach ( $products as $key => $product ) { |
|
117 | - if ( isset ( $product['qty'] ) ) { |
|
118 | - $product['qty'] = (int) $product['qty']; |
|
115 | + if (!empty($products)) { |
|
116 | + foreach ($products as $key => $product) { |
|
117 | + if (isset ($product['qty'])) { |
|
118 | + $product['qty'] = (int)$product['qty']; |
|
119 | 119 | |
120 | - if ( $product['qty'] <= 0 ) { |
|
121 | - Cart::g()->delete_product( $key ); |
|
120 | + if ($product['qty'] <= 0) { |
|
121 | + Cart::g()->delete_product($key); |
|
122 | 122 | } else { |
123 | - Cart::g()->update_cart( $product ); |
|
123 | + Cart::g()->update_cart($product); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | ob_start(); |
130 | - echo do_shortcode( '[wps_cart]' ); |
|
131 | - wp_send_json_success( array( |
|
130 | + echo do_shortcode('[wps_cart]'); |
|
131 | + wp_send_json_success(array( |
|
132 | 132 | 'namespace' => 'wpshopFrontend', |
133 | 133 | 'module' => 'cart', |
134 | 134 | 'callback_success' => 'updatedCart', |
135 | 135 | 'view' => ob_get_clean(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,22 +142,22 @@ discard block |
||
142 | 142 | * @since 2.0.0 |
143 | 143 | */ |
144 | 144 | public function ajax_delete_product_from_cart() { |
145 | - check_ajax_referer( 'ajax_delete_product_from_cart' ); |
|
145 | + check_ajax_referer('ajax_delete_product_from_cart'); |
|
146 | 146 | |
147 | - $key = isset( $_POST['key'] ) ? (int) $_POST['key'] : -1; |
|
147 | + $key = isset($_POST['key']) ? (int)$_POST['key'] : -1; |
|
148 | 148 | |
149 | 149 | if ( -1 != $key ) { |
150 | - Cart::g()->delete_product( $key ); |
|
150 | + Cart::g()->delete_product($key); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | ob_start(); |
154 | - echo do_shortcode( '[wps_cart]' ); |
|
155 | - wp_send_json_success( array( |
|
154 | + echo do_shortcode('[wps_cart]'); |
|
155 | + wp_send_json_success(array( |
|
156 | 156 | 'namespace' => 'wpshopFrontend', |
157 | 157 | 'module' => 'cart', |
158 | 158 | 'callback_success' => 'deletedProdutFromCart', |
159 | 159 | 'view' => ob_get_clean(), |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 |