@@ -14,24 +14,24 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <table class="wpeo-table"> |
20 | 20 | <thead> |
21 | 21 | <tr> |
22 | - <th><?php esc_html_e( 'E-mail', 'wpshop' ); ?></th> |
|
22 | + <th><?php esc_html_e('E-mail', 'wpshop'); ?></th> |
|
23 | 23 | <th></th> |
24 | 24 | </tr> |
25 | 25 | </thead> |
26 | 26 | <tbody> |
27 | 27 | <?php |
28 | - if ( ! empty( $emails ) ) : |
|
29 | - foreach ( $emails as $key => $email ) : |
|
28 | + if (!empty($emails)) : |
|
29 | + foreach ($emails as $key => $email) : |
|
30 | 30 | ?> |
31 | 31 | <tr> |
32 | 32 | <td><?php echo $email['title']; ?></td> |
33 | 33 | <td> |
34 | - <a href="<?php echo admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&page=wps-settings&tab=emails§ion=' . $key ); ?>" class="wpeo-button button-main"> |
|
34 | + <a href="<?php echo admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&page=wps-settings&tab=emails§ion=' . $key); ?>" class="wpeo-button button-main"> |
|
35 | 35 | <span>Gérer</span> |
36 | 36 | </a> |
37 | 37 | </td> |
@@ -16,21 +16,21 @@ |
||
16 | 16 | |
17 | 17 | namespace wpshop; |
18 | 18 | |
19 | -defined( 'ABSPATH' ) || exit; ?> |
|
19 | +defined('ABSPATH') || exit; ?> |
|
20 | 20 | |
21 | -<form class="wpeo-form" action="<?php echo admin_url( 'admin-post.php' ); ?>" method="POST"> |
|
21 | +<form class="wpeo-form" action="<?php echo admin_url('admin-post.php'); ?>" method="POST"> |
|
22 | 22 | <input type="hidden" name="action" value="wps_update_method_payment_payment_in_shop" /> |
23 | - <?php wp_nonce_field( 'update_method_payment_in_shop' ); ?> |
|
23 | + <?php wp_nonce_field('update_method_payment_in_shop'); ?> |
|
24 | 24 | |
25 | 25 | <div class="form-element"> |
26 | - <span class="form-label"><?php esc_html_e( 'Title', 'wpshop' ); ?></span> |
|
26 | + <span class="form-label"><?php esc_html_e('Title', 'wpshop'); ?></span> |
|
27 | 27 | <label class="form-field-container"> |
28 | - <input type="text" class="form-field" name="title" value="<?php echo esc_attr( $payment_data['title'] ); ?>" /> |
|
28 | + <input type="text" class="form-field" name="title" value="<?php echo esc_attr($payment_data['title']); ?>" /> |
|
29 | 29 | </label> |
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class="form-element"> |
33 | - <span class="form-label"><?php esc_html_e( 'Description', 'wpshop' ); ?></span> |
|
33 | + <span class="form-label"><?php esc_html_e('Description', 'wpshop'); ?></span> |
|
34 | 34 | <label class="form-field-container"> |
35 | 35 | <textarea name="description" class="form-field" rows="3" cols="20"><?php echo $payment_data['description']; ?></textarea> |
36 | 36 | </label> |
@@ -14,28 +14,28 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | |
20 | -<form class="wpeo-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="POST"> |
|
21 | - <input type="hidden" name="action" value="<?php echo esc_attr( 'wps_update_shipping_cost' ); ?>" /> |
|
20 | +<form class="wpeo-form" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="POST"> |
|
21 | + <input type="hidden" name="action" value="<?php echo esc_attr('wps_update_shipping_cost'); ?>" /> |
|
22 | 22 | <input type="hidden" name="tab" value="shipping_cost" /> |
23 | - <?php wp_nonce_field( 'callback_update_shipping_cost' ); ?> |
|
23 | + <?php wp_nonce_field('callback_update_shipping_cost'); ?> |
|
24 | 24 | |
25 | 25 | <div class="form-element"> |
26 | - <span class="form-label"><?php esc_html_e( 'Select shipping product', 'wpshop' ); ?></span> |
|
26 | + <span class="form-label"><?php esc_html_e('Select shipping product', 'wpshop'); ?></span> |
|
27 | 27 | <label class="form-field-container"> |
28 | 28 | <select name="shipping_product_id" class="form-field"> |
29 | 29 | <?php |
30 | - if ( ! empty( $products ) ) : |
|
31 | - foreach ( $products as $product ) : |
|
30 | + if (!empty($products)) : |
|
31 | + foreach ($products as $product) : |
|
32 | 32 | $selected = ''; |
33 | 33 | |
34 | - if ( $product->data['id'] == $shipping_cost_option['shipping_product_id'] ) : |
|
34 | + if ($product->data['id'] == $shipping_cost_option['shipping_product_id']) : |
|
35 | 35 | $selected = 'selected="selected"'; |
36 | 36 | endif; |
37 | 37 | ?> |
38 | - <option <?php echo $selected; ?> value="<?php echo esc_attr( $product->data['id'] ); ?>"><?php echo esc_html( $product->data['title'] ); ?></option> |
|
38 | + <option <?php echo $selected; ?> value="<?php echo esc_attr($product->data['id']); ?>"><?php echo esc_html($product->data['title']); ?></option> |
|
39 | 39 | <?php |
40 | 40 | endforeach; |
41 | 41 | endif; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | </div> |
46 | 46 | |
47 | 47 | <div class="form-element"> |
48 | - <span class="form-label"><?php esc_html_e( 'Free delivery starting from (€) HT', 'wpshop' ); ?></span> |
|
48 | + <span class="form-label"><?php esc_html_e('Free delivery starting from (€) HT', 'wpshop'); ?></span> |
|
49 | 49 | <label class="form-field-container"> |
50 | - <input type="text" name="from_price_ht" class="form-field" placeholder="00.00" value="<?php echo esc_attr( $shipping_cost_option['from_price_ht'] ); ?>" /> |
|
50 | + <input type="text" name="from_price_ht" class="form-field" placeholder="00.00" value="<?php echo esc_attr($shipping_cost_option['from_price_ht']); ?>" /> |
|
51 | 51 | </label> |
52 | 52 | </div> |
53 | 53 |
@@ -14,31 +14,31 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<form class="wpeo-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="POST"> |
|
20 | - <input type="hidden" name="action" value="<?php echo esc_attr( 'wps_update_general_settings' ); ?>" /> |
|
19 | +<form class="wpeo-form" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="POST"> |
|
20 | + <input type="hidden" name="action" value="<?php echo esc_attr('wps_update_general_settings'); ?>" /> |
|
21 | 21 | <input type="hidden" name="tab" value="general" /> |
22 | - <?php wp_nonce_field( 'callback_update_general_settings' ); ?> |
|
22 | + <?php wp_nonce_field('callback_update_general_settings'); ?> |
|
23 | 23 | |
24 | 24 | <div class="form-element"> |
25 | 25 | <span class="form-label">Dolibarr URL</span> |
26 | 26 | <label class="form-field-container"> |
27 | - <input type="text" class="form-field" name="dolibarr_url" value="<?php echo esc_attr( $dolibarr_option['dolibarr_url'] ); ?>" /> |
|
27 | + <input type="text" class="form-field" name="dolibarr_url" value="<?php echo esc_attr($dolibarr_option['dolibarr_url']); ?>" /> |
|
28 | 28 | </label> |
29 | 29 | </div> |
30 | 30 | |
31 | 31 | <div class="form-element"> |
32 | 32 | <span class="form-label">Dolibarr Secret</span> |
33 | 33 | <label class="form-field-container"> |
34 | - <input type="text" class="form-field" name="dolibarr_secret" value="<?php echo esc_attr( $dolibarr_option['dolibarr_secret'] ); ?>" /> |
|
34 | + <input type="text" class="form-field" name="dolibarr_secret" value="<?php echo esc_attr($dolibarr_option['dolibarr_secret']); ?>" /> |
|
35 | 35 | </label> |
36 | 36 | </div> |
37 | 37 | |
38 | 38 | <div class="form-element"> |
39 | 39 | <span class="form-label">Email de la boutique</span> |
40 | 40 | <label class="form-field-container"> |
41 | - <input type="text" class="form-field" name="shop_email" value="<?php echo esc_attr( $dolibarr_option['shop_email'] ); ?>" /> |
|
41 | + <input type="text" class="form-field" name="shop_email" value="<?php echo esc_attr($dolibarr_option['shop_email']); ?>" /> |
|
42 | 42 | </label> |
43 | 43 | </div> |
44 | 44 |
@@ -14,13 +14,13 @@ 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( 'Settings', 'wpshop' ); ?></h2> |
|
20 | + <h2><?php esc_html_e('Settings', 'wpshop'); ?></h2> |
|
21 | 21 | |
22 | 22 | <?php |
23 | - if ( ! empty( $transient ) ) : |
|
23 | + if (!empty($transient)) : |
|
24 | 24 | ?> |
25 | 25 | <div class="notice notice-success is-dismissible"> |
26 | 26 | <p><?php echo $transient; ?></p> |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | |
32 | 32 | <div class="wpeo-tab"> |
33 | 33 | <ul class="tab-list"> |
34 | - <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&tab=general' ) ); ?>" class="tab-element <?php echo ( 'general' === $tab ) ? 'tab-active' : ''; ?>"><?php esc_html_e( 'General', 'wpshop' ); ?></a> |
|
35 | - <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&tab=pages' ) ); ?>" class="tab-element <?php echo ( 'pages' === $tab ) ? 'tab-active' : ''; ?>"><?php esc_html_e( 'Pages', 'wpshop' ); ?></a> |
|
36 | - <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&tab=emails' ) ); ?>" class="tab-element <?php echo ( 'emails' === $tab ) ? 'tab-active' : ''; ?>"><?php esc_html_e( 'Emails', 'wpshop' ); ?></a> |
|
37 | - <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&tab=payment_method' ) ); ?>" class="tab-element <?php echo ( 'payment_method' === $tab ) ? 'tab-active' : ''; ?>"><?php esc_html_e( 'Payment method', 'wpshop' ); ?></a> |
|
38 | - <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce( 'callback_load_tab' ) . '&tab=shipping_cost' ) ); ?>" class="tab-element <?php echo ( 'shipping_cost' === $tab ) ? 'tab-active' : ''; ?>"><?php esc_html_e( 'Shipping cost', 'wpshop' ); ?></a> |
|
34 | + <a href="<?php echo esc_url(admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&tab=general')); ?>" class="tab-element <?php echo ('general' === $tab) ? 'tab-active' : ''; ?>"><?php esc_html_e('General', 'wpshop'); ?></a> |
|
35 | + <a href="<?php echo esc_url(admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&tab=pages')); ?>" class="tab-element <?php echo ('pages' === $tab) ? 'tab-active' : ''; ?>"><?php esc_html_e('Pages', 'wpshop'); ?></a> |
|
36 | + <a href="<?php echo esc_url(admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&tab=emails')); ?>" class="tab-element <?php echo ('emails' === $tab) ? 'tab-active' : ''; ?>"><?php esc_html_e('Emails', 'wpshop'); ?></a> |
|
37 | + <a href="<?php echo esc_url(admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&tab=payment_method')); ?>" class="tab-element <?php echo ('payment_method' === $tab) ? 'tab-active' : ''; ?>"><?php esc_html_e('Payment method', 'wpshop'); ?></a> |
|
38 | + <a href="<?php echo esc_url(admin_url('admin-post.php?action=wps_load_settings_tab&_wpnonce=' . wp_create_nonce('callback_load_tab') . '&tab=shipping_cost')); ?>" class="tab-element <?php echo ('shipping_cost' === $tab) ? 'tab-active' : ''; ?>"><?php esc_html_e('Shipping cost', 'wpshop'); ?></a> |
|
39 | 39 | </ul> |
40 | 40 | |
41 | 41 | <div class="tab-container"> |
42 | 42 | <div class="tab-content tab-active"> |
43 | - <?php call_user_func( array( Settings::g(), 'display_' . $tab ), $section ); ?> |
|
43 | + <?php call_user_func(array(Settings::g(), 'display_' . $tab), $section); ?> |
|
44 | 44 | </div> |
45 | 45 | </div> |
46 | 46 | </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 | * Emails Action Class. |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'admin_post_wps_copy_email_template', array( $this, 'callback_copy_email_template' ) ); |
|
30 | + add_action('admin_post_wps_copy_email_template', array($this, 'callback_copy_email_template')); |
|
31 | 31 | |
32 | - add_action( 'wps_email_order_details', array( $this, 'order_details' ) ); |
|
33 | - add_action( 'wps_email_order_details', array( $this, 'type_payment' ), 20, 1 ); |
|
32 | + add_action('wps_email_order_details', array($this, 'order_details')); |
|
33 | + add_action('wps_email_order_details', array($this, 'type_payment'), 20, 1); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | * @since 2.0.0 |
40 | 40 | */ |
41 | 41 | public function callback_copy_email_template() { |
42 | - check_admin_referer( 'callback_copy_email_template' ); |
|
42 | + check_admin_referer('callback_copy_email_template'); |
|
43 | 43 | |
44 | 44 | $tab = 'emails'; |
45 | - $section = ! empty( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : ''; |
|
46 | - $email = Emails::g()->emails[ $section ]; |
|
45 | + $section = !empty($_GET['section']) ? sanitize_text_field($_GET['section']) : ''; |
|
46 | + $email = Emails::g()->emails[$section]; |
|
47 | 47 | $file_to_copy = \eoxia\Config_Util::$init['wpshop']->emails->path . '/view/' . $email['filename_template']; |
48 | 48 | $path = get_template_directory() . '/wpshop/emails/view/' . $email['filename_template']; |
49 | 49 | |
50 | - if ( wp_mkdir_p( dirname( $path ) ) && ! file_exists( $path ) ) { |
|
51 | - copy( $file_to_copy, $path ); |
|
50 | + if (wp_mkdir_p(dirname($path)) && !file_exists($path)) { |
|
51 | + copy($file_to_copy, $path); |
|
52 | 52 | } |
53 | 53 | |
54 | - wp_redirect( admin_url( 'admin.php?page=wps-settings&tab= ' . $tab . '§ion=' . $section ) ); |
|
54 | + wp_redirect(admin_url('admin.php?page=wps-settings&tab= ' . $tab . '§ion=' . $section)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -64,29 +64,29 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param Order_Model $order Les données de la commande. |
66 | 66 | */ |
67 | - public function order_details( $order ) { |
|
67 | + public function order_details($order) { |
|
68 | 68 | $tva_lines = array(); |
69 | 69 | |
70 | - if ( ! empty( $order->lines ) ) { |
|
71 | - foreach ( $order->lines as &$line ) { |
|
72 | - if ( empty( $tva_lines[ $line->tva_tx ] ) ) { |
|
73 | - $tva_lines[ $line->tva_tx ] = 0; |
|
70 | + if (!empty($order->lines)) { |
|
71 | + foreach ($order->lines as &$line) { |
|
72 | + if (empty($tva_lines[$line->tva_tx])) { |
|
73 | + $tva_lines[$line->tva_tx] = 0; |
|
74 | 74 | } |
75 | 75 | |
76 | - $tva_lines[ $line->tva_tx ] += $line->total_tva; |
|
76 | + $tva_lines[$line->tva_tx] += $line->total_tva; |
|
77 | 77 | |
78 | - $wp_product = Product::g()->get( array( |
|
78 | + $wp_product = Product::g()->get(array( |
|
79 | 79 | 'meta_key' => '_external_id', |
80 | - 'meta_value' => (int) $line->fk_product, |
|
81 | - ), true ); |
|
80 | + 'meta_value' => (int)$line->fk_product, |
|
81 | + ), true); |
|
82 | 82 | |
83 | 83 | $line->wp_id = $wp_product->data['id']; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - unset( $line ); |
|
87 | + unset($line); |
|
88 | 88 | |
89 | - include( Template_Util::get_template_part( 'emails', 'order-details' ) ); |
|
89 | + include(Template_Util::get_template_part('emails', 'order-details')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param Order_Model $order Les données de la commande. |
101 | 101 | */ |
102 | - public function type_payment( $order ) { |
|
103 | - $payment_methods = get_option( 'wps_payment_methods', Payment::g()->default_options ); |
|
102 | + public function type_payment($order) { |
|
103 | + $payment_methods = get_option('wps_payment_methods', Payment::g()->default_options); |
|
104 | 104 | |
105 | - include( Template_Util::get_template_part( 'emails', 'type-payment' ) ); |
|
105 | + include(Template_Util::get_template_part('emails', 'type-payment')); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -16,37 +16,37 @@ |
||
16 | 16 | |
17 | 17 | namespace wpshop; |
18 | 18 | |
19 | -defined( 'ABSPATH' ) || exit; |
|
19 | +defined('ABSPATH') || exit; |
|
20 | 20 | |
21 | -do_action( 'wps_email_header' ); ?> |
|
21 | +do_action('wps_email_header'); ?> |
|
22 | 22 | |
23 | 23 | <p> |
24 | 24 | <?php |
25 | 25 | /* translators: %s Customer username */ |
26 | - printf( esc_html__( 'Hi %s,', 'wpshop' ), esc_html( $data['contact']['login'] ) ); |
|
26 | + printf(esc_html__('Hi %s,', 'wpshop'), esc_html($data['contact']['login'])); |
|
27 | 27 | ?> |
28 | 28 | </p> |
29 | 29 | <p> |
30 | 30 | <?php |
31 | 31 | /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ |
32 | - printf( __( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: <a target="_blank" href="%3$s">%4$s</a>', 'wpshop' ), array( |
|
32 | + printf(__('Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: <a target="_blank" href="%3$s">%4$s</a>', 'wpshop'), array( |
|
33 | 33 | get_bloginfo(), |
34 | - '<strong>' . esc_html( $data['contact']['login'] ) . '</strong>', |
|
35 | - esc_url( Pages::g()->get_account_link() ), |
|
34 | + '<strong>' . esc_html($data['contact']['login']) . '</strong>', |
|
35 | + esc_url(Pages::g()->get_account_link()), |
|
36 | 36 | get_bloginfo(), |
37 | - ) ); |
|
37 | + )); |
|
38 | 38 | ?> |
39 | 39 | </p> |
40 | 40 | |
41 | 41 | <p> |
42 | 42 | <?php |
43 | 43 | /* translators: Click here to create your password: <strong><a href="createpassword">Create my password</a></strong> */ |
44 | - printf( __( 'Click here to create your password: <strong><a href="%s">Create my password</a></strong>', 'wpshop' ), $data['url'] ); |
|
44 | + printf(__('Click here to create your password: <strong><a href="%s">Create my password</a></strong>', 'wpshop'), $data['url']); |
|
45 | 45 | ?> |
46 | 46 | </p> |
47 | 47 | |
48 | -<p><?php esc_html_e( 'We look forward to seeing you soon.', 'wpshop' ); ?></p> |
|
48 | +<p><?php esc_html_e('We look forward to seeing you soon.', 'wpshop'); ?></p> |
|
49 | 49 | |
50 | 50 | <?php |
51 | 51 | |
52 | -do_action( 'wps_email_footer' ); |
|
52 | +do_action('wps_email_footer'); |
@@ -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 Order Class. |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | * @since 2.0.0 |
82 | 82 | */ |
83 | 83 | public function display() { |
84 | - $orders = $this->get( array( |
|
84 | + $orders = $this->get(array( |
|
85 | 85 | 'orderby' => 'meta_value', |
86 | 86 | 'meta_key' => 'date_commande', |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - if ( ! empty( $orders ) ) { |
|
90 | - foreach ( $orders as &$element ) { |
|
91 | - $element->data['tier'] = Third_Party::g()->get( array( 'id' => $element->data['parent_id'] ), true ); |
|
89 | + if (!empty($orders)) { |
|
90 | + foreach ($orders as &$element) { |
|
91 | + $element->data['tier'] = Third_Party::g()->get(array('id' => $element->data['parent_id']), true); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'list', array( |
|
95 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'list', array( |
|
96 | 96 | 'orders' => $orders, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return Order_Model Les données de WP avec ceux de dolibarr. |
109 | 109 | */ |
110 | - public function doli_to_wp( $doli_order, $wp_order ) { |
|
111 | - $wp_order->data['external_id'] = (int) $doli_order->id; |
|
110 | + public function doli_to_wp($doli_order, $wp_order) { |
|
111 | + $wp_order->data['external_id'] = (int)$doli_order->id; |
|
112 | 112 | $wp_order->data['title'] = $doli_order->ref; |
113 | 113 | $wp_order->data['total_ht'] = $doli_order->total_ht; |
114 | 114 | $wp_order->data['total_ttc'] = $doli_order->total_ttc; |
115 | - $wp_order->data['billed'] = (int) $doli_order->billed; |
|
115 | + $wp_order->data['billed'] = (int)$doli_order->billed; |
|
116 | 116 | $wp_order->data['lines'] = $doli_order->lines; |
117 | - $wp_order->data['date_commande'] = date( 'Y-m-d H:i:s', $doli_order->date_commande ); |
|
118 | - $wp_order->data['datec'] = date( 'Y-m-d H:i:s', $doli_order->date_creation ); |
|
119 | - $wp_order->data['parent_id'] = Doli_Third_Parties::g()->get_wp_id_by_doli_id( $doli_order->socid ); |
|
120 | - $wp_order->data['payment_method'] = ( null === $doli_order->mode_reglement_code ) ? $doli_order->data['payment_method'] : Doli_Payment::g()->convert_to_wp( $doli_order->mode_reglement_code ); |
|
117 | + $wp_order->data['date_commande'] = date('Y-m-d H:i:s', $doli_order->date_commande); |
|
118 | + $wp_order->data['datec'] = date('Y-m-d H:i:s', $doli_order->date_creation); |
|
119 | + $wp_order->data['parent_id'] = Doli_Third_Parties::g()->get_wp_id_by_doli_id($doli_order->socid); |
|
120 | + $wp_order->data['payment_method'] = (null === $doli_order->mode_reglement_code) ? $doli_order->data['payment_method'] : Doli_Payment::g()->convert_to_wp($doli_order->mode_reglement_code); |
|
121 | 121 | |
122 | 122 | $status = ''; |
123 | 123 | |
124 | - switch ( $doli_order->statut ) { |
|
124 | + switch ($doli_order->statut) { |
|
125 | 125 | case -1: |
126 | 126 | $status = 'wps-canceled'; |
127 | 127 | break; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $wp_order->data['status'] = $status; |
145 | 145 | |
146 | - return Doli_Order::g()->update( $wp_order->data ); |
|
146 | + return Doli_Order::g()->update($wp_order->data); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | * @param integer $doli_id L'ID de dolibarr. |
155 | 155 | * @return integer L'ID de WP. |
156 | 156 | */ |
157 | - public function get_wp_id_by_doli_id( $doli_id ) { |
|
158 | - $order = Doli_Order::g()->get( array( |
|
157 | + public function get_wp_id_by_doli_id($doli_id) { |
|
158 | + $order = Doli_Order::g()->get(array( |
|
159 | 159 | 'meta_key' => '_external_id', |
160 | 160 | 'meta_value' => $doli_id, |
161 | - ), true ); |
|
161 | + ), true); |
|
162 | 162 | |
163 | 163 | return $order->data['id']; |
164 | 164 | } |
@@ -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 Order Action Class. |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'admin_init', array( $this, 'callback_admin_init' ) ); |
|
31 | - add_action( 'admin_menu', array( $this, 'callback_admin_menu' ) ); |
|
30 | + add_action('admin_init', array($this, 'callback_admin_init')); |
|
31 | + add_action('admin_menu', array($this, 'callback_admin_menu')); |
|
32 | 32 | |
33 | - add_action( 'wps_checkout_create_order', array( $this, 'create_order' ), 10, 1 ); |
|
34 | - add_action( 'wps_payment_complete', array( $this, 'set_to_billed' ), 30, 1 ); |
|
35 | - add_action( 'wps_payment_failed', array( $this, 'set_to_failed' ), 30, 1 ); |
|
33 | + add_action('wps_checkout_create_order', array($this, 'create_order'), 10, 1); |
|
34 | + add_action('wps_payment_complete', array($this, 'set_to_billed'), 30, 1); |
|
35 | + add_action('wps_payment_failed', array($this, 'set_to_failed'), 30, 1); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | * @since 2.0.0 |
42 | 42 | */ |
43 | 43 | public function callback_admin_init() { |
44 | - remove_post_type_support( 'wps-order', 'title' ); |
|
45 | - remove_post_type_support( 'wps-order', 'editor' ); |
|
46 | - remove_post_type_support( 'wps-order', 'excerpt' ); |
|
44 | + remove_post_type_support('wps-order', 'title'); |
|
45 | + remove_post_type_support('wps-order', 'editor'); |
|
46 | + remove_post_type_support('wps-order', 'excerpt'); |
|
47 | 47 | |
48 | - register_post_status( 'wps-delivered', array( |
|
49 | - 'label' => _x( 'Delivered', 'Order status', 'wpshop' ), |
|
48 | + register_post_status('wps-delivered', array( |
|
49 | + 'label' => _x('Delivered', 'Order status', 'wpshop'), |
|
50 | 50 | 'public' => false, |
51 | 51 | 'exclude_from_search' => false, |
52 | 52 | 'show_in_admin_all_list' => true, |
53 | 53 | 'show_in_admin_status_list' => true, |
54 | 54 | /* translators: %s: number of orders */ |
55 | - 'label_count' => _n_noop( 'Delivered <span class="count">(%s)</span>', 'Delivered <span class="count">(%s)</span>', 'wpshop' ), |
|
56 | - ) ); |
|
55 | + 'label_count' => _n_noop('Delivered <span class="count">(%s)</span>', 'Delivered <span class="count">(%s)</span>', 'wpshop'), |
|
56 | + )); |
|
57 | 57 | |
58 | - register_post_status( 'wps-canceled', array( |
|
59 | - 'label' => _x( 'Canceled', 'Order status', 'wpshop' ), |
|
58 | + register_post_status('wps-canceled', array( |
|
59 | + 'label' => _x('Canceled', 'Order status', 'wpshop'), |
|
60 | 60 | 'public' => false, |
61 | 61 | 'exclude_from_search' => false, |
62 | 62 | 'show_in_admin_all_list' => true, |
63 | 63 | 'show_in_admin_status_list' => true, |
64 | 64 | /* translators: %s: number of orders */ |
65 | - 'label_count' => _n_noop( 'Canceled <span class="count">(%s)</span>', 'Canceled <span class="count">(%s)</span>', 'wpshop' ), |
|
66 | - ) ); |
|
65 | + 'label_count' => _n_noop('Canceled <span class="count">(%s)</span>', 'Canceled <span class="count">(%s)</span>', 'wpshop'), |
|
66 | + )); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @since 2.0.0 |
73 | 73 | */ |
74 | 74 | public function callback_admin_menu() { |
75 | - add_submenu_page( 'wps-order', __( 'Orders', 'wpshop' ), __( 'Orders', 'wpshop' ), 'manage_options', 'wps-order', array( $this, 'callback_add_menu_page' ) ); |
|
75 | + add_submenu_page('wps-order', __('Orders', 'wpshop'), __('Orders', 'wpshop'), 'manage_options', 'wps-order', array($this, 'callback_add_menu_page')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | * @since 2.0.0 |
82 | 82 | */ |
83 | 83 | public function callback_add_menu_page() { |
84 | - if ( isset( $_GET['id'] ) ) { |
|
85 | - $order = Doli_Order::g()->get( array( 'id' => $_GET['id'] ), true ); |
|
84 | + if (isset($_GET['id'])) { |
|
85 | + $order = Doli_Order::g()->get(array('id' => $_GET['id']), true); |
|
86 | 86 | $args_metabox = array( |
87 | 87 | 'order' => $order, |
88 | 88 | 'id' => $_GET['id'], |
89 | 89 | ); |
90 | 90 | |
91 | 91 | /* translators: Order details CO00010 */ |
92 | - $box_order_detail_title = sprintf( __( 'Order details %s', 'wpshop' ), $order->data['title'] ); |
|
92 | + $box_order_detail_title = sprintf(__('Order details %s', 'wpshop'), $order->data['title']); |
|
93 | 93 | |
94 | - add_meta_box( 'wps-order-customer', $box_order_detail_title, array( $this, 'callback_meta_box' ), 'wps-order', 'normal', 'default', $args_metabox ); |
|
95 | - add_meta_box( 'wps-order-products', __( 'Products', 'wpshop' ), array( $this, 'callback_products' ), 'wps-order', 'normal', 'default', $args_metabox ); |
|
94 | + add_meta_box('wps-order-customer', $box_order_detail_title, array($this, 'callback_meta_box'), 'wps-order', 'normal', 'default', $args_metabox); |
|
95 | + add_meta_box('wps-order-products', __('Products', 'wpshop'), array($this, 'callback_products'), 'wps-order', 'normal', 'default', $args_metabox); |
|
96 | 96 | |
97 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'single', array( 'order' => $order ) ); |
|
97 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'single', array('order' => $order)); |
|
98 | 98 | } else { |
99 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'main' ); |
|
99 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'main'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | * @param WP_Post $post Les données du post. |
109 | 109 | * @param array $callback_args Tableau contenu les données de la commande. |
110 | 110 | */ |
111 | - public function callback_meta_box( $post, $callback_args ) { |
|
111 | + public function callback_meta_box($post, $callback_args) { |
|
112 | 112 | $order = $callback_args['args']['order']; |
113 | - $invoice = Doli_Invoice::g()->get( array( 'post_parent' => $order->data['id'] ), true ); |
|
114 | - $third_party = Third_Party::g()->get( array( 'id' => $order->data['parent_id'] ), true ); |
|
113 | + $invoice = Doli_Invoice::g()->get(array('post_parent' => $order->data['id']), true); |
|
114 | + $third_party = Third_Party::g()->get(array('id' => $order->data['parent_id']), true); |
|
115 | 115 | $link_invoice = ''; |
116 | 116 | |
117 | - if ( ! empty( $invoice ) ) { |
|
117 | + if (!empty($invoice)) { |
|
118 | 118 | $invoice->data['payments'] = array(); |
119 | - $invoice->data['payments'] = Doli_Payment::g()->get( array( 'post_parent' => $invoice->data['id'] ) ); |
|
120 | - $link_invoice = admin_url( 'admin-post.php?action=wps_download_invoice_wpnonce=' . wp_create_nonce( 'download_invoice' ) . '&order_id=' . $order->data['id'] ); |
|
119 | + $invoice->data['payments'] = Doli_Payment::g()->get(array('post_parent' => $invoice->data['id'])); |
|
120 | + $link_invoice = admin_url('admin-post.php?action=wps_download_invoice_wpnonce=' . wp_create_nonce('download_invoice') . '&order_id=' . $order->data['id']); |
|
121 | 121 | } |
122 | 122 | |
123 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'metabox-order-details', array( |
|
123 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'metabox-order-details', array( |
|
124 | 124 | 'order' => $order, |
125 | 125 | 'third_party' => $third_party, |
126 | 126 | 'invoice' => $invoice, |
127 | 127 | 'link_invoice' => $link_invoice, |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | * @param WP_Post $post Les données du post. |
137 | 137 | * @param array $callback_args Tableau contenu les données de la commande. |
138 | 138 | */ |
139 | - public function callback_products( $post, $callback_args ) { |
|
139 | + public function callback_products($post, $callback_args) { |
|
140 | 140 | $order = $callback_args['args']['order']; |
141 | 141 | |
142 | 142 | $tva_lines = array(); |
143 | 143 | |
144 | - if ( ! empty( $order->data['lines'] ) ) { |
|
145 | - foreach ( $order->data['lines'] as $line ) { |
|
146 | - if ( empty( $tva_lines[ $line['tva_tx'] ] ) ) { |
|
147 | - $tva_lines[ $line['tva_tx'] ] = 0; |
|
144 | + if (!empty($order->data['lines'])) { |
|
145 | + foreach ($order->data['lines'] as $line) { |
|
146 | + if (empty($tva_lines[$line['tva_tx']])) { |
|
147 | + $tva_lines[$line['tva_tx']] = 0; |
|
148 | 148 | } |
149 | 149 | |
150 | - $tva_lines[ $line['tva_tx'] ] += $line['total_tva']; |
|
150 | + $tva_lines[$line['tva_tx']] += $line['total_tva']; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'metabox-orders', array( |
|
154 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'metabox-orders', array( |
|
155 | 155 | 'order' => $order, |
156 | 156 | 'tva_lines' => $tva_lines, |
157 | - ) ); |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | * @param WP_Post $post Les données du post. |
166 | 166 | * @param array $callback_args Tableau contenu les données de la commande. |
167 | 167 | */ |
168 | - public function callback_order_action( $post, $callback_args ) { |
|
168 | + public function callback_order_action($post, $callback_args) { |
|
169 | 169 | $order = $callback_args['args']['order']; |
170 | 170 | |
171 | - \eoxia\View_Util::exec( 'wpshop', 'doli-order', 'metabox-action', array( |
|
171 | + \eoxia\View_Util::exec('wpshop', 'doli-order', 'metabox-action', array( |
|
172 | 172 | 'order' => $order, |
173 | - ) ); |
|
173 | + )); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -181,31 +181,31 @@ discard block |
||
181 | 181 | * @param stdClass $wp_proposal Les données du devis. |
182 | 182 | * @return Order_Model Les données de la commande WP. |
183 | 183 | */ |
184 | - public function create_order( $wp_proposal ) { |
|
185 | - $third_party = Third_Party::g()->get( array( 'id' => $wp_proposal->data['parent_id'] ), true ); |
|
186 | - $doli_proposal_id = get_post_meta( $wp_proposal->data['id'], '_external_id', true ); |
|
184 | + public function create_order($wp_proposal) { |
|
185 | + $third_party = Third_Party::g()->get(array('id' => $wp_proposal->data['parent_id']), true); |
|
186 | + $doli_proposal_id = get_post_meta($wp_proposal->data['id'], '_external_id', true); |
|
187 | 187 | |
188 | - $doli_order = Request_Util::post( 'orders/createfromproposal/' . $doli_proposal_id ); |
|
189 | - $doli_order = Request_Util::post( 'orders/' . $doli_order->id . '/validate' ); |
|
188 | + $doli_order = Request_Util::post('orders/createfromproposal/' . $doli_proposal_id); |
|
189 | + $doli_order = Request_Util::post('orders/' . $doli_order->id . '/validate'); |
|
190 | 190 | |
191 | - Emails::g()->send_mail( null, 'wps_email_new_order', array( |
|
191 | + Emails::g()->send_mail(null, 'wps_email_new_order', array( |
|
192 | 192 | 'order' => $doli_order, |
193 | 193 | 'third_party' => $third_party->data, |
194 | - ) ); |
|
194 | + )); |
|
195 | 195 | |
196 | 196 | $current_user = wp_get_current_user(); |
197 | 197 | |
198 | - Emails::g()->send_mail( $current_user->user_email, 'wps_email_customer_processing_order', array( |
|
198 | + Emails::g()->send_mail($current_user->user_email, 'wps_email_customer_processing_order', array( |
|
199 | 199 | 'order' => $doli_order, |
200 | 200 | 'third_party' => $third_party->data, |
201 | - ) ); |
|
201 | + )); |
|
202 | 202 | |
203 | - $wp_order = Doli_Order::g()->get( array( 'schema' => true ), true ); |
|
204 | - $wp_order = Doli_Order::g()->doli_to_wp( $doli_order, $wp_order ); |
|
203 | + $wp_order = Doli_Order::g()->get(array('schema' => true), true); |
|
204 | + $wp_order = Doli_Order::g()->doli_to_wp($doli_order, $wp_order); |
|
205 | 205 | |
206 | 206 | $wp_order->data['author_id'] = $current_user->ID; |
207 | 207 | |
208 | - return Doli_Order::g()->update( $wp_order->data ); |
|
208 | + return Doli_Order::g()->update($wp_order->data); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @param array $data Les données IPN de PayPal. |
217 | 217 | */ |
218 | - public function set_to_billed( $data ) { |
|
219 | - $wp_order = Doli_Order::g()->get( array( 'id' => (int) $data['custom'] ), true ); |
|
218 | + public function set_to_billed($data) { |
|
219 | + $wp_order = Doli_Order::g()->get(array('id' => (int)$data['custom']), true); |
|
220 | 220 | |
221 | - $doli_order = Request_Util::post( 'orders/' . $wp_order->data['external_id'] . '/setinvoiced' ); |
|
221 | + $doli_order = Request_Util::post('orders/' . $wp_order->data['external_id'] . '/setinvoiced'); |
|
222 | 222 | |
223 | - Doli_Order::g()->doli_to_wp( $doli_order, $wp_order ); |
|
223 | + Doli_Order::g()->doli_to_wp($doli_order, $wp_order); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param array $data Les données IPN de PayPal. |
232 | 232 | */ |
233 | - public function set_to_failed( $data ) { |
|
234 | - $wp_order = Doli_Order::g()->get( array( 'id' => (int) $data['custom'] ), true ); |
|
233 | + public function set_to_failed($data) { |
|
234 | + $wp_order = Doli_Order::g()->get(array('id' => (int)$data['custom']), true); |
|
235 | 235 | |
236 | 236 | $wp_order->data['payment_failed'] = true; |
237 | - Doli_Order::g()->update( $wp_order->data ); |
|
237 | + Doli_Order::g()->update($wp_order->data); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 |