@@ -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 | * Orders Model Class. |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param Order $object Les données de l'objet. |
30 | 30 | * @param string $req_method La méthode de la requête. |
31 | 31 | */ |
32 | - public function __construct( $object, $req_method = null ) { |
|
32 | + public function __construct($object, $req_method = null) { |
|
33 | 33 | |
34 | 34 | $this->schema['external_id'] = array( |
35 | 35 | 'type' => 'integer', |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'field' => 'datec', |
54 | 54 | 'since' => '2.0.0', |
55 | 55 | 'description' => 'Date de création de la commande. Relation avec dolibarr', |
56 | - 'context' => array( 'GET' ), |
|
56 | + 'context' => array('GET'), |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | $this->schema['date_commande'] = array( |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'field' => 'date_commande', |
63 | 63 | 'since' => '2.0.0', |
64 | 64 | 'description' => 'Date de la commande. Relation avec dolibarr', |
65 | - 'context' => array( 'GET' ), |
|
65 | + 'context' => array('GET'), |
|
66 | 66 | ); |
67 | 67 | |
68 | 68 | $this->schema['total_ht'] = array( |
@@ -117,6 +117,6 @@ discard block |
||
117 | 117 | 'default' => array(), |
118 | 118 | ); |
119 | 119 | |
120 | - parent::__construct( $object, $req_method ); |
|
120 | + parent::__construct($object, $req_method); |
|
121 | 121 | } |
122 | 122 | } |
@@ -14,42 +14,42 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<h3><?php esc_html_e( 'Payment', 'wpshop' ); ?></h3> |
|
20 | -<p><strong><?php esc_html_e( 'Payment by', 'wpshop' ); ?></strong> : <?php echo empty( $order->data['payment_method'] ) ? 'N/D' : Payment::g()->get_payment_title( $order->data['payment_method'] ); ?></p> |
|
19 | +<h3><?php esc_html_e('Payment', 'wpshop'); ?></h3> |
|
20 | +<p><strong><?php esc_html_e('Payment by', 'wpshop'); ?></strong> : <?php echo empty($order->data['payment_method']) ? 'N/D' : Payment::g()->get_payment_title($order->data['payment_method']); ?></p> |
|
21 | 21 | <p> |
22 | - <strong><?php esc_html_e( 'Payment status', 'wpshop' ); ?></strong> : |
|
22 | + <strong><?php esc_html_e('Payment status', 'wpshop'); ?></strong> : |
|
23 | 23 | <span> |
24 | 24 | <?php |
25 | - echo esc_html( Payment::g()->convert_status( $order->data ) ); |
|
26 | - if ( ! empty( $link_invoice ) ) : |
|
25 | + echo esc_html(Payment::g()->convert_status($order->data)); |
|
26 | + if (!empty($link_invoice)) : |
|
27 | 27 | ?> |
28 | - - <a href="<?php echo esc_url( $link_invoice ); ?>" target="_blank"><?php esc_html_e( 'View invoice', 'wpshop' ); ?></a> |
|
28 | + - <a href="<?php echo esc_url($link_invoice); ?>" target="_blank"><?php esc_html_e('View invoice', 'wpshop'); ?></a> |
|
29 | 29 | <?php |
30 | 30 | endif; |
31 | 31 | ?> |
32 | 32 | </span> |
33 | 33 | </p> |
34 | 34 | |
35 | -<h3><?php esc_html_e( 'Customer address', 'wpshop' ); ?></h3> |
|
35 | +<h3><?php esc_html_e('Customer address', 'wpshop'); ?></h3> |
|
36 | 36 | |
37 | 37 | <div class="wpeo-gridlayout grid-3"> |
38 | 38 | <div> |
39 | 39 | <ul> |
40 | - <li><strong><?php esc_html_e( 'Customer', 'wpshop' ); ?></strong> : <a href="<?php echo admin_url( 'admin.php?page=wps-third-party&id=' . $third_party->data['id'] ); ?>" target="_blank"><?php echo $third_party->data['title']; ?></a></li> |
|
40 | + <li><strong><?php esc_html_e('Customer', 'wpshop'); ?></strong> : <a href="<?php echo admin_url('admin.php?page=wps-third-party&id=' . $third_party->data['id']); ?>" target="_blank"><?php echo $third_party->data['title']; ?></a></li> |
|
41 | 41 | <?php |
42 | - if ( ! empty( $invoice->data['payments'] ) ) : |
|
42 | + if (!empty($invoice->data['payments'])) : |
|
43 | 43 | ?> |
44 | 44 | <li> |
45 | 45 | <?php |
46 | - foreach ( $invoice->data['payments'] as $payment ) : |
|
46 | + foreach ($invoice->data['payments'] as $payment) : |
|
47 | 47 | ?> |
48 | 48 | <ul> |
49 | - <li><?php esc_html_e( 'Payment method', 'wpshop' ); ?> : <?php echo esc_html( $payment->data['payment_type'] ); ?></li> |
|
50 | - <li><?php esc_html_e( 'Payment date', 'wpshop' ); ?> : <?php echo esc_html( $payment->data['date']['rendered']['date_human_readable'] ); ?></li> |
|
51 | - <li><?php esc_html_e( 'Payment reference', 'wpshop' ); ?> : <?php echo esc_html( $payment->data['title'] ); ?></li> |
|
52 | - <li><?php esc_html_e( 'Amount', 'wpshop' ); ?> : <?php echo esc_html( $payment->data['amount'] ); ?>€</li> |
|
49 | + <li><?php esc_html_e('Payment method', 'wpshop'); ?> : <?php echo esc_html($payment->data['payment_type']); ?></li> |
|
50 | + <li><?php esc_html_e('Payment date', 'wpshop'); ?> : <?php echo esc_html($payment->data['date']['rendered']['date_human_readable']); ?></li> |
|
51 | + <li><?php esc_html_e('Payment reference', 'wpshop'); ?> : <?php echo esc_html($payment->data['title']); ?></li> |
|
52 | + <li><?php esc_html_e('Amount', 'wpshop'); ?> : <?php echo esc_html($payment->data['amount']); ?>€</li> |
|
53 | 53 | </ul> |
54 | 54 | <?php |
55 | 55 | endforeach; |
@@ -60,25 +60,25 @@ discard block |
||
60 | 60 | ?> |
61 | 61 | </div> |
62 | 62 | <div> |
63 | - <strong><?php esc_html_e( 'Billing', 'wpshop' ); ?></strong> |
|
63 | + <strong><?php esc_html_e('Billing', 'wpshop'); ?></strong> |
|
64 | 64 | |
65 | 65 | <ul> |
66 | - <li><?php esc_html_e( 'No billing address', 'wpshop' ); ?></li> |
|
66 | + <li><?php esc_html_e('No billing address', 'wpshop'); ?></li> |
|
67 | 67 | </ul> |
68 | 68 | </div> |
69 | 69 | <div> |
70 | - <strong><?php esc_html_e( 'Shipment', 'wpshop' ); ?></strong> |
|
70 | + <strong><?php esc_html_e('Shipment', 'wpshop'); ?></strong> |
|
71 | 71 | |
72 | 72 | <ul> |
73 | - <li><?php echo ! empty( $third_party->data['title'] ) ? $third_party->data['title'] : 'N/D'; ?></li> |
|
74 | - <li><?php echo ! empty( $third_party->data['address'] ) ? $third_party->data['address'] : 'N/D'; ?></li> |
|
73 | + <li><?php echo !empty($third_party->data['title']) ? $third_party->data['title'] : 'N/D'; ?></li> |
|
74 | + <li><?php echo !empty($third_party->data['address']) ? $third_party->data['address'] : 'N/D'; ?></li> |
|
75 | 75 | <li> |
76 | - <?php echo ! empty( $third_party->data['zip'] ) ? $third_party->data['zip'] : 'N/D'; ?> |
|
77 | - <?php echo ! empty( $third_party->data['town'] ) ? $third_party->data['town'] : 'N/D'; ?> |
|
76 | + <?php echo !empty($third_party->data['zip']) ? $third_party->data['zip'] : 'N/D'; ?> |
|
77 | + <?php echo !empty($third_party->data['town']) ? $third_party->data['town'] : 'N/D'; ?> |
|
78 | 78 | </li> |
79 | 79 | <li> |
80 | - <strong><?php esc_html_e( 'Phone number', 'wpshop' ); ?> :</strong> |
|
81 | - <p><?php echo ! empty( $third_party->data['phone'] ) ? $third_party->data['phone'] : 'N/D'; ?></p> |
|
80 | + <strong><?php esc_html_e('Phone number', 'wpshop'); ?> :</strong> |
|
81 | + <p><?php echo !empty($third_party->data['phone']) ? $third_party->data['phone'] : 'N/D'; ?></p> |
|
82 | 82 | </li> |
83 | 83 | </ul> |
84 | 84 | </div> |
@@ -14,25 +14,25 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <div class="wps-list-product wpeo-table table-flex table-7"> |
20 | 20 | <div class="table-row table-header"> |
21 | 21 | <div class="table-cell table-25"><input type="checkbox" class="check-all"/></div> |
22 | - <div class="table-cell table-full"><?php esc_html_e( 'Order reference', 'wpshop' ); ?></div> |
|
23 | - <div class="table-cell table-200"><?php esc_html_e( 'Billing', 'wpshop' ); ?></div> |
|
24 | - <div class="table-cell table-150"><?php esc_html_e( 'Status', 'wpshop' ); ?></div> |
|
25 | - <div class="table-cell table-100"><?php esc_html_e( 'Method of payment', 'wpshop' ); ?>%</div> |
|
26 | - <div class="table-cell table-100"><?php esc_html_e( 'Price TTC(€)', 'wpshop' ); ?></div> |
|
27 | - <div class="table-cell table-100"><?php esc_html_e( 'Synchro', 'wpshop' ); ?></div> |
|
22 | + <div class="table-cell table-full"><?php esc_html_e('Order reference', 'wpshop'); ?></div> |
|
23 | + <div class="table-cell table-200"><?php esc_html_e('Billing', 'wpshop'); ?></div> |
|
24 | + <div class="table-cell table-150"><?php esc_html_e('Status', 'wpshop'); ?></div> |
|
25 | + <div class="table-cell table-100"><?php esc_html_e('Method of payment', 'wpshop'); ?>%</div> |
|
26 | + <div class="table-cell table-100"><?php esc_html_e('Price TTC(€)', 'wpshop'); ?></div> |
|
27 | + <div class="table-cell table-100"><?php esc_html_e('Synchro', 'wpshop'); ?></div> |
|
28 | 28 | </div> |
29 | 29 | |
30 | 30 | <?php |
31 | - if ( ! empty( $orders ) ) : |
|
32 | - foreach ( $orders as $order ) : |
|
33 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'item', array( |
|
31 | + if (!empty($orders)) : |
|
32 | + foreach ($orders as $order) : |
|
33 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'item', array( |
|
34 | 34 | 'order' => $order, |
35 | - ) ); |
|
35 | + )); |
|
36 | 36 | endforeach; |
37 | 37 | endif; |
38 | 38 | ?> |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h2><?php esc_html_e( 'Orders', 'wpshop' ); ?></h2> |
|
20 | + <h2><?php esc_html_e('Orders', 'wpshop'); ?></h2> |
|
21 | 21 | |
22 | 22 | <div class="wps-filter-bar wpeo-form form-light"> |
23 | 23 | <div class="form-element"> |
24 | 24 | <label class="form-field-container"> |
25 | 25 | <span class="form-field-icon-prev"><i class="fas fa-filter"></i></span> |
26 | 26 | <select id="monselect" class="form-field"> |
27 | - <option value="valeur1" selected><?php esc_html_e( 'Date', 'wpshop' ); ?></option> |
|
28 | - <option value="valeur2"><?php esc_html_e( 'Title', 'wpshop' ); ?></option> |
|
29 | - <option value="valeur3"><?php esc_html_e( 'Method of payment', 'wpshop' ); ?></option> |
|
30 | - <option value="valeur4"><?php esc_html_e( 'Order status', 'wpshop' ); ?></option> |
|
31 | - <option value="valeur5"><?php esc_html_e( 'Desynchronized orders', 'wpshop' ); ?></option> |
|
27 | + <option value="valeur1" selected><?php esc_html_e('Date', 'wpshop'); ?></option> |
|
28 | + <option value="valeur2"><?php esc_html_e('Title', 'wpshop'); ?></option> |
|
29 | + <option value="valeur3"><?php esc_html_e('Method of payment', 'wpshop'); ?></option> |
|
30 | + <option value="valeur4"><?php esc_html_e('Order status', 'wpshop'); ?></option> |
|
31 | + <option value="valeur5"><?php esc_html_e('Desynchronized orders', 'wpshop'); ?></option> |
|
32 | 32 | </select> |
33 | 33 | </label> |
34 | 34 | </div> |
35 | 35 | |
36 | - <a href="#" class="wpeo-button button-filter"><?php esc_html_e( 'Filter', 'wpshop' ); ?></a> |
|
36 | + <a href="#" class="wpeo-button button-filter"><?php esc_html_e('Filter', 'wpshop'); ?></a> |
|
37 | 37 | |
38 | 38 | <div class="form-element"> |
39 | 39 | <label class="form-field-container"> |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | </label> |
43 | 43 | </div> |
44 | 44 | |
45 | - <a href="#" class="wpeo-button button-filter"><?php esc_html_e( 'Search', 'wpshop' ); ?></a> |
|
45 | + <a href="#" class="wpeo-button button-filter"><?php esc_html_e('Search', 'wpshop'); ?></a> |
|
46 | 46 | |
47 | 47 | <div></div> |
48 | 48 | <div></div> |
49 | - <div><?php echo esc_html( $count ) . ' éléments'; ?></div> |
|
49 | + <div><?php echo esc_html($count) . ' éléments'; ?></div> |
|
50 | 50 | </div> |
51 | 51 | |
52 | 52 | <?php Doli_Order::g()->display(); ?> |
@@ -14,34 +14,34 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <div class="table-row"> |
20 | 20 | <div class="table-cell table-25"><input type="checkbox" class="check"/></div> |
21 | 21 | <div class="table-cell table-full"> |
22 | 22 | <ul class="reference-id"> |
23 | - <li><i class="fas fa-calendar-alt"></i> <?php echo esc_html( $order->data['date_commande']['rendered']['date'] ); ?></li> |
|
23 | + <li><i class="fas fa-calendar-alt"></i> <?php echo esc_html($order->data['date_commande']['rendered']['date']); ?></li> |
|
24 | 24 | </ul> |
25 | 25 | <div class="reference-title"> |
26 | - <a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-order&id=' . $order->data['id'] ) ); ?>"><?php echo esc_html( $order->data['title'] ); ?></a> |
|
26 | + <a href="<?php echo esc_attr(admin_url('admin.php?page=wps-order&id=' . $order->data['id'])); ?>"><?php echo esc_html($order->data['title']); ?></a> |
|
27 | 27 | </div> |
28 | 28 | <ul class="reference-actions"> |
29 | - <li><a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-order&id=' . $order->data['id'] ) ); ?>"><?php esc_html_e( 'See', 'wpshop' ); ?></a></li> |
|
30 | - <?php if ( ! empty( $order->data['external_id'] ) ) : ?> |
|
31 | - <li><a href="#" target="_blank"><?php esc_html_e( 'See in Dolibarr', 'wpshop' ); ?></a></li> |
|
29 | + <li><a href="<?php echo esc_attr(admin_url('admin.php?page=wps-order&id=' . $order->data['id'])); ?>"><?php esc_html_e('See', 'wpshop'); ?></a></li> |
|
30 | + <?php if (!empty($order->data['external_id'])) : ?> |
|
31 | + <li><a href="#" target="_blank"><?php esc_html_e('See in Dolibarr', 'wpshop'); ?></a></li> |
|
32 | 32 | <?php endif; ?> |
33 | 33 | </ul> |
34 | 34 | </div> |
35 | 35 | <div class="table-cell table-200"> |
36 | - <div><strong><?php echo esc_html( $order->data['tier']->data['title'] ); ?></strong></div> |
|
37 | - <div><?php echo esc_html( $order->data['tier']->data['address'] ); ?></div> |
|
38 | - <div><?php echo esc_html( $order->data['tier']->data['zip'] ) . ' ' . esc_html( $order->data['tier']->data['country'] ); ?></div> |
|
39 | - <div><?php echo esc_html( $order->data['tier']->data['phone'] ); ?></div> |
|
36 | + <div><strong><?php echo esc_html($order->data['tier']->data['title']); ?></strong></div> |
|
37 | + <div><?php echo esc_html($order->data['tier']->data['address']); ?></div> |
|
38 | + <div><?php echo esc_html($order->data['tier']->data['zip']) . ' ' . esc_html($order->data['tier']->data['country']); ?></div> |
|
39 | + <div><?php echo esc_html($order->data['tier']->data['phone']); ?></div> |
|
40 | 40 | </div> |
41 | - <div class="table-cell table-150"><?php echo Payment::g()->convert_status( $order->data ); ?></div> |
|
42 | - <div class="table-cell table-100"><?php echo esc_html( $order->data['payment_method'] ); ?></div> |
|
43 | - <div class="table-cell table-100"><strong><?php echo esc_html( number_format( $order->data['total_ttc'], 2, ',', '' ) ); ?>€</strong></div> |
|
44 | - <?php apply_filters( 'wps_order_table_tr', $order ); ?> |
|
41 | + <div class="table-cell table-150"><?php echo Payment::g()->convert_status($order->data); ?></div> |
|
42 | + <div class="table-cell table-100"><?php echo esc_html($order->data['payment_method']); ?></div> |
|
43 | + <div class="table-cell table-100"><strong><?php echo esc_html(number_format($order->data['total_ttc'], 2, ',', '')); ?>€</strong></div> |
|
44 | + <?php apply_filters('wps_order_table_tr', $order); ?> |
|
45 | 45 | <div class="table-cell table-100"> |
46 | 46 | <!-- <div class="button-synchro"><i class="fas fa-sync"></i></div> |
47 | 47 | <div class="statut statut-green wpeo-tooltip-event" data-direction="left" aria-label="Date de la derniere synchro"></div> --> |
@@ -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 | * Checkout Class. |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function get_posted_data() { |
39 | 39 | $data = array( |
40 | - 'contact' => ! empty( $_POST['contact'] ) ? (array) $_POST['contact'] : array(), |
|
41 | - 'third_party' => ! empty( $_POST['third_party'] ) ? (array) $_POST['third_party'] : array(), |
|
40 | + 'contact' => !empty($_POST['contact']) ? (array)$_POST['contact'] : array(), |
|
41 | + 'third_party' => !empty($_POST['third_party']) ? (array)$_POST['third_party'] : array(), |
|
42 | 42 | ); |
43 | 43 | |
44 | - $data['contact']['firstname'] = ! empty( $_POST['contact']['firstname'] ) ? sanitize_text_field( $_POST['contact']['firstname'] ) : ''; |
|
45 | - $data['contact']['lastname'] = ! empty( $_POST['contact']['lastname'] ) ? sanitize_text_field( $_POST['contact']['lastname'] ) : ''; |
|
46 | - $data['contact']['phone'] = ! empty( $_POST['contact']['phone'] ) ? sanitize_text_field( $_POST['contact']['phone'] ) : ''; |
|
47 | - $data['contact']['email'] = ! empty( $_POST['contact']['email'] ) ? sanitize_email( $_POST['contact']['email'] ) : ''; |
|
48 | - $data['contact']['password'] = ! empty( $_POST['contact']['password'] ) ? (string) ( $_POST['contact']['password'] ) : ''; |
|
49 | - $data['third_party']['country_id'] = ! empty( $_POST['third_party']['country_id'] ) ? (int) ( $_POST['third_party']['country_id'] ) : ''; |
|
50 | - $data['third_party']['address'] = ! empty( $_POST['third_party']['address'] ) ? sanitize_text_field( $_POST['third_party']['address'] ) : ''; |
|
51 | - $data['third_party']['zip'] = ! empty( $_POST['third_party']['zip'] ) ? sanitize_text_field( $_POST['third_party']['zip'] ) : ''; |
|
52 | - $data['third_party']['town'] = ! empty( $_POST['third_party']['town'] ) ? sanitize_text_field( $_POST['third_party']['town'] ) : ''; |
|
53 | - |
|
54 | - return apply_filters( 'wps_checkout_posted_data', $data ); |
|
44 | + $data['contact']['firstname'] = !empty($_POST['contact']['firstname']) ? sanitize_text_field($_POST['contact']['firstname']) : ''; |
|
45 | + $data['contact']['lastname'] = !empty($_POST['contact']['lastname']) ? sanitize_text_field($_POST['contact']['lastname']) : ''; |
|
46 | + $data['contact']['phone'] = !empty($_POST['contact']['phone']) ? sanitize_text_field($_POST['contact']['phone']) : ''; |
|
47 | + $data['contact']['email'] = !empty($_POST['contact']['email']) ? sanitize_email($_POST['contact']['email']) : ''; |
|
48 | + $data['contact']['password'] = !empty($_POST['contact']['password']) ? (string)($_POST['contact']['password']) : ''; |
|
49 | + $data['third_party']['country_id'] = !empty($_POST['third_party']['country_id']) ? (int)($_POST['third_party']['country_id']) : ''; |
|
50 | + $data['third_party']['address'] = !empty($_POST['third_party']['address']) ? sanitize_text_field($_POST['third_party']['address']) : ''; |
|
51 | + $data['third_party']['zip'] = !empty($_POST['third_party']['zip']) ? sanitize_text_field($_POST['third_party']['zip']) : ''; |
|
52 | + $data['third_party']['town'] = !empty($_POST['third_party']['town']) ? sanitize_text_field($_POST['third_party']['town']) : ''; |
|
53 | + |
|
54 | + return apply_filters('wps_checkout_posted_data', $data); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -65,41 +65,41 @@ discard block |
||
65 | 65 | return array( |
66 | 66 | 'contact' => array( |
67 | 67 | 'firstname' => array( |
68 | - 'label' => __( 'First name', 'wpshop' ), |
|
68 | + 'label' => __('First name', 'wpshop'), |
|
69 | 69 | 'required' => false, |
70 | 70 | ), |
71 | 71 | 'lastname' => array( |
72 | - 'label' => __( 'Last name', 'wpshop' ), |
|
72 | + 'label' => __('Last name', 'wpshop'), |
|
73 | 73 | 'required' => false, |
74 | 74 | ), |
75 | 75 | 'phone' => array( |
76 | - 'label' => __( 'Phone', 'wpshop' ), |
|
76 | + 'label' => __('Phone', 'wpshop'), |
|
77 | 77 | 'required' => false, |
78 | 78 | ), |
79 | 79 | 'email' => array( |
80 | - 'label' => __( 'Email address', 'wpshop' ), |
|
80 | + 'label' => __('Email address', 'wpshop'), |
|
81 | 81 | 'required' => true, |
82 | 82 | ), |
83 | 83 | 'password' => array( |
84 | - 'label' => __( 'Password', 'wpshop' ), |
|
84 | + 'label' => __('Password', 'wpshop'), |
|
85 | 85 | 'required' => false, |
86 | 86 | ), |
87 | 87 | ), |
88 | 88 | 'third_party' => array( |
89 | 89 | 'country_id' => array( |
90 | - 'label' => __( 'Country', 'wpshop' ), |
|
90 | + 'label' => __('Country', 'wpshop'), |
|
91 | 91 | 'required' => true, |
92 | 92 | ), |
93 | 93 | 'address' => array( |
94 | - 'label' => __( 'Street Address', 'wpshop' ), |
|
94 | + 'label' => __('Street Address', 'wpshop'), |
|
95 | 95 | 'required' => true, |
96 | 96 | ), |
97 | 97 | 'zip' => array( |
98 | - 'label' => __( 'Postcode / Zip', 'wpshop' ), |
|
98 | + 'label' => __('Postcode / Zip', 'wpshop'), |
|
99 | 99 | 'required' => true, |
100 | 100 | ), |
101 | 101 | 'town' => array( |
102 | - 'label' => __( 'Town / City', 'wpshop' ), |
|
102 | + 'label' => __('Town / City', 'wpshop'), |
|
103 | 103 | 'required' => true, |
104 | 104 | ), |
105 | 105 | ), |
@@ -114,30 +114,30 @@ discard block |
||
114 | 114 | * @param array $data Les données reçu du formulaire. |
115 | 115 | * @param WP_Error $errors Gestion des erreurs du formulaire. |
116 | 116 | */ |
117 | - protected function validate_posted_data( &$data, &$errors ) { |
|
118 | - foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) { |
|
119 | - foreach ( $fieldset as $field_key => $field ) { |
|
120 | - if ( $field['required'] && ( '' == $data[ $fieldset_key ][ $field_key ] || '0' == $data[ $fieldset_key ][ $field_key ] ) ) { |
|
117 | + protected function validate_posted_data(&$data, &$errors) { |
|
118 | + foreach ($this->get_checkout_fields() as $fieldset_key => $fieldset) { |
|
119 | + foreach ($fieldset as $field_key => $field) { |
|
120 | + if ($field['required'] && ('' == $data[$fieldset_key][$field_key] || '0' == $data[$fieldset_key][$field_key])) { |
|
121 | 121 | /* translators: Lastname is a required field. */ |
122 | - $errors->add( 'required-field', apply_filters( 'wps_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'wpshop' ), '<strong>' . esc_html( $field['label'] ) . '</strong>' ), $field['label'] ) ); |
|
122 | + $errors->add('required-field', apply_filters('wps_checkout_required_field_notice', sprintf(__('%s is a required field.', 'wpshop'), '<strong>' . esc_html($field['label']) . '</strong>'), $field['label'])); |
|
123 | 123 | |
124 | 124 | $error_field = array( |
125 | 125 | 'required' => true, |
126 | 126 | 'input_class' => $fieldset_key . '-' . $field_key, |
127 | 127 | ); |
128 | 128 | |
129 | - $errors->add_data( $error_field, 'input_' . $fieldset_key . '_' . $field_key ); |
|
129 | + $errors->add_data($error_field, 'input_' . $fieldset_key . '_' . $field_key); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( ! is_user_logged_in() && 'email' === $field_key && false !== email_exists( $data['contact']['email'] ) ) { |
|
132 | + if (!is_user_logged_in() && 'email' === $field_key && false !== email_exists($data['contact']['email'])) { |
|
133 | 133 | /* translators: [email protected] is already used. */ |
134 | - $errors->add( 'email-exists', apply_filters( 'wps_checkout_email_exists_notice', sprintf( __( '%s is already used.', 'wpshop' ), '<strong>' . esc_html( $field['label'] ) . '</strong>' ), $field['label'] ) ); |
|
134 | + $errors->add('email-exists', apply_filters('wps_checkout_email_exists_notice', sprintf(__('%s is already used.', 'wpshop'), '<strong>' . esc_html($field['label']) . '</strong>'), $field['label'])); |
|
135 | 135 | $error_field = array( |
136 | 136 | 'email_exists' => true, |
137 | 137 | 'input_class' => $fieldset_key . '-' . $field_key, |
138 | 138 | ); |
139 | 139 | |
140 | - $errors->add_data( $error_field, 'input_' . $fieldset_key . '_' . $field_key ); |
|
140 | + $errors->add_data($error_field, 'input_' . $fieldset_key . '_' . $field_key); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param array $data Les données reçu du formulaire. |
152 | 152 | * @param WP_Error $errors Gestion des erreurs du formulaire. |
153 | 153 | */ |
154 | - public function validate_checkout( &$data, &$errors ) { |
|
155 | - $this->validate_posted_data( $data, $errors ); |
|
154 | + public function validate_checkout(&$data, &$errors) { |
|
155 | + $this->validate_posted_data($data, $errors); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -162,56 +162,56 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @param Order_Model $order Les données de la commande. |
164 | 164 | */ |
165 | - public function process_order_payment( $order ) { |
|
166 | - $type = ! empty( $_POST['type_payment'] ) ? $_POST['type_payment'] : ''; |
|
165 | + public function process_order_payment($order) { |
|
166 | + $type = !empty($_POST['type_payment']) ? $_POST['type_payment'] : ''; |
|
167 | 167 | |
168 | - switch ( $type ) { |
|
168 | + switch ($type) { |
|
169 | 169 | case 'cheque': |
170 | - update_post_meta( $order->data['id'], 'payment_method', 'cheque' ); |
|
170 | + update_post_meta($order->data['id'], 'payment_method', 'cheque'); |
|
171 | 171 | Cart_Session::g()->destroy(); |
172 | - wp_send_json_success( array( |
|
172 | + wp_send_json_success(array( |
|
173 | 173 | 'namespace' => 'wpshopFrontend', |
174 | 174 | 'module' => 'checkout', |
175 | 175 | 'callback_success' => 'redirect', |
176 | 176 | 'url' => Pages::g()->get_valid_checkout_link() . '?order_id=' . $order->data['id'], |
177 | - ) ); |
|
177 | + )); |
|
178 | 178 | break; |
179 | 179 | case 'payment_in_shop': |
180 | - update_post_meta( $order->data['id'], 'payment_method', 'payment_in_shop' ); |
|
180 | + update_post_meta($order->data['id'], 'payment_method', 'payment_in_shop'); |
|
181 | 181 | Cart_Session::g()->destroy(); |
182 | - wp_send_json_success( array( |
|
182 | + wp_send_json_success(array( |
|
183 | 183 | 'namespace' => 'wpshopFrontend', |
184 | 184 | 'module' => 'checkout', |
185 | 185 | 'callback_success' => 'redirect', |
186 | 186 | 'url' => Pages::g()->get_valid_checkout_link() . '?order_id=' . $order->data['id'], |
187 | - ) ); |
|
187 | + )); |
|
188 | 188 | break; |
189 | 189 | case 'paypal': |
190 | - update_post_meta( $order->data['id'], 'payment_method', 'paypal' ); |
|
190 | + update_post_meta($order->data['id'], 'payment_method', 'paypal'); |
|
191 | 191 | |
192 | - $result = Paypal::g()->process_payment( $order ); |
|
192 | + $result = Paypal::g()->process_payment($order); |
|
193 | 193 | Cart_Session::g()->destroy(); |
194 | - if ( ! empty( $result['url'] ) ) { |
|
195 | - wp_send_json_success( array( |
|
194 | + if (!empty($result['url'])) { |
|
195 | + wp_send_json_success(array( |
|
196 | 196 | 'namespace' => 'wpshopFrontend', |
197 | 197 | 'module' => 'checkout', |
198 | 198 | 'callback_success' => 'redirectToPayment', |
199 | 199 | 'url' => $result['url'], |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | } |
202 | 202 | break; |
203 | 203 | case 'stripe': |
204 | - update_post_meta( $order->data['id'], 'payment_method', 'stripe' ); |
|
205 | - $result = Stripe::g()->process_payment( $order ); |
|
204 | + update_post_meta($order->data['id'], 'payment_method', 'stripe'); |
|
205 | + $result = Stripe::g()->process_payment($order); |
|
206 | 206 | Cart_Session::g()->destroy(); |
207 | 207 | |
208 | - if ( ! empty( $result['id'] ) ) { |
|
209 | - wp_send_json_success( array( |
|
208 | + if (!empty($result['id'])) { |
|
209 | + wp_send_json_success(array( |
|
210 | 210 | 'namespace' => 'wpshopFrontend', |
211 | 211 | 'module' => 'stripe', |
212 | 212 | 'callback_success' => 'redirectToPayment', |
213 | 213 | 'id' => $result['id'], |
214 | - ) ); |
|
214 | + )); |
|
215 | 215 | } |
216 | 216 | break; |
217 | 217 | } |
@@ -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 | * Checkout Action Class. |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | * @since 2.0.0 |
29 | 29 | */ |
30 | 30 | public function __construct() { |
31 | - add_action( 'init', array( Checkout_Shortcode::g(), 'callback_init' ) ); |
|
31 | + add_action('init', array(Checkout_Shortcode::g(), 'callback_init')); |
|
32 | 32 | |
33 | - add_action( 'wps_after_cart_table', array( $this, 'callback_after_cart_table' ), 20 ); |
|
33 | + add_action('wps_after_cart_table', array($this, 'callback_after_cart_table'), 20); |
|
34 | 34 | |
35 | - add_action( 'wps_checkout_shipping', array( $this, 'callback_checkout_shipping' ), 10, 2 ); |
|
36 | - add_action( 'wps_checkout_order_review', array( $this, 'callback_checkout_order_review' ), 10, 1 ); |
|
37 | - add_action( 'wps_checkout_after_order_review', array( $this, 'callback_checkout_payment' ) ); |
|
35 | + add_action('wps_checkout_shipping', array($this, 'callback_checkout_shipping'), 10, 2); |
|
36 | + add_action('wps_checkout_order_review', array($this, 'callback_checkout_order_review'), 10, 1); |
|
37 | + add_action('wps_checkout_after_order_review', array($this, 'callback_checkout_payment')); |
|
38 | 38 | |
39 | - add_action( 'wp_ajax_wps_checkout_create_third_party', array( $this, 'callback_checkout_create_third' ) ); |
|
40 | - add_action( 'wp_ajax_nopriv_wps_checkout_create_third_party', array( $this, 'callback_checkout_create_third' ) ); |
|
39 | + add_action('wp_ajax_wps_checkout_create_third_party', array($this, 'callback_checkout_create_third')); |
|
40 | + add_action('wp_ajax_nopriv_wps_checkout_create_third_party', array($this, 'callback_checkout_create_third')); |
|
41 | 41 | |
42 | - add_action( 'wp_ajax_wps_place_order', array( $this, 'callback_place_order' ) ); |
|
43 | - add_action( 'wp_ajax_nopriv_wps_place_order', array( $this, 'callback_place_order' ) ); |
|
42 | + add_action('wp_ajax_wps_place_order', array($this, 'callback_place_order')); |
|
43 | + add_action('wp_ajax_nopriv_wps_place_order', array($this, 'callback_place_order')); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function callback_after_cart_table() { |
52 | 52 | $link_checkout = Pages::g()->get_checkout_link(); |
53 | - include( Template_Util::get_template_part( 'checkout', 'proceed-to-checkout-button' ) ); |
|
53 | + include(Template_Util::get_template_part('checkout', 'proceed-to-checkout-button')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param Third_Party_Model $third_party Les données du tier. |
62 | 62 | * @param Contact_Model $contact Les données du contact. |
63 | 63 | */ |
64 | - public function callback_checkout_shipping( $third_party, $contact ) { |
|
65 | - include( Template_Util::get_template_part( 'checkout', 'form-shipping' ) ); |
|
64 | + public function callback_checkout_shipping($third_party, $contact) { |
|
65 | + include(Template_Util::get_template_part('checkout', 'form-shipping')); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param Proposal_Model $proposal Les données du devis. |
74 | 74 | */ |
75 | - public function callback_checkout_order_review( $proposal ) { |
|
75 | + public function callback_checkout_order_review($proposal) { |
|
76 | 76 | $cart_contents = Cart_Session::g()->cart_contents; |
77 | 77 | |
78 | 78 | $tva_lines = array(); |
79 | 79 | |
80 | - if ( ! empty( $proposal->data['lines'] ) ) { |
|
81 | - foreach ( $proposal->data['lines'] as $line ) { |
|
80 | + if (!empty($proposal->data['lines'])) { |
|
81 | + foreach ($proposal->data['lines'] as $line) { |
|
82 | 82 | |
83 | - if ( empty( $tva_lines[ $line['tva_tx'] ] ) ) { |
|
84 | - $tva_lines[ $line['tva_tx'] ] = 0; |
|
83 | + if (empty($tva_lines[$line['tva_tx']])) { |
|
84 | + $tva_lines[$line['tva_tx']] = 0; |
|
85 | 85 | } |
86 | 86 | |
87 | - $tva_lines[ $line['tva_tx'] ] += $line['total_tva']; |
|
87 | + $tva_lines[$line['tva_tx']] += $line['total_tva']; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - include( Template_Util::get_template_part( 'checkout', 'review-order' ) ); |
|
91 | + include(Template_Util::get_template_part('checkout', 'review-order')); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @since 2.0.0 |
98 | 98 | */ |
99 | 99 | public function callback_checkout_payment() { |
100 | - $payment_methods = get_option( 'wps_payment_methods', Payment::g()->default_options ); |
|
100 | + $payment_methods = get_option('wps_payment_methods', Payment::g()->default_options); |
|
101 | 101 | |
102 | - include( Template_Util::get_template_part( 'checkout', 'payment' ) ); |
|
102 | + include(Template_Util::get_template_part('checkout', 'payment')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -108,84 +108,84 @@ discard block |
||
108 | 108 | * @since 2.0.0 |
109 | 109 | */ |
110 | 110 | public function callback_checkout_create_third() { |
111 | - check_ajax_referer( 'callback_checkout_create_third' ); |
|
111 | + check_ajax_referer('callback_checkout_create_third'); |
|
112 | 112 | |
113 | 113 | $errors = new \WP_Error(); |
114 | 114 | $posted_data = Checkout::g()->get_posted_data(); |
115 | 115 | |
116 | - Checkout::g()->validate_checkout( $posted_data, $errors ); |
|
116 | + Checkout::g()->validate_checkout($posted_data, $errors); |
|
117 | 117 | |
118 | - if ( 0 === count( $errors->error_data ) ) { |
|
119 | - if ( empty( $posted_data['third_party']['title'] ) || empty( $posted_data['contact']['lastname'] ) ) { |
|
120 | - $exploded_email = explode( '@', $posted_data['contact']['email'] ); |
|
118 | + if (0 === count($errors->error_data)) { |
|
119 | + if (empty($posted_data['third_party']['title']) || empty($posted_data['contact']['lastname'])) { |
|
120 | + $exploded_email = explode('@', $posted_data['contact']['email']); |
|
121 | 121 | |
122 | - if ( empty( $posted_data['third_party']['title'] ) ) { |
|
122 | + if (empty($posted_data['third_party']['title'])) { |
|
123 | 123 | $posted_data['third_party']['title'] = $exploded_email[0]; |
124 | 124 | } |
125 | 125 | |
126 | - if ( empty( $posted_data['contact']['lastname'] ) ) { |
|
126 | + if (empty($posted_data['contact']['lastname'])) { |
|
127 | 127 | $posted_data['contact']['lastname'] = $exploded_email[0]; |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - $posted_data['third_party']['country_id'] = (int) $posted_data['third_party']['country_id']; |
|
132 | - $posted_data['third_party']['country'] = get_from_code( $posted_data['third_party']['country_id'] ); |
|
131 | + $posted_data['third_party']['country_id'] = (int)$posted_data['third_party']['country_id']; |
|
132 | + $posted_data['third_party']['country'] = get_from_code($posted_data['third_party']['country_id']); |
|
133 | 133 | $posted_data['third_party']['phone'] = $posted_data['contact']['phone']; |
134 | 134 | |
135 | - if ( ! is_user_logged_in() ) { |
|
136 | - $third_party = Third_Party::g()->update( $posted_data['third_party'] ); |
|
137 | - do_action( 'wps_checkout_create_third_party', $third_party ); |
|
135 | + if (!is_user_logged_in()) { |
|
136 | + $third_party = Third_Party::g()->update($posted_data['third_party']); |
|
137 | + do_action('wps_checkout_create_third_party', $third_party); |
|
138 | 138 | |
139 | - $posted_data['contact']['login'] = sanitize_user( current( explode( '@', $posted_data['contact']['email'] ) ), true ); |
|
139 | + $posted_data['contact']['login'] = sanitize_user(current(explode('@', $posted_data['contact']['email'])), true); |
|
140 | 140 | $posted_data['contact']['password'] = wp_generate_password(); |
141 | 141 | $posted_data['contact']['third_party_id'] = $third_party->data['id']; |
142 | 142 | |
143 | - $contact = Contact::g()->update( $posted_data['contact'] ); |
|
143 | + $contact = Contact::g()->update($posted_data['contact']); |
|
144 | 144 | |
145 | 145 | $third_party->data['contact_ids'][] = $contact->data['id']; |
146 | - $thid_party = Third_Party::g()->update( $third_party->data ); |
|
146 | + $thid_party = Third_Party::g()->update($third_party->data); |
|
147 | 147 | |
148 | - do_action( 'wps_checkout_create_contact', $contact ); |
|
148 | + do_action('wps_checkout_create_contact', $contact); |
|
149 | 149 | |
150 | 150 | $signon_data = array( |
151 | 151 | 'user_login' => $posted_data['contact']['login'], |
152 | 152 | 'user_password' => $posted_data['contact']['password'], |
153 | 153 | ); |
154 | 154 | |
155 | - $user = wp_signon( $signon_data, is_ssl() ); |
|
155 | + $user = wp_signon($signon_data, is_ssl()); |
|
156 | 156 | |
157 | - $key = get_password_reset_key( $user ); |
|
157 | + $key = get_password_reset_key($user); |
|
158 | 158 | |
159 | - $trackcode = get_user_meta( $contact->data['id'], 'p_user_registration_code', true ); |
|
160 | - $track_url = get_option( 'siteurl' ) . '/wp-login.php?action=rp&key=' . $key . '&login=' . $posted_data['contact']['login']; |
|
159 | + $trackcode = get_user_meta($contact->data['id'], 'p_user_registration_code', true); |
|
160 | + $track_url = get_option('siteurl') . '/wp-login.php?action=rp&key=' . $key . '&login=' . $posted_data['contact']['login']; |
|
161 | 161 | |
162 | - Emails::g()->send_mail( $posted_data['contact']['email'], 'wps_email_customer_new_account', array_merge( $posted_data, array( 'url' => $track_url ) ) ); |
|
162 | + Emails::g()->send_mail($posted_data['contact']['email'], 'wps_email_customer_new_account', array_merge($posted_data, array('url' => $track_url))); |
|
163 | 163 | } else { |
164 | 164 | $current_user = wp_get_current_user(); |
165 | 165 | |
166 | - $contact = Contact::g()->get( array( |
|
166 | + $contact = Contact::g()->get(array( |
|
167 | 167 | 'search' => $current_user->user_email, |
168 | 168 | 'number' => 1, |
169 | - ), true ); |
|
169 | + ), true); |
|
170 | 170 | |
171 | - $third_party = Third_Party::g()->get( array( 'id' => $contact->data['third_party_id'] ), true ); |
|
171 | + $third_party = Third_Party::g()->get(array('id' => $contact->data['third_party_id']), true); |
|
172 | 172 | |
173 | 173 | $posted_data['third_party']['id'] = $third_party->data['id']; |
174 | 174 | |
175 | - $third_party = Third_Party::g()->update( $posted_data['third_party'] ); |
|
175 | + $third_party = Third_Party::g()->update($posted_data['third_party']); |
|
176 | 176 | } |
177 | 177 | |
178 | - $type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : 'proposal'; |
|
178 | + $type = !empty($_POST['type']) ? sanitize_text_field($_POST['type']) : 'proposal'; |
|
179 | 179 | |
180 | - $proposal = Proposals::g()->get( array( 'schema' => true ), true ); |
|
180 | + $proposal = Proposals::g()->get(array('schema' => true), true); |
|
181 | 181 | |
182 | 182 | $last_ref = Proposals::g()->get_last_ref(); |
183 | - $last_ref = empty( $last_ref ) ? 1 : $last_ref; |
|
183 | + $last_ref = empty($last_ref) ? 1 : $last_ref; |
|
184 | 184 | $last_ref++; |
185 | 185 | |
186 | - $proposal->data['title'] = 'PR' . sprintf( '%06d', $last_ref ); |
|
187 | - $proposal->data['ref'] = sprintf( '%06d', $last_ref ); |
|
188 | - $proposal->data['datec'] = current_time( 'mysql' ); |
|
186 | + $proposal->data['title'] = 'PR' . sprintf('%06d', $last_ref); |
|
187 | + $proposal->data['ref'] = sprintf('%06d', $last_ref); |
|
188 | + $proposal->data['datec'] = current_time('mysql'); |
|
189 | 189 | $proposal->data['parent_id'] = $third_party->data['id']; |
190 | 190 | $proposal->data['author_id'] = $contact->data['id']; |
191 | 191 | $proposal->data['status'] = 'publish'; |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $total_ht = 0; |
195 | 195 | $total_ttc = 0; |
196 | 196 | |
197 | - if ( ! empty( Cart_Session::g()->cart_contents ) ) { |
|
198 | - foreach ( Cart_Session::g()->cart_contents as $content ) { |
|
197 | + if (!empty(Cart_Session::g()->cart_contents)) { |
|
198 | + foreach (Cart_Session::g()->cart_contents as $content) { |
|
199 | 199 | $proposal->data['lines'][] = $content; |
200 | 200 | |
201 | 201 | $total_ht += $content['price']; |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | $proposal->data['total_ht'] = $total_ht; |
207 | 207 | $proposal->data['total_ttc'] = $total_ttc; |
208 | 208 | |
209 | - $proposal = Proposals::g()->update( $proposal->data ); |
|
210 | - do_action( 'wps_checkout_create_proposal', $proposal ); |
|
209 | + $proposal = Proposals::g()->update($proposal->data); |
|
210 | + do_action('wps_checkout_create_proposal', $proposal); |
|
211 | 211 | |
212 | - Cart_Session::g()->add_external_data( 'proposal_id', $proposal->data['id'] ); |
|
212 | + Cart_Session::g()->add_external_data('proposal_id', $proposal->data['id']); |
|
213 | 213 | Cart_Session::g()->update_session(); |
214 | 214 | |
215 | - wp_send_json_success( array( |
|
215 | + wp_send_json_success(array( |
|
216 | 216 | 'namespace' => 'wpshopFrontend', |
217 | 217 | 'module' => 'checkout', |
218 | 218 | 'callback_success' => 'createdThirdSuccess', |
219 | 219 | 'redirect_url' => Pages::g()->get_checkout_link() . '?step=2', |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | } else { |
222 | 222 | ob_start(); |
223 | - include( Template_Util::get_template_part( 'checkout', 'notice-error' ) ); |
|
223 | + include(Template_Util::get_template_part('checkout', 'notice-error')); |
|
224 | 224 | $template = ob_get_clean(); |
225 | 225 | |
226 | - wp_send_json_success( array( |
|
226 | + wp_send_json_success(array( |
|
227 | 227 | 'namespace' => 'wpshopFrontend', |
228 | 228 | 'module' => 'checkout', |
229 | 229 | 'callback_success' => 'checkoutErrors', |
230 | 230 | 'errors' => $errors, |
231 | 231 | 'template' => $template, |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
@@ -239,30 +239,30 @@ discard block |
||
239 | 239 | * @since 2.0.0 |
240 | 240 | */ |
241 | 241 | public function callback_place_order() { |
242 | - check_ajax_referer( 'callback_place_order' ); |
|
242 | + check_ajax_referer('callback_place_order'); |
|
243 | 243 | |
244 | - do_action( 'wps_before_checkout_process' ); |
|
244 | + do_action('wps_before_checkout_process'); |
|
245 | 245 | |
246 | - do_action( 'wps_checkout_process' ); |
|
246 | + do_action('wps_checkout_process'); |
|
247 | 247 | |
248 | - $proposal = Proposals::g()->get( array( 'id' => Cart_Session::g()->external_data['proposal_id'] ), true ); |
|
248 | + $proposal = Proposals::g()->get(array('id' => Cart_Session::g()->external_data['proposal_id']), true); |
|
249 | 249 | $proposal->data['payment_method'] = $_POST['type_payment']; |
250 | 250 | |
251 | - $proposal = Proposals::g()->update( $proposal->data ); |
|
251 | + $proposal = Proposals::g()->update($proposal->data); |
|
252 | 252 | |
253 | - do_action( 'wps_checkout_update_proposal', $proposal ); |
|
253 | + do_action('wps_checkout_update_proposal', $proposal); |
|
254 | 254 | |
255 | - if ( 'order' == $_POST['type'] ) { |
|
256 | - $order = apply_filters( 'wps_checkout_create_order', $proposal ); |
|
257 | - Checkout::g()->process_order_payment( $order ); |
|
255 | + if ('order' == $_POST['type']) { |
|
256 | + $order = apply_filters('wps_checkout_create_order', $proposal); |
|
257 | + Checkout::g()->process_order_payment($order); |
|
258 | 258 | } else { |
259 | 259 | Cart_Session::g()->destroy(); |
260 | - wp_send_json_success( array( |
|
260 | + wp_send_json_success(array( |
|
261 | 261 | 'namespace' => 'wpshopFrontend', |
262 | 262 | 'module' => 'checkout', |
263 | 263 | 'callback_success' => 'redirect', |
264 | 264 | 'url' => Pages::g()->get_valid_proposal_link() . '?proposal_id=' . $proposal->data['id'], |
265 | - ) ); |
|
265 | + )); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<a href="<?php echo esc_url( $link_checkout ); ?>" class="wpeo-button alignright process-checkout"> |
|
20 | - <?php esc_html_e( 'Proceed to checkout', 'wpshop' ); ?> |
|
19 | +<a href="<?php echo esc_url($link_checkout); ?>" class="wpeo-button alignright process-checkout"> |
|
20 | + <?php esc_html_e('Proceed to checkout', 'wpshop'); ?> |
|
21 | 21 | </a> |
@@ -14,58 +14,58 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<h3><?php esc_html_e( 'Shipping details', 'wpshop' ); ?></h3> |
|
19 | +<h3><?php esc_html_e('Shipping details', 'wpshop'); ?></h3> |
|
20 | 20 | |
21 | -<?php do_action( 'wps_before_checkout_billing_form' ); ?> |
|
21 | +<?php do_action('wps_before_checkout_billing_form'); ?> |
|
22 | 22 | |
23 | 23 | <div class="wpeo-form"> |
24 | - <?php wp_nonce_field( 'callback_checkout_create_third' ); ?> |
|
24 | + <?php wp_nonce_field('callback_checkout_create_third'); ?> |
|
25 | 25 | |
26 | 26 | <div class="wpeo-grid grid-2"> |
27 | 27 | <div> |
28 | 28 | <div class="form-element contact-firstname"> |
29 | - <span class="form-label"><?php esc_html_e( 'First name', 'wpshop' ); ?></span> |
|
29 | + <span class="form-label"><?php esc_html_e('First name', 'wpshop'); ?></span> |
|
30 | 30 | <label class="form-field-container"> |
31 | - <input type="text" class="form-field" name="contact[firstname]" value="<?php echo ! empty( $contact->data['firstname'] ) ? $contact->data['firstname'] : ''; ?>" /> |
|
31 | + <input type="text" class="form-field" name="contact[firstname]" value="<?php echo !empty($contact->data['firstname']) ? $contact->data['firstname'] : ''; ?>" /> |
|
32 | 32 | </label> |
33 | 33 | </div> |
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div> |
37 | 37 | <div class="form-element contact-lastname"> |
38 | - <span class="form-label"><?php esc_html_e( 'Last name', 'wpshop' ); ?></span> |
|
38 | + <span class="form-label"><?php esc_html_e('Last name', 'wpshop'); ?></span> |
|
39 | 39 | <label class="form-field-container"> |
40 | - <input type="text" class="form-field" name="contact[lastname]" value="<?php echo ! empty( $contact->data['lastname'] ) ? $contact->data['lastname'] : ''; ?>" /> |
|
40 | + <input type="text" class="form-field" name="contact[lastname]" value="<?php echo !empty($contact->data['lastname']) ? $contact->data['lastname'] : ''; ?>" /> |
|
41 | 41 | </label> |
42 | 42 | </div> |
43 | 43 | </div> |
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <div class="form-element third_party-title"> |
47 | - <span class="form-label"><?php esc_html_e( 'Company name', 'wpshop' ); ?></span> |
|
47 | + <span class="form-label"><?php esc_html_e('Company name', 'wpshop'); ?></span> |
|
48 | 48 | <label class="form-field-container"> |
49 | - <input type="text" class="form-field" name="third_party[title]" value="<?php echo ! empty( $third_party->data['title'] ) ? $third_party->data['title'] : ''; ?>" /> |
|
49 | + <input type="text" class="form-field" name="third_party[title]" value="<?php echo !empty($third_party->data['title']) ? $third_party->data['title'] : ''; ?>" /> |
|
50 | 50 | </label> |
51 | 51 | </div> |
52 | 52 | |
53 | 53 | <?php $countries = get_countries(); ?> |
54 | 54 | <div class="form-element third_party-country_id form-element-required"> |
55 | - <span class="form-label"><?php esc_html_e( 'Country', 'wpshop' ); ?></span> |
|
55 | + <span class="form-label"><?php esc_html_e('Country', 'wpshop'); ?></span> |
|
56 | 56 | <label class="form-field-container"> |
57 | 57 | <select id="monselect" class="form-field" name="third_party[country_id]"> |
58 | 58 | <?php |
59 | - if ( ! empty( $countries ) ) : |
|
60 | - foreach ( $countries as $key => $country ) : |
|
59 | + if (!empty($countries)) : |
|
60 | + foreach ($countries as $key => $country) : |
|
61 | 61 | $selected = ''; |
62 | 62 | |
63 | - if ( ! empty( $third_party ) && $key == $third_party->data['country_id'] ) : |
|
63 | + if (!empty($third_party) && $key == $third_party->data['country_id']) : |
|
64 | 64 | $selected = 'selected="selected"'; |
65 | 65 | endif; |
66 | 66 | |
67 | 67 | ?> |
68 | - <option <?php echo $selected; ?> value="<?php echo esc_attr( $key ); ?>"><?php echo $country; ?></option> |
|
68 | + <option <?php echo $selected; ?> value="<?php echo esc_attr($key); ?>"><?php echo $country; ?></option> |
|
69 | 69 | <?php |
70 | 70 | endforeach; |
71 | 71 | endif; |
@@ -75,45 +75,45 @@ discard block |
||
75 | 75 | </div> |
76 | 76 | |
77 | 77 | <div class="form-element third_party-address form-element-required"> |
78 | - <span class="form-label"><?php esc_html_e( 'Street address', 'wpshop' ); ?></span> |
|
78 | + <span class="form-label"><?php esc_html_e('Street address', 'wpshop'); ?></span> |
|
79 | 79 | <label class="form-field-container"> |
80 | - <input type="text" class="form-field" name="third_party[address]" value="<?php echo ! empty( $third_party->data['address'] ) ? $third_party->data['address'] : ''; ?>" /> |
|
80 | + <input type="text" class="form-field" name="third_party[address]" value="<?php echo !empty($third_party->data['address']) ? $third_party->data['address'] : ''; ?>" /> |
|
81 | 81 | </label> |
82 | 82 | </div> |
83 | 83 | |
84 | 84 | <div class="form-element third_party-zip form-element-required"> |
85 | - <span class="form-label"><?php esc_html_e( 'Postcode / ZIP', 'wpshop' ); ?></span> |
|
85 | + <span class="form-label"><?php esc_html_e('Postcode / ZIP', 'wpshop'); ?></span> |
|
86 | 86 | <label class="form-field-container"> |
87 | - <input type="text" class="form-field" name="third_party[zip]" value="<?php echo ! empty( $third_party->data['zip'] ) ? $third_party->data['zip'] : ''; ?>" /> |
|
87 | + <input type="text" class="form-field" name="third_party[zip]" value="<?php echo !empty($third_party->data['zip']) ? $third_party->data['zip'] : ''; ?>" /> |
|
88 | 88 | </label> |
89 | 89 | </div> |
90 | 90 | |
91 | 91 | <div class="form-element third_party-town form-element-required"> |
92 | - <span class="form-label"><?php esc_html_e( 'Town / City', 'wpshop' ); ?></span> |
|
92 | + <span class="form-label"><?php esc_html_e('Town / City', 'wpshop'); ?></span> |
|
93 | 93 | <label class="form-field-container"> |
94 | - <input type="text" class="form-field" name="third_party[town]" value="<?php echo ! empty( $third_party->data['town'] ) ? $third_party->data['town'] : ''; ?>" /> |
|
94 | + <input type="text" class="form-field" name="third_party[town]" value="<?php echo !empty($third_party->data['town']) ? $third_party->data['town'] : ''; ?>" /> |
|
95 | 95 | </label> |
96 | 96 | </div> |
97 | 97 | |
98 | 98 | <div class="wpeo-grid grid-2"> |
99 | 99 | <div> |
100 | 100 | <div class="form-element contact-phone"> |
101 | - <span class="form-label"><?php esc_html_e( 'Phone number', 'wpshop' ); ?></span> |
|
101 | + <span class="form-label"><?php esc_html_e('Phone number', 'wpshop'); ?></span> |
|
102 | 102 | <label class="form-field-container"> |
103 | - <input type="text" class="form-field" name="contact[phone]" value="<?php echo ! empty( $third_party->data['phone'] ) ? $third_party->data['phone'] : ''; ?>" /> |
|
103 | + <input type="text" class="form-field" name="contact[phone]" value="<?php echo !empty($third_party->data['phone']) ? $third_party->data['phone'] : ''; ?>" /> |
|
104 | 104 | </label> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | |
108 | 108 | <div> |
109 | 109 | <div class="form-element contact-email form-element-required"> |
110 | - <span class="form-label"><?php esc_html_e( 'Email', 'wpshop' ); ?></span> |
|
110 | + <span class="form-label"><?php esc_html_e('Email', 'wpshop'); ?></span> |
|
111 | 111 | <label class="form-field-container"> |
112 | - <input type="text" class="form-field" name="contact[email]" value="<?php echo ! empty( $contact->data['email'] ) ? $contact->data['email'] : ''; ?>" /> |
|
112 | + <input type="text" class="form-field" name="contact[email]" value="<?php echo !empty($contact->data['email']) ? $contact->data['email'] : ''; ?>" /> |
|
113 | 113 | </label> |
114 | 114 | </div> |
115 | 115 | </div> |
116 | 116 | </div> |
117 | 117 | </div> |
118 | 118 | |
119 | -<?php do_action( 'wps_after_checkout_billing_form' ); ?> |
|
119 | +<?php do_action('wps_after_checkout_billing_form'); ?> |