@@ -1,19 +1,19 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wps-checkout-wrapper"> |
4 | 4 | <div class="wps-checkout-content"> |
5 | 5 | <?php echo do_shortcode('[wps_addresses]'); ?> |
6 | 6 | |
7 | 7 | <div id="wps-checkout-step-errors"></div> |
8 | - <?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?> |
|
9 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce( 'wps_checkout_valid_step_three' ); ?>" id="wps-checkout-valid-step-three"><?php _e( 'Validate my quotation', 'wpshop' ); ?></button></div> |
|
8 | + <?php if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') : ?> |
|
9 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce('wps_checkout_valid_step_three'); ?>" id="wps-checkout-valid-step-three"><?php _e('Validate my quotation', 'wpshop'); ?></button></div> |
|
10 | 10 | <?php else : ?> |
11 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce( 'wps_checkout_valid_step_three' ); ?>" id="wps-checkout-valid-step-three"><?php _e( 'Order', 'wpshop' ); ?></button></div> |
|
11 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce('wps_checkout_valid_step_three'); ?>" id="wps-checkout-valid-step-three"><?php _e('Order', 'wpshop'); ?></button></div> |
|
12 | 12 | <?php endif; ?> |
13 | 13 | </div> |
14 | 14 | <div class="wps-sidebar-resume"> |
15 | 15 | <input type="hidden" name="action" value="wps-checkout_valid_step_five"/> |
16 | - <?php wp_nonce_field( 'wps_checkout_valid_step_five' ); ?> |
|
17 | - <?php echo do_shortcode( '[wps_resume_cart]' ); ?> |
|
16 | + <?php wp_nonce_field('wps_checkout_valid_step_five'); ?> |
|
17 | + <?php echo do_shortcode('[wps_resume_cart]'); ?> |
|
18 | 18 | </div> |
19 | 19 | </div> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div class="wps-checkout-wrapper"> |
4 | 6 | <div class="wps-checkout-content"> |
@@ -7,8 +9,11 @@ discard block |
||
7 | 9 | <div id="wps-checkout-step-errors"></div> |
8 | 10 | <?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?> |
9 | 11 | <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce( 'wps_checkout_valid_step_three' ); ?>" id="wps-checkout-valid-step-three"><?php _e( 'Validate my quotation', 'wpshop' ); ?></button></div> |
10 | - <?php else : ?> |
|
11 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce( 'wps_checkout_valid_step_three' ); ?>" id="wps-checkout-valid-step-three"><?php _e( 'Order', 'wpshop' ); ?></button></div> |
|
12 | + <?php else { |
|
13 | + : ?> |
|
14 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" data-nonce="<?php echo wp_create_nonce( 'wps_checkout_valid_step_three' ); |
|
15 | +} |
|
16 | +?>" id="wps-checkout-valid-step-three"><?php _e( 'Order', 'wpshop' ); ?></button></div> |
|
12 | 17 | <?php endif; ?> |
13 | 18 | </div> |
14 | 19 | <div class="wps-sidebar-resume"> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * WP Shop Classic Checkout bootstrap file |
4 | 4 | * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]> |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( !class_exists("wps_classic_checkout") ) { |
|
11 | +if (!class_exists("wps_classic_checkout")) { |
|
12 | 12 | |
13 | 13 | /** Template Global vars **/ |
14 | 14 | DEFINE('WPS_CLASSIC_CHECKOUT_DIR', basename(dirname(__FILE__))); |
15 | - DEFINE('WPS_CLASSIC_CHECKOUT_PATH', str_replace( "\\", "/", str_replace( WPS_CLASSIC_CHECKOUT_DIR, "", dirname( __FILE__ ) ) ) ); |
|
16 | - DEFINE('WPS_CLASSIC_CHECKOUT_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPS_CLASSIC_CHECKOUT_PATH ) ); |
|
15 | + DEFINE('WPS_CLASSIC_CHECKOUT_PATH', str_replace("\\", "/", str_replace(WPS_CLASSIC_CHECKOUT_DIR, "", dirname(__FILE__)))); |
|
16 | + DEFINE('WPS_CLASSIC_CHECKOUT_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPS_CLASSIC_CHECKOUT_PATH)); |
|
17 | 17 | |
18 | 18 | |
19 | 19 | class wps_classic_checkout { |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | $this->template_dir = WPS_CLASSIC_CHECKOUT_PATH . WPS_CLASSIC_CHECKOUT_DIR . "/templates/"; |
36 | 36 | |
37 | 37 | /** Classic Checkout Shortcode **/ |
38 | - add_shortcode( 'wps_checkout', array( &$this, 'show_classic_checkout') ); |
|
39 | - add_shortcode( 'wpshop_checkout', array( &$this, 'show_classic_checkout') ); |
|
38 | + add_shortcode('wps_checkout', array(&$this, 'show_classic_checkout')); |
|
39 | + add_shortcode('wpshop_checkout', array(&$this, 'show_classic_checkout')); |
|
40 | 40 | /** Checkout Step indicator **/ |
41 | - add_shortcode('wps_checkout_step_indicator', array(&$this, 'get_checkout_step_indicator') ); |
|
41 | + add_shortcode('wps_checkout_step_indicator', array(&$this, 'get_checkout_step_indicator')); |
|
42 | 42 | |
43 | 43 | // Add scripts |
44 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts') ); |
|
44 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts')); |
|
45 | 45 | |
46 | 46 | /** Ajax Actions **/ |
47 | - add_action( 'wp_ajax_wps-checkout_valid_step_three', array( &$this, 'wps_checkout_valid_step_three') ); |
|
48 | - add_action( 'wp_ajax_wps-checkout_valid_step_four', array( &$this, 'wps_checkout_valid_step_four') ); |
|
49 | - add_action( 'wp_ajax_wps-checkout_valid_step_five', array( &$this, 'wps_checkout_valid_step_five') ); |
|
47 | + add_action('wp_ajax_wps-checkout_valid_step_three', array(&$this, 'wps_checkout_valid_step_three')); |
|
48 | + add_action('wp_ajax_wps-checkout_valid_step_four', array(&$this, 'wps_checkout_valid_step_four')); |
|
49 | + add_action('wp_ajax_wps-checkout_valid_step_five', array(&$this, 'wps_checkout_valid_step_five')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,151 +54,151 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function add_scripts() { |
56 | 56 | wp_enqueue_script('jquery'); |
57 | - wp_enqueue_script( 'wps_classic_checkout', plugins_url('templates/frontend/js/wps_classic_checkout.js', __FILE__) ); |
|
57 | + wp_enqueue_script('wps_classic_checkout', plugins_url('templates/frontend/js/wps_classic_checkout.js', __FILE__)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Display Classic Checkout |
62 | 62 | */ |
63 | 63 | function show_classic_checkout() { |
64 | - $action = !empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; |
|
65 | - $token = !empty( $_GET['token'] ) ? sanitize_text_field( $_GET['token'] ) : ''; |
|
66 | - $login = !empty( $_GET['login'] ) ? sanitize_text_field( $_GET['login'] ) : ''; |
|
67 | - $order_id = !empty( $_GET['order_id'] ) ? (int) $_GET['order_id'] : '';; |
|
64 | + $action = !empty($_GET['action']) ? sanitize_text_field($_GET['action']) : ''; |
|
65 | + $token = !empty($_GET['token']) ? sanitize_text_field($_GET['token']) : ''; |
|
66 | + $login = !empty($_GET['login']) ? sanitize_text_field($_GET['login']) : ''; |
|
67 | + $order_id = !empty($_GET['order_id']) ? (int)$_GET['order_id'] : ''; ; |
|
68 | 68 | |
69 | - if( !empty($action) && $action == 'direct_payment_link') { |
|
70 | - wpshop_checkout::direct_payment_link( $token, $order_id, $login); |
|
69 | + if (!empty($action) && $action == 'direct_payment_link') { |
|
70 | + wpshop_checkout::direct_payment_link($token, $order_id, $login); |
|
71 | 71 | } |
72 | 72 | |
73 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
74 | - $current_step = !empty( $_GET[ 'order_step' ] ) && is_int( (int)$_GET[ 'order_step' ] ) ? (int)$_GET[ 'order_step' ] : null; |
|
73 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
74 | + $current_step = !empty($_GET['order_step']) && is_int((int)$_GET['order_step']) ? (int)$_GET['order_step'] : null; |
|
75 | 75 | |
76 | 76 | /** Cas spécial lorsqu'il n'y a qu'un seul produit autorisé dans le panier / Special case when there is only one product allowed into cart */ |
77 | - if ( ( empty( $current_step ) || ( 1 == $current_step ) ) && ( !empty( $wpshop_cart_option ) && !empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) && ( 'yes' === $wpshop_cart_option[ 'total_nb_of_item_allowed' ][0] ) ) ) { |
|
78 | - if( empty($_SESSION) || empty($_SESSION['cart']) || empty($_SESSION['cart']['order_items']) ) { |
|
79 | - $product_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_product_page_id' ) ); |
|
80 | - $url = get_permalink( $product_page_id ); |
|
81 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
77 | + if ((empty($current_step) || (1 == $current_step)) && (!empty($wpshop_cart_option) && !empty($wpshop_cart_option['total_nb_of_item_allowed']) && ('yes' === $wpshop_cart_option['total_nb_of_item_allowed'][0]))) { |
|
78 | + if (empty($_SESSION) || empty($_SESSION['cart']) || empty($_SESSION['cart']['order_items'])) { |
|
79 | + $product_page_id = wpshop_tools::get_page_id(get_option('wpshop_product_page_id')); |
|
80 | + $url = get_permalink($product_page_id); |
|
81 | + wpshop_tools::wpshop_safe_redirect($url); |
|
82 | 82 | } |
83 | 83 | else { |
84 | 84 | $current_step = 2; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - $checkout_step_indicator = do_shortcode( '[wps_checkout_step_indicator]'); |
|
88 | + $checkout_step_indicator = do_shortcode('[wps_checkout_step_indicator]'); |
|
89 | 89 | $checkout_content = ''; |
90 | 90 | |
91 | - if ( !empty($current_step) ) { |
|
92 | - switch( $current_step) { |
|
91 | + if (!empty($current_step)) { |
|
92 | + switch ($current_step) { |
|
93 | 93 | case 1 : |
94 | 94 | ob_start(); |
95 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one") ); |
|
95 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one")); |
|
96 | 96 | $checkout_content .= ob_get_contents(); |
97 | 97 | ob_end_clean(); |
98 | 98 | break; |
99 | 99 | case 2 : |
100 | - if ( get_current_user_id() != 0 ) { |
|
101 | - $permalink_option = get_option( 'permalink_structure' ); |
|
102 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
103 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
104 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
100 | + if (get_current_user_id() != 0) { |
|
101 | + $permalink_option = get_option('permalink_structure'); |
|
102 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
103 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
104 | + wpshop_tools::wpshop_safe_redirect($url); |
|
105 | 105 | } |
106 | 106 | else { |
107 | 107 | ob_start(); |
108 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-two") ); |
|
108 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-two")); |
|
109 | 109 | $checkout_content .= ob_get_contents(); |
110 | 110 | ob_end_clean(); |
111 | 111 | } |
112 | 112 | break; |
113 | 113 | case 3 : |
114 | - if ( get_current_user_id() == 0 ) { |
|
115 | - $permalink_option = get_option( 'permalink_structure' ); |
|
116 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
117 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
118 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
114 | + if (get_current_user_id() == 0) { |
|
115 | + $permalink_option = get_option('permalink_structure'); |
|
116 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
117 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
118 | + wpshop_tools::wpshop_safe_redirect($url); |
|
119 | 119 | } |
120 | 120 | else { |
121 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
121 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
122 | 122 | ob_start(); |
123 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three") ); |
|
123 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three")); |
|
124 | 124 | $checkout_content .= ob_get_contents(); |
125 | 125 | ob_end_clean(); |
126 | - $url = apply_filters('wps_extra_signup_actions', ( isset( $url ) ? $url : '' ) ); |
|
127 | - if(!empty($url)) { |
|
128 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
126 | + $url = apply_filters('wps_extra_signup_actions', (isset($url) ? $url : '')); |
|
127 | + if (!empty($url)) { |
|
128 | + wpshop_tools::wpshop_safe_redirect($url); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | else { |
132 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
133 | - $url = get_permalink( $checkout_page_id ); |
|
134 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
132 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
133 | + $url = get_permalink($checkout_page_id); |
|
134 | + wpshop_tools::wpshop_safe_redirect($url); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | break; |
138 | 138 | case 4 : |
139 | - if ( get_current_user_id() == 0 ) { |
|
140 | - $permalink_option = get_option( 'permalink_structure' ); |
|
141 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
142 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
143 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
139 | + if (get_current_user_id() == 0) { |
|
140 | + $permalink_option = get_option('permalink_structure'); |
|
141 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
142 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
143 | + wpshop_tools::wpshop_safe_redirect($url); |
|
144 | 144 | } |
145 | 145 | else { |
146 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
146 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
147 | 147 | ob_start(); |
148 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four") ); |
|
148 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four")); |
|
149 | 149 | $checkout_content .= ob_get_contents(); |
150 | 150 | ob_end_clean(); |
151 | 151 | } |
152 | 152 | else { |
153 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
154 | - $url = get_permalink( $checkout_page_id ); |
|
155 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
153 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
154 | + $url = get_permalink($checkout_page_id); |
|
155 | + wpshop_tools::wpshop_safe_redirect($url); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | break; |
159 | 159 | case 5 : |
160 | - if ( get_current_user_id() == 0 ) { |
|
161 | - $permalink_option = get_option( 'permalink_structure' ); |
|
162 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
163 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
164 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
160 | + if (get_current_user_id() == 0) { |
|
161 | + $permalink_option = get_option('permalink_structure'); |
|
162 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
163 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
164 | + wpshop_tools::wpshop_safe_redirect($url); |
|
165 | 165 | } |
166 | 166 | else { |
167 | 167 | $wps_cart = new wps_cart(); |
168 | - $order = $wps_cart->calcul_cart_information( array() ); |
|
168 | + $order = $wps_cart->calcul_cart_information(array()); |
|
169 | 169 | $wps_cart->store_cart_in_session($order); |
170 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
171 | - if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && ( ( !empty($shipping_option) && !empty($shipping_option['activate']) && !empty($_SESSION['shipping_method']) ) || ( !empty($shipping_option) && empty($shipping_option['activate']) ) ) ) { |
|
172 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
170 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
171 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && ((!empty($shipping_option) && !empty($shipping_option['activate']) && !empty($_SESSION['shipping_method'])) || (!empty($shipping_option) && empty($shipping_option['activate'])))) { |
|
172 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
173 | 173 | ob_start(); |
174 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-five") ); |
|
174 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-five")); |
|
175 | 175 | $checkout_content .= ob_get_contents(); |
176 | 176 | ob_end_clean(); |
177 | - $checkout_content = apply_filters( 'classic_checkout_step_six_extra_content', $checkout_content ); |
|
177 | + $checkout_content = apply_filters('classic_checkout_step_six_extra_content', $checkout_content); |
|
178 | 178 | } |
179 | 179 | else { |
180 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
181 | - $url = get_permalink( $checkout_page_id ); |
|
182 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
180 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
181 | + $url = get_permalink($checkout_page_id); |
|
182 | + wpshop_tools::wpshop_safe_redirect($url); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | break; |
186 | 186 | case 6 : |
187 | 187 | |
188 | - if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ){ |
|
188 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
189 | 189 | $wps_marketing_tools_ctr = new wps_marketing_tools_ctr(); |
190 | - $checkout_content .= $wps_marketing_tools_ctr->display_ecommerce_ga_tracker( $_SESSION['order_id'] ); |
|
190 | + $checkout_content .= $wps_marketing_tools_ctr->display_ecommerce_ga_tracker($_SESSION['order_id']); |
|
191 | 191 | $checkout_content .= $this->wps_classic_confirmation_message(); |
192 | 192 | } |
193 | 193 | else { |
194 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
195 | - $url = get_permalink( $checkout_page_id ); |
|
196 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
194 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
195 | + $url = get_permalink($checkout_page_id); |
|
196 | + wpshop_tools::wpshop_safe_redirect($url); |
|
197 | 197 | } |
198 | 198 | break; |
199 | 199 | default : |
200 | 200 | ob_start(); |
201 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one") ); |
|
201 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one")); |
|
202 | 202 | $checkout_content .= ob_get_contents(); |
203 | 203 | ob_end_clean(); |
204 | 204 | break; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $checkout_content = do_shortcode('[wps_cart]'); |
210 | 210 | } |
211 | 211 | |
212 | - require_once( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic_checkout") ); |
|
212 | + require_once(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic_checkout")); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | function wps_classic_confirmation_message() { |
221 | 221 | $output = ''; |
222 | 222 | $wps_cart = new wps_cart(); |
223 | - $available_templates = array( 'banktransfer', 'checks', 'free', 'paypal', 'cic', 'quotation', 'cash_on_delivery' ); |
|
224 | - $payment_method = ( !empty($_SESSION['payment_method']) && in_array($_SESSION['payment_method'], $available_templates) ) ? $_SESSION['payment_method'] : 'others'; |
|
223 | + $available_templates = array('banktransfer', 'checks', 'free', 'paypal', 'cic', 'quotation', 'cash_on_delivery'); |
|
224 | + $payment_method = (!empty($_SESSION['payment_method']) && in_array($_SESSION['payment_method'], $available_templates)) ? $_SESSION['payment_method'] : 'others'; |
|
225 | 225 | ob_start(); |
226 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir,"frontend", "confirmation/confirmation", $payment_method) ); |
|
226 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "confirmation/confirmation", $payment_method)); |
|
227 | 227 | $output .= ob_get_contents(); |
228 | 228 | ob_end_clean(); |
229 | 229 | return $output; |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | * @return String |
235 | 235 | */ |
236 | 236 | function get_checkout_step_indicator() { |
237 | - $default_step = ( !empty( $_GET['order_step'] ) ) ? wpshop_tools::varSanitizer( $_GET['order_step'] ) : 1; |
|
237 | + $default_step = (!empty($_GET['order_step'])) ? wpshop_tools::varSanitizer($_GET['order_step']) : 1; |
|
238 | 238 | $steps = array(); |
239 | 239 | |
240 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
241 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
242 | - $permalink_option = get_option( 'permalink_structure' ); |
|
243 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
240 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
241 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
242 | + $permalink_option = get_option('permalink_structure'); |
|
243 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | $no_cart = false; |
247 | - if ( empty( $wpshop_cart_option ) || empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) || ( 'no' === $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) ) { |
|
247 | + if (empty($wpshop_cart_option) || empty($wpshop_cart_option['total_nb_of_item_allowed']) || ('no' === $wpshop_cart_option['total_nb_of_item_allowed'])) { |
|
248 | 248 | $steps[] = __('Cart', 'wpshop'); |
249 | 249 | } |
250 | 250 | else { |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $steps[] = __('Addresses', 'wpshop'); |
256 | 256 | |
257 | 257 | $no_shipping = false; |
258 | - if ( !empty( $shipping_address_option ) && !empty( $shipping_address_option[ 'activate' ] ) && !empty( $shipping_address_option[ 'choice' ] ) ) { |
|
258 | + if (!empty($shipping_address_option) && !empty($shipping_address_option['activate']) && !empty($shipping_address_option['choice'])) { |
|
259 | 259 | $steps[] = __('Shipping Mode', 'wpshop'); |
260 | 260 | } |
261 | 261 | else { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | $no_payment = false; |
266 | 266 | $partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
267 | - if( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && ( ( !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) || ( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' && isset( $partial_payment_for_quotation['for_quotation']['activate'] ) ) ) ) { |
|
267 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && ((!empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format($_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '') == '0.00') || (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' && isset($partial_payment_for_quotation['for_quotation']['activate'])))) { |
|
268 | 268 | $no_payment = true; |
269 | 269 | } |
270 | 270 | else { |
@@ -275,45 +275,45 @@ discard block |
||
275 | 275 | |
276 | 276 | $steps = apply_filters('wps_extra_action_checkout_indicator', $steps); |
277 | 277 | |
278 | - require_once( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir,"frontend", "checkout_step_indicator/checkout_step_indicator") ); |
|
278 | + require_once(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "checkout_step_indicator/checkout_step_indicator")); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
282 | 282 | * AJAX - Valid Checkout Step three |
283 | 283 | */ |
284 | 284 | function wps_checkout_valid_step_three() { |
285 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
285 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
286 | 286 | |
287 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) ) |
|
287 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_three')) |
|
288 | 288 | wp_die(); |
289 | 289 | |
290 | 290 | $response = ''; $status = true; |
291 | 291 | |
292 | - $shipping_address = ( !empty($_POST['shipping_address_id']) ) ? wpshop_tools::varSanitizer( $_POST['shipping_address_id'] ): null; |
|
293 | - $billing_address = ( !empty($_POST['billing_address_id']) ) ? wpshop_tools::varSanitizer( $_POST['billing_address_id'] ): null; |
|
292 | + $shipping_address = (!empty($_POST['shipping_address_id'])) ? wpshop_tools::varSanitizer($_POST['shipping_address_id']) : null; |
|
293 | + $billing_address = (!empty($_POST['billing_address_id'])) ? wpshop_tools::varSanitizer($_POST['billing_address_id']) : null; |
|
294 | 294 | |
295 | 295 | $user_id = get_current_user_id(); |
296 | 296 | |
297 | 297 | $response = '<div class="wps-alert-error"><ul>'; |
298 | 298 | |
299 | - if( $user_id != 0 ) { |
|
300 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
301 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
302 | - $user_addresses = wps_address::get_addresses_list( $user_id ); |
|
299 | + if ($user_id != 0) { |
|
300 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
301 | + $billing_option = get_option('wpshop_billing_address'); |
|
302 | + $user_addresses = wps_address::get_addresses_list($user_id); |
|
303 | 303 | |
304 | 304 | // Check if is only downloadable else display address |
305 | 305 | $cart_is_downloadable = false; |
306 | - if ( !empty( $_SESSION['cart'] ) && !empty( $_SESSION['cart']['order_items'] ) ) { |
|
307 | - foreach( $_SESSION['cart']['order_items'] as $c ) { |
|
308 | - $product = wpshop_products::get_product_data( $c['item_id'] ); |
|
306 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
307 | + foreach ($_SESSION['cart']['order_items'] as $c) { |
|
308 | + $product = wpshop_products::get_product_data($c['item_id']); |
|
309 | 309 | /** Check if it's a variation and check the parent product **/ |
310 | - if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
311 | - $parent_def = wpshop_products::get_parent_variation( $c['item_id'] ); |
|
312 | - if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) { |
|
310 | + if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
311 | + $parent_def = wpshop_products::get_parent_variation($c['item_id']); |
|
312 | + if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) { |
|
313 | 313 | $product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_']; |
314 | 314 | } |
315 | 315 | } |
316 | - if( !empty($product['is_downloadable_']) && ( __( $product['is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $product['is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) { |
|
316 | + if (!empty($product['is_downloadable_']) && (__($product['is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($product['is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) { |
|
317 | 317 | $cart_is_downloadable = true; |
318 | 318 | } else { |
319 | 319 | $cart_is_downloadable = false; |
@@ -322,90 +322,90 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if( !empty($shipping_option) && !empty($shipping_option['activate']) && !$cart_is_downloadable ) { |
|
325 | + if (!empty($shipping_option) && !empty($shipping_option['activate']) && !$cart_is_downloadable) { |
|
326 | 326 | /** Check Shipping address **/ |
327 | - if ( empty($shipping_address) ) { |
|
327 | + if (empty($shipping_address)) { |
|
328 | 328 | $status = false; |
329 | 329 | /** Check if user have already create a shipping address **/ |
330 | - if ( !empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $shipping_option['choice'] ]) ){ |
|
331 | - $response .= '<li>'.__( 'You must select a shipping address', 'wpshop' ).'</li>'; |
|
330 | + if (!empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[$shipping_option['choice']])) { |
|
331 | + $response .= '<li>' . __('You must select a shipping address', 'wpshop') . '</li>'; |
|
332 | 332 | } |
333 | 333 | else { |
334 | - $response .= '<li>'.__( 'You must create a shipping address', 'wpshop' ).'</li>'; |
|
334 | + $response .= '<li>' . __('You must create a shipping address', 'wpshop') . '</li>'; |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | 338 | } |
339 | 339 | /** Check Billing address **/ |
340 | - if( empty($billing_address) ) { |
|
340 | + if (empty($billing_address)) { |
|
341 | 341 | $status = false; |
342 | - if ( !empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $billing_option['choice'] ]) ){ |
|
343 | - $response .= '<li>'.__( 'You must select a billing address', 'wpshop' ).'</li>'; |
|
342 | + if (!empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[$billing_option['choice']])) { |
|
343 | + $response .= '<li>' . __('You must select a billing address', 'wpshop') . '</li>'; |
|
344 | 344 | } |
345 | 345 | else { |
346 | - $response .= '<li>'.__( 'You must create a billing address', 'wpshop' ).'</li>'; |
|
346 | + $response .= '<li>' . __('You must create a billing address', 'wpshop') . '</li>'; |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | 350 | else { |
351 | 351 | $status = false; |
352 | - $response .= '<li>'.__( 'You must be logged to pass to next step', 'wpshop' ).'</li>'; |
|
352 | + $response .= '<li>' . __('You must be logged to pass to next step', 'wpshop') . '</li>'; |
|
353 | 353 | } |
354 | 354 | $response .= '</ul></div>'; |
355 | 355 | |
356 | 356 | /** If no error **/ |
357 | - if( $status ) { |
|
357 | + if ($status) { |
|
358 | 358 | $_SESSION['shipping_address'] = $shipping_address; |
359 | 359 | $_SESSION['billing_address'] = $billing_address; |
360 | 360 | |
361 | - $permalink_option = get_option( 'permalink_structure' ); |
|
362 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
361 | + $permalink_option = get_option('permalink_structure'); |
|
362 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
363 | 363 | /** Checking if no shipping method is required and it is a quotation or a free order **/ |
364 | - $shipping_option = get_option( 'wps_shipping_mode' ); |
|
364 | + $shipping_option = get_option('wps_shipping_mode'); |
|
365 | 365 | $available_shipping_method = false; |
366 | - if( !empty($shipping_option) && !empty($shipping_option['modes']) && !$cart_is_downloadable ) { |
|
367 | - foreach( $shipping_option['modes'] as $shipping_mode_id => $shipping_mode ) { |
|
368 | - if( !empty($shipping_mode['active']) && $shipping_mode['active'] == 'on' ) { |
|
366 | + if (!empty($shipping_option) && !empty($shipping_option['modes']) && !$cart_is_downloadable) { |
|
367 | + foreach ($shipping_option['modes'] as $shipping_mode_id => $shipping_mode) { |
|
368 | + if (!empty($shipping_mode['active']) && $shipping_mode['active'] == 'on') { |
|
369 | 369 | $available_shipping_method = true; |
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
374 | - if( !$available_shipping_method ) { |
|
374 | + if (!$available_shipping_method) { |
|
375 | 375 | $_SESSION['shipping_method'] = 'No Shipping method required'; |
376 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
376 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
377 | 377 | |
378 | - if ( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
378 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
379 | 379 | $status = true; |
380 | 380 | $payment_method = $_SESSION['payment_method'] = 'quotation'; |
381 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
382 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
381 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
382 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
383 | 383 | } |
384 | - elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && isset($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
384 | + elseif (!empty($_SESSION) && !empty($_SESSION['cart']) && isset($_SESSION['cart']['order_amount_to_pay_now']) && number_format($_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '') == '0.00') { |
|
385 | 385 | $status = true; |
386 | 386 | $payment_method = $_SESSION['payment_method'] = 'free'; |
387 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
388 | - $permalink_option = get_option( 'permalink_structure' ); |
|
389 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
390 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
387 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
388 | + $permalink_option = get_option('permalink_structure'); |
|
389 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
390 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
391 | 391 | // wpshop_tools::wpshop_safe_redirect( $url ); |
392 | 392 | $response = $url; |
393 | 393 | } |
394 | 394 | else { |
395 | 395 | $status = true; |
396 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
|
396 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=5'; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | else { |
400 | 400 | $status = true; |
401 | - $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=4'; |
|
401 | + $response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=4'; |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | //Stock checking verification |
405 | 405 | $this->checking_stock(); |
406 | 406 | |
407 | 407 | |
408 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
408 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
409 | 409 | die(); |
410 | 410 | } |
411 | 411 | |
@@ -413,51 +413,51 @@ discard block |
||
413 | 413 | * AJAX - Valid Checkout step four |
414 | 414 | */ |
415 | 415 | function wps_checkout_valid_step_four() { |
416 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
416 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
417 | 417 | |
418 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) ) |
|
418 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_four')) |
|
419 | 419 | wp_die(); |
420 | 420 | |
421 | - $shipping_method = ( !empty($_POST['shipping_mode']) ) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null; |
|
421 | + $shipping_method = (!empty($_POST['shipping_mode'])) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null; |
|
422 | 422 | $status = false; |
423 | 423 | $response = ''; |
424 | - $permalink_option = get_option( 'permalink_structure' ); |
|
425 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
426 | - if ( !empty($shipping_method) ) { |
|
424 | + $permalink_option = get_option('permalink_structure'); |
|
425 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
426 | + if (!empty($shipping_method)) { |
|
427 | 427 | $status = true; |
428 | 428 | $_SESSION['shipping_method'] = $shipping_method; |
429 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
430 | - if ( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
429 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
430 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
431 | 431 | $partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
432 | - if( isset( $partial_payment_for_quotation['for_quotation']['activate'] ) ) { |
|
432 | + if (isset($partial_payment_for_quotation['for_quotation']['activate'])) { |
|
433 | 433 | $step = '5'; |
434 | 434 | } else { |
435 | 435 | $payment_method = $_SESSION['payment_method'] = 'quotation'; |
436 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
436 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
437 | 437 | $step = '6'; |
438 | 438 | } |
439 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step; |
|
439 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=' . $step; |
|
440 | 440 | } |
441 | - elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
441 | + elseif (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format($_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '') == '0.00') { |
|
442 | 442 | $payment_method = $_SESSION['payment_method'] = 'free'; |
443 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
444 | - $permalink_option = get_option( 'permalink_structure' ); |
|
445 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
446 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
443 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
444 | + $permalink_option = get_option('permalink_structure'); |
|
445 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
446 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
447 | 447 | $response = $url; |
448 | 448 | } |
449 | 449 | else { |
450 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
|
450 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=5'; |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | else { |
454 | - $response .= '<div class="wps-alert-error">'.__( 'You must select a shipping method', 'wpshop' ).'</div>'; |
|
454 | + $response .= '<div class="wps-alert-error">' . __('You must select a shipping method', 'wpshop') . '</div>'; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | //Stock checking verification |
458 | 458 | $this->checking_stock(); |
459 | 459 | |
460 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
460 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
461 | 461 | die(); |
462 | 462 | } |
463 | 463 | |
@@ -465,45 +465,45 @@ discard block |
||
465 | 465 | * AJAX - Valid Checkout step four |
466 | 466 | */ |
467 | 467 | function wps_checkout_valid_step_five() { |
468 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
468 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
469 | 469 | |
470 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) ) |
|
470 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_five')) |
|
471 | 471 | wp_die(); |
472 | 472 | |
473 | 473 | $status = false; $response = ''; |
474 | - $payment_method = ( !empty($_POST['wps-payment-method']) ) ? wpshop_tools::varSanitizer( $_POST['wps-payment-method'] ): null; |
|
475 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
476 | - $customer_comment = ( !empty($_POST['wps-customer-comment']) ) ? wpshop_tools::varSanitizer( $_POST['wps-customer-comment'] ) : null; |
|
477 | - $terms_of_sale_indicator = !empty( $_POST['terms_of_sale_indicator'] ) ? sanitize_text_field( $_POST['terms_of_sale_indicator'] ) : ''; |
|
478 | - $terms_of_sale = !empty( $_POST['terms_of_sale'] ) ? sanitize_text_field( $_POST['terms_of_sale'] ) : ''; |
|
474 | + $payment_method = (!empty($_POST['wps-payment-method'])) ? wpshop_tools::varSanitizer($_POST['wps-payment-method']) : null; |
|
475 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
476 | + $customer_comment = (!empty($_POST['wps-customer-comment'])) ? wpshop_tools::varSanitizer($_POST['wps-customer-comment']) : null; |
|
477 | + $terms_of_sale_indicator = !empty($_POST['terms_of_sale_indicator']) ? sanitize_text_field($_POST['terms_of_sale_indicator']) : ''; |
|
478 | + $terms_of_sale = !empty($_POST['terms_of_sale']) ? sanitize_text_field($_POST['terms_of_sale']) : ''; |
|
479 | 479 | |
480 | - $terms_of_sale_checking = ( ( isset($terms_of_sale_indicator) && !empty($terms_of_sale) ) || ( !empty($terms_of_sale) ) || ( !isset($terms_of_sale_indicator) && empty($terms_of_sale) ) ) ? true : false; |
|
480 | + $terms_of_sale_checking = ((isset($terms_of_sale_indicator) && !empty($terms_of_sale)) || (!empty($terms_of_sale)) || (!isset($terms_of_sale_indicator) && empty($terms_of_sale))) ? true : false; |
|
481 | 481 | |
482 | 482 | if ($terms_of_sale_checking) { |
483 | - if ( !empty($payment_method) ) { |
|
483 | + if (!empty($payment_method)) { |
|
484 | 484 | /** Check if the payment method exist for the shop **/ |
485 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
485 | + $payment_option = get_option('wps_payment_mode'); |
|
486 | 486 | |
487 | - if( !empty($payment_option) && !empty($payment_option['mode']) && array_key_exists( $payment_method, $payment_option['mode']) && !empty($payment_option['mode'][$payment_method]['active']) ) { |
|
488 | - if( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) { |
|
487 | + if (!empty($payment_option) && !empty($payment_option['mode']) && array_key_exists($payment_method, $payment_option['mode']) && !empty($payment_option['mode'][$payment_method]['active'])) { |
|
488 | + if (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
489 | 489 | $new_payment_method = $payment_method; |
490 | 490 | $payment_method = 'quotation'; |
491 | 491 | $is_quotation = true; |
492 | 492 | } else { |
493 | 493 | $is_quotation = false; |
494 | 494 | } |
495 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
496 | - if( !empty($order_id) && !empty($customer_comment) ) { |
|
497 | - wp_update_post( array('ID' => $order_id, 'post_excerpt' => $customer_comment) ); |
|
495 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
496 | + if (!empty($order_id) && !empty($customer_comment)) { |
|
497 | + wp_update_post(array('ID' => $order_id, 'post_excerpt' => $customer_comment)); |
|
498 | 498 | } |
499 | - $permalink_option = get_option( 'permalink_structure' ); |
|
500 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
501 | - $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
502 | - if( $is_quotation ) { |
|
503 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
504 | - $params = array( 'method' => $new_payment_method, 'waited_amount' => $order_meta['order_partial_payment'], 'status' => 'waiting_payment', 'author' => get_current_user_id() ); |
|
499 | + $permalink_option = get_option('permalink_structure'); |
|
500 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
501 | + $response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
502 | + if ($is_quotation) { |
|
503 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
504 | + $params = array('method' => $new_payment_method, 'waited_amount' => $order_meta['order_partial_payment'], 'status' => 'waiting_payment', 'author' => get_current_user_id()); |
|
505 | 505 | $order_meta['order_payment']['received'][0] = $params; |
506 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
506 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
507 | 507 | $_SESSION['payment_method'] = $new_payment_method; |
508 | 508 | } else { |
509 | 509 | $_SESSION['payment_method'] = $payment_method; |
@@ -512,21 +512,21 @@ discard block |
||
512 | 512 | //Add an action to extra actions on order save |
513 | 513 | // @TODO : REQUEST |
514 | 514 | // $args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST); |
515 | - wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args ); |
|
515 | + wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args); |
|
516 | 516 | } |
517 | 517 | else { |
518 | - $response = '<div class="wps-alert-error">' .__( 'This payment method is unavailable', 'wpshop' ).'</div>'; |
|
518 | + $response = '<div class="wps-alert-error">' . __('This payment method is unavailable', 'wpshop') . '</div>'; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | else { |
522 | - $response = '<div class="wps-alert-error">' .__( 'You must choose a payment method', 'wpshop' ).'</div>'; |
|
522 | + $response = '<div class="wps-alert-error">' . __('You must choose a payment method', 'wpshop') . '</div>'; |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | else { |
526 | - $response = '<div class="wps-alert-error">' .__( 'You must accept the terms of sale to order', 'wpshop' ).'</div>'; |
|
526 | + $response = '<div class="wps-alert-error">' . __('You must accept the terms of sale to order', 'wpshop') . '</div>'; |
|
527 | 527 | } |
528 | 528 | |
529 | - echo json_encode( array('status' => $status, 'response' => $response) ); |
|
529 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
530 | 530 | die(); |
531 | 531 | } |
532 | 532 | |
@@ -534,15 +534,15 @@ discard block |
||
534 | 534 | * Checking stock in differents checkout steps |
535 | 535 | */ |
536 | 536 | function checking_stock() { |
537 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
538 | - foreach( $_SESSION['cart']['order_items'] as $item_id => $item ) { |
|
537 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
538 | + foreach ($_SESSION['cart']['order_items'] as $item_id => $item) { |
|
539 | 539 | $wps_product = new wps_product_ctr(); |
540 | - $checking = $wps_product->check_stock( $item['item_id'], $item['item_qty'], $item_id ); |
|
541 | - if( $checking !== true ) { |
|
542 | - unset( $_SESSION['cart']['order_items'][$item_id] ); |
|
540 | + $checking = $wps_product->check_stock($item['item_id'], $item['item_qty'], $item_id); |
|
541 | + if ($checking !== true) { |
|
542 | + unset($_SESSION['cart']['order_items'][$item_id]); |
|
543 | 543 | $wps_cart_ctr = new wps_cart(); |
544 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
545 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
544 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
545 | + $wps_cart_ctr->store_cart_in_session($order); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | } |
@@ -550,6 +550,6 @@ discard block |
||
550 | 550 | |
551 | 551 | } |
552 | 552 | } |
553 | -if ( class_exists("wps_classic_checkout") ) { |
|
553 | +if (class_exists("wps_classic_checkout")) { |
|
554 | 554 | $wps_classic_checkout = new wps_classic_checkout(); |
555 | 555 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * WP Shop Classic Checkout bootstrap file |
4 | 6 | * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]> |
@@ -79,8 +81,7 @@ discard block |
||
79 | 81 | $product_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_product_page_id' ) ); |
80 | 82 | $url = get_permalink( $product_page_id ); |
81 | 83 | wpshop_tools::wpshop_safe_redirect( $url ); |
82 | - } |
|
83 | - else { |
|
84 | + } else { |
|
84 | 85 | $current_step = 2; |
85 | 86 | } |
86 | 87 | } |
@@ -102,8 +103,7 @@ discard block |
||
102 | 103 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
103 | 104 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
104 | 105 | wpshop_tools::wpshop_safe_redirect( $url ); |
105 | - } |
|
106 | - else { |
|
106 | + } else { |
|
107 | 107 | ob_start(); |
108 | 108 | require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-two") ); |
109 | 109 | $checkout_content .= ob_get_contents(); |
@@ -116,8 +116,7 @@ discard block |
||
116 | 116 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
117 | 117 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
118 | 118 | wpshop_tools::wpshop_safe_redirect( $url ); |
119 | - } |
|
120 | - else { |
|
119 | + } else { |
|
121 | 120 | if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
122 | 121 | ob_start(); |
123 | 122 | require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three") ); |
@@ -127,8 +126,7 @@ discard block |
||
127 | 126 | if(!empty($url)) { |
128 | 127 | wpshop_tools::wpshop_safe_redirect( $url ); |
129 | 128 | } |
130 | - } |
|
131 | - else { |
|
129 | + } else { |
|
132 | 130 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
133 | 131 | $url = get_permalink( $checkout_page_id ); |
134 | 132 | wpshop_tools::wpshop_safe_redirect( $url ); |
@@ -141,15 +139,13 @@ discard block |
||
141 | 139 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
142 | 140 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
143 | 141 | wpshop_tools::wpshop_safe_redirect( $url ); |
144 | - } |
|
145 | - else { |
|
142 | + } else { |
|
146 | 143 | if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
147 | 144 | ob_start(); |
148 | 145 | require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four") ); |
149 | 146 | $checkout_content .= ob_get_contents(); |
150 | 147 | ob_end_clean(); |
151 | - } |
|
152 | - else { |
|
148 | + } else { |
|
153 | 149 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
154 | 150 | $url = get_permalink( $checkout_page_id ); |
155 | 151 | wpshop_tools::wpshop_safe_redirect( $url ); |
@@ -162,8 +158,7 @@ discard block |
||
162 | 158 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
163 | 159 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
164 | 160 | wpshop_tools::wpshop_safe_redirect( $url ); |
165 | - } |
|
166 | - else { |
|
161 | + } else { |
|
167 | 162 | $wps_cart = new wps_cart(); |
168 | 163 | $order = $wps_cart->calcul_cart_information( array() ); |
169 | 164 | $wps_cart->store_cart_in_session($order); |
@@ -175,8 +170,7 @@ discard block |
||
175 | 170 | $checkout_content .= ob_get_contents(); |
176 | 171 | ob_end_clean(); |
177 | 172 | $checkout_content = apply_filters( 'classic_checkout_step_six_extra_content', $checkout_content ); |
178 | - } |
|
179 | - else { |
|
173 | + } else { |
|
180 | 174 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
181 | 175 | $url = get_permalink( $checkout_page_id ); |
182 | 176 | wpshop_tools::wpshop_safe_redirect( $url ); |
@@ -189,8 +183,7 @@ discard block |
||
189 | 183 | $wps_marketing_tools_ctr = new wps_marketing_tools_ctr(); |
190 | 184 | $checkout_content .= $wps_marketing_tools_ctr->display_ecommerce_ga_tracker( $_SESSION['order_id'] ); |
191 | 185 | $checkout_content .= $this->wps_classic_confirmation_message(); |
192 | - } |
|
193 | - else { |
|
186 | + } else { |
|
194 | 187 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
195 | 188 | $url = get_permalink( $checkout_page_id ); |
196 | 189 | wpshop_tools::wpshop_safe_redirect( $url ); |
@@ -204,8 +197,7 @@ discard block |
||
204 | 197 | break; |
205 | 198 | } |
206 | 199 | |
207 | - } |
|
208 | - else { |
|
200 | + } else { |
|
209 | 201 | $checkout_content = do_shortcode('[wps_cart]'); |
210 | 202 | } |
211 | 203 | |
@@ -246,8 +238,7 @@ discard block |
||
246 | 238 | $no_cart = false; |
247 | 239 | if ( empty( $wpshop_cart_option ) || empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) || ( 'no' === $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) ) { |
248 | 240 | $steps[] = __('Cart', 'wpshop'); |
249 | - } |
|
250 | - else { |
|
241 | + } else { |
|
251 | 242 | $no_cart = true; |
252 | 243 | } |
253 | 244 | |
@@ -257,8 +248,7 @@ discard block |
||
257 | 248 | $no_shipping = false; |
258 | 249 | if ( !empty( $shipping_address_option ) && !empty( $shipping_address_option[ 'activate' ] ) && !empty( $shipping_address_option[ 'choice' ] ) ) { |
259 | 250 | $steps[] = __('Shipping Mode', 'wpshop'); |
260 | - } |
|
261 | - else { |
|
251 | + } else { |
|
262 | 252 | $no_shipping = true; |
263 | 253 | } |
264 | 254 | |
@@ -266,8 +256,7 @@ discard block |
||
266 | 256 | $partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
267 | 257 | if( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && ( ( !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) || ( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' && isset( $partial_payment_for_quotation['for_quotation']['activate'] ) ) ) ) { |
268 | 258 | $no_payment = true; |
269 | - } |
|
270 | - else { |
|
259 | + } else { |
|
271 | 260 | $steps[] = __('Payment', 'wpshop'); |
272 | 261 | } |
273 | 262 | |
@@ -284,8 +273,9 @@ discard block |
||
284 | 273 | function wps_checkout_valid_step_three() { |
285 | 274 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
286 | 275 | |
287 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) ) |
|
288 | - wp_die(); |
|
276 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) ) { |
|
277 | + wp_die(); |
|
278 | + } |
|
289 | 279 | |
290 | 280 | $response = ''; $status = true; |
291 | 281 | |
@@ -329,8 +319,7 @@ discard block |
||
329 | 319 | /** Check if user have already create a shipping address **/ |
330 | 320 | if ( !empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $shipping_option['choice'] ]) ){ |
331 | 321 | $response .= '<li>'.__( 'You must select a shipping address', 'wpshop' ).'</li>'; |
332 | - } |
|
333 | - else { |
|
322 | + } else { |
|
334 | 323 | $response .= '<li>'.__( 'You must create a shipping address', 'wpshop' ).'</li>'; |
335 | 324 | } |
336 | 325 | } |
@@ -341,13 +330,11 @@ discard block |
||
341 | 330 | $status = false; |
342 | 331 | if ( !empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $billing_option['choice'] ]) ){ |
343 | 332 | $response .= '<li>'.__( 'You must select a billing address', 'wpshop' ).'</li>'; |
344 | - } |
|
345 | - else { |
|
333 | + } else { |
|
346 | 334 | $response .= '<li>'.__( 'You must create a billing address', 'wpshop' ).'</li>'; |
347 | 335 | } |
348 | 336 | } |
349 | - } |
|
350 | - else { |
|
337 | + } else { |
|
351 | 338 | $status = false; |
352 | 339 | $response .= '<li>'.__( 'You must be logged to pass to next step', 'wpshop' ).'</li>'; |
353 | 340 | } |
@@ -380,8 +367,7 @@ discard block |
||
380 | 367 | $payment_method = $_SESSION['payment_method'] = 'quotation'; |
381 | 368 | $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
382 | 369 | $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
383 | - } |
|
384 | - elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && isset($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
370 | + } elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && isset($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
385 | 371 | $status = true; |
386 | 372 | $payment_method = $_SESSION['payment_method'] = 'free'; |
387 | 373 | $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
@@ -390,13 +376,11 @@ discard block |
||
390 | 376 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
391 | 377 | // wpshop_tools::wpshop_safe_redirect( $url ); |
392 | 378 | $response = $url; |
393 | - } |
|
394 | - else { |
|
379 | + } else { |
|
395 | 380 | $status = true; |
396 | 381 | $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
397 | 382 | } |
398 | - } |
|
399 | - else { |
|
383 | + } else { |
|
400 | 384 | $status = true; |
401 | 385 | $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=4'; |
402 | 386 | } |
@@ -415,8 +399,9 @@ discard block |
||
415 | 399 | function wps_checkout_valid_step_four() { |
416 | 400 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
417 | 401 | |
418 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) ) |
|
419 | - wp_die(); |
|
402 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) ) { |
|
403 | + wp_die(); |
|
404 | + } |
|
420 | 405 | |
421 | 406 | $shipping_method = ( !empty($_POST['shipping_mode']) ) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null; |
422 | 407 | $status = false; |
@@ -437,20 +422,17 @@ discard block |
||
437 | 422 | $step = '6'; |
438 | 423 | } |
439 | 424 | $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step; |
440 | - } |
|
441 | - elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
425 | + } elseif( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['order_amount_to_pay_now']) && number_format( $_SESSION['cart']['order_amount_to_pay_now'], 2, '.', '' ) == '0.00' ) { |
|
442 | 426 | $payment_method = $_SESSION['payment_method'] = 'free'; |
443 | 427 | $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
444 | 428 | $permalink_option = get_option( 'permalink_structure' ); |
445 | 429 | $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
446 | 430 | $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
447 | 431 | $response = $url; |
448 | - } |
|
449 | - else { |
|
432 | + } else { |
|
450 | 433 | $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
451 | 434 | } |
452 | - } |
|
453 | - else { |
|
435 | + } else { |
|
454 | 436 | $response .= '<div class="wps-alert-error">'.__( 'You must select a shipping method', 'wpshop' ).'</div>'; |
455 | 437 | } |
456 | 438 | |
@@ -467,8 +449,9 @@ discard block |
||
467 | 449 | function wps_checkout_valid_step_five() { |
468 | 450 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
469 | 451 | |
470 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) ) |
|
471 | - wp_die(); |
|
452 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) ) { |
|
453 | + wp_die(); |
|
454 | + } |
|
472 | 455 | |
473 | 456 | $status = false; $response = ''; |
474 | 457 | $payment_method = ( !empty($_POST['wps-payment-method']) ) ? wpshop_tools::varSanitizer( $_POST['wps-payment-method'] ): null; |
@@ -513,16 +496,13 @@ discard block |
||
513 | 496 | // @TODO : REQUEST |
514 | 497 | // $args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST); |
515 | 498 | wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args ); |
516 | - } |
|
517 | - else { |
|
499 | + } else { |
|
518 | 500 | $response = '<div class="wps-alert-error">' .__( 'This payment method is unavailable', 'wpshop' ).'</div>'; |
519 | 501 | } |
520 | - } |
|
521 | - else { |
|
502 | + } else { |
|
522 | 503 | $response = '<div class="wps-alert-error">' .__( 'You must choose a payment method', 'wpshop' ).'</div>'; |
523 | 504 | } |
524 | - } |
|
525 | - else { |
|
505 | + } else { |
|
526 | 506 | $response = '<div class="wps-alert-error">' .__( 'You must accept the terms of sale to order', 'wpshop' ).'</div>'; |
527 | 507 | } |
528 | 508 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_media_manager_backend_ctr { |
3 | 3 | /** Define the main directory containing the template for the current plugin |
4 | 4 | * @var string |
@@ -9,27 +9,27 @@ discard block |
||
9 | 9 | $this->template_dir = WPS_MEDIA_MANAGER_PATH . WPS_MEDIA_MANAGER_DIR . "/templates/"; |
10 | 10 | |
11 | 11 | // Add action to create custom type and custom taxonomy |
12 | - add_action( 'add_meta_boxes', array($this, 'add_meta_box') ); |
|
13 | - add_action( 'save_post', array($this, 'save_post_actions') ); |
|
12 | + add_action('add_meta_boxes', array($this, 'add_meta_box')); |
|
13 | + add_action('save_post', array($this, 'save_post_actions')); |
|
14 | 14 | |
15 | 15 | // Add Scripts |
16 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_backend' ) ); |
|
16 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_backend')); |
|
17 | 17 | |
18 | 18 | // Ajax Actions |
19 | - add_action( 'wp_ajax_display_pictures_in_backend', array( $this, 'wp_ajax_display_pictures_in_backend' ) ); |
|
19 | + add_action('wp_ajax_display_pictures_in_backend', array($this, 'wp_ajax_display_pictures_in_backend')); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Add JAvascript and CSS files in Backend |
24 | 24 | */ |
25 | 25 | function add_scripts_backend() { |
26 | - wp_enqueue_script( 'jquery'); |
|
27 | - wp_enqueue_script( 'jquery-ui'); |
|
28 | - wp_enqueue_script( 'jquery-ui-sortable'); |
|
29 | - wp_enqueue_script( 'wps_media_manager_backend', WPS_MEDIA_MANAGER_URL . WPS_MEDIA_MANAGER_DIR .'/assets/js/wps_media_manager_backend.js'); |
|
26 | + wp_enqueue_script('jquery'); |
|
27 | + wp_enqueue_script('jquery-ui'); |
|
28 | + wp_enqueue_script('jquery-ui-sortable'); |
|
29 | + wp_enqueue_script('wps_media_manager_backend', WPS_MEDIA_MANAGER_URL . WPS_MEDIA_MANAGER_DIR . '/assets/js/wps_media_manager_backend.js'); |
|
30 | 30 | |
31 | - wp_register_style( 'wps_media_manager_css_backend', WPS_MEDIA_MANAGER_URL . WPS_MEDIA_MANAGER_DIR .'/assets/css/wps_media_manager_backend.css' ); |
|
32 | - wp_enqueue_style( 'wps_media_manager_css_backend' ); |
|
31 | + wp_register_style('wps_media_manager_css_backend', WPS_MEDIA_MANAGER_URL . WPS_MEDIA_MANAGER_DIR . '/assets/css/wps_media_manager_backend.css'); |
|
32 | + wp_enqueue_style('wps_media_manager_css_backend'); |
|
33 | 33 | |
34 | 34 | } |
35 | 35 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * Display meta Box in Project Custom Type |
38 | 38 | */ |
39 | 39 | function add_meta_box() { |
40 | - add_meta_box('wps_media_manager', __('Media Manager', 'wpshop' ),array( $this, 'meta_box' ), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal','low'); |
|
40 | + add_meta_box('wps_media_manager', __('Media Manager', 'wpshop'), array($this, 'meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,51 +46,51 @@ discard block |
||
46 | 46 | function meta_box() { |
47 | 47 | global $post; |
48 | 48 | $media = ''; |
49 | - $media_id_data = get_post_meta( $post->ID, '_wps_product_media', true ); |
|
50 | - if( !empty($media_id_data) ) { |
|
51 | - $media_id = explode( ',', $media_id_data ); |
|
49 | + $media_id_data = get_post_meta($post->ID, '_wps_product_media', true); |
|
50 | + if (!empty($media_id_data)) { |
|
51 | + $media_id = explode(',', $media_id_data); |
|
52 | 52 | ob_start(); |
53 | - require_once( wpshop_tools::get_template_part( WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "media_list") ); |
|
53 | + require_once(wpshop_tools::get_template_part(WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "media_list")); |
|
54 | 54 | $media = ob_get_contents(); |
55 | 55 | ob_end_clean(); |
56 | 56 | } |
57 | - require_once( wpshop_tools::get_template_part( WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "meta_box") ); |
|
57 | + require_once(wpshop_tools::get_template_part(WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "meta_box")); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * AJAX - Display pictures in backend panel |
62 | 62 | */ |
63 | 63 | function wp_ajax_display_pictures_in_backend() { |
64 | - $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
64 | + $_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
65 | 65 | |
66 | - if ( !wp_verify_nonce( $_wpnonce, 'wp_ajax_display_pictures_in_backend' ) ) |
|
66 | + if (!wp_verify_nonce($_wpnonce, 'wp_ajax_display_pictures_in_backend')) |
|
67 | 67 | wp_die(); |
68 | 68 | |
69 | 69 | $status = true; $response = ''; |
70 | 70 | $media_indicator = !empty($_POST['media_id']) ? (int)$_POST['media_id'] : null; |
71 | - if( !empty($media_indicator) ) { |
|
72 | - $media_id = explode( ',', $media_indicator ); |
|
73 | - if( !empty($media_id) ) { |
|
71 | + if (!empty($media_indicator)) { |
|
72 | + $media_id = explode(',', $media_indicator); |
|
73 | + if (!empty($media_id)) { |
|
74 | 74 | ob_start(); |
75 | - require( wpshop_tools::get_template_part( WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "media_list") ); |
|
75 | + require(wpshop_tools::get_template_part(WPS_MEDIA_MANAGER_DIR, $this->template_dir, "backend", "media_list")); |
|
76 | 76 | $response = ob_get_contents(); |
77 | 77 | ob_end_clean(); |
78 | 78 | } |
79 | 79 | } |
80 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
80 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
81 | 81 | wp_die(); |
82 | 82 | } |
83 | 83 | |
84 | 84 | // @TODO: NONCE et vérifier product_media |
85 | 85 | function save_post_actions() { |
86 | - $post_type = !empty( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : ''; |
|
87 | - $product_media_form = !empty( $_POST['product_media_form'] ) ? sanitize_text_field( $_POST['product_media_form'] ) : ''; |
|
88 | - $action = !empty( $_POST['action'] ) ? sanitize_text_field( $_POST['action'] ) : ''; |
|
89 | - $product_media = !empty( $_POST['product_media'] ) ? sanitize_text_field( $_POST['product_media'] ) : ''; |
|
90 | - $post_ID = !empty( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; |
|
86 | + $post_type = !empty($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : ''; |
|
87 | + $product_media_form = !empty($_POST['product_media_form']) ? sanitize_text_field($_POST['product_media_form']) : ''; |
|
88 | + $action = !empty($_POST['action']) ? sanitize_text_field($_POST['action']) : ''; |
|
89 | + $product_media = !empty($_POST['product_media']) ? sanitize_text_field($_POST['product_media']) : ''; |
|
90 | + $post_ID = !empty($_POST['post_ID']) ? (int)$_POST['post_ID'] : 0; |
|
91 | 91 | |
92 | - if ( !empty($post_type) && !empty($product_media_form) && $product_media_form == 'post' && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT && !empty( $action ) && $action != 'autosave' ) { |
|
93 | - update_post_meta( $post_ID, '_wps_product_media', $product_media ); |
|
92 | + if (!empty($post_type) && !empty($product_media_form) && $product_media_form == 'post' && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT && !empty($action) && $action != 'autosave') { |
|
93 | + update_post_meta($post_ID, '_wps_product_media', $product_media); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_media_manager_backend_ctr { |
3 | 5 | /** Define the main directory containing the template for the current plugin |
4 | 6 | * @var string |
@@ -63,8 +65,9 @@ discard block |
||
63 | 65 | function wp_ajax_display_pictures_in_backend() { |
64 | 66 | $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
65 | 67 | |
66 | - if ( !wp_verify_nonce( $_wpnonce, 'wp_ajax_display_pictures_in_backend' ) ) |
|
67 | - wp_die(); |
|
68 | + if ( !wp_verify_nonce( $_wpnonce, 'wp_ajax_display_pictures_in_backend' ) ) { |
|
69 | + wp_die(); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $status = true; $response = ''; |
70 | 73 | $media_indicator = !empty($_POST['media_id']) ? (int)$_POST['media_id'] : null; |
@@ -1,2 +1,2 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
2 | -<a href="<?php print wp_nonce_url( admin_url( 'admin-ajax.php?width=600&height=550&action=wps_free_product_form_page_tpl&oid='.$order_id ), 'wps_free_product_form_page_tpl', '_wpnonce' ); ?>" class="wps-bton-second-mini-rounded alignRight thickbox" title="<?php _e( 'Add free product', 'wpshop' ); ?>" id="add_free_product_bton"><?php _e( 'Add free product', 'wpshop' ); ?></a> |
|
1 | +<?php if (!defined('ABSPATH')) exit; ?> |
|
2 | +<a href="<?php print wp_nonce_url(admin_url('admin-ajax.php?width=600&height=550&action=wps_free_product_form_page_tpl&oid=' . $order_id), 'wps_free_product_form_page_tpl', '_wpnonce'); ?>" class="wps-bton-second-mini-rounded alignRight thickbox" title="<?php _e('Add free product', 'wpshop'); ?>" id="add_free_product_bton"><?php _e('Add free product', 'wpshop'); ?></a> |
@@ -1,4 +1,7 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
4 | +?> |
|
2 | 5 | <form id="wps_create_free_product" method="post" action="<?php echo admin_url('admin-ajax.php'); ?>"> |
3 | 6 | |
4 | 7 | <input type="hidden" name="action" value="wps_create_new_free_product"> |
@@ -1,21 +1,21 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_quotation_backend_ctr { |
3 | 3 | /* |
4 | 4 | * Declare filter and actions |
5 | 5 | */ |
6 | 6 | public function __construct() { |
7 | 7 | /** Appel des styles pour l'administration / Call style for administration */ |
8 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_assets' ) ); |
|
8 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_assets')); |
|
9 | 9 | |
10 | 10 | /** Définition du filtre permettant le champs d'activation du module avec un code obtenu sur la boutique / Define the filter allowing to display an input for module activation with a given code from the shop */ |
11 | - add_filter( 'wps-addon-extra-info', array( $this, 'display_addon_activation_form' ) ); |
|
11 | + add_filter('wps-addon-extra-info', array($this, 'display_addon_activation_form')); |
|
12 | 12 | /** Déclaration de la requête Ajax permettant de vérifier le code d'activation et d'activer le module le cas échéant / Declare ajax request allowing to check the code and activate addon in case the code is correct */ |
13 | - add_action( 'wp_ajax_check_code_for_activation', array( $this, 'check_code_for_activation' ) ); |
|
13 | + add_action('wp_ajax_check_code_for_activation', array($this, 'check_code_for_activation')); |
|
14 | 14 | |
15 | - add_filter( 'wps-filter-free-product-bton-tpl', array( $this, 'wps_free_product_bton_tpl' ) ); |
|
16 | - add_action( 'wp_ajax_wps_free_product_form_page_tpl', array( $this, 'wps_free_product_form_page_tpl' ) ); |
|
17 | - add_action( 'wp_ajax_wps_create_new_free_product', array( $this, 'wps_create_new_free_product' ) ); |
|
18 | - add_action( 'init', array( $this, 'wps_free_product_post_status' ) ); |
|
15 | + add_filter('wps-filter-free-product-bton-tpl', array($this, 'wps_free_product_bton_tpl')); |
|
16 | + add_action('wp_ajax_wps_free_product_form_page_tpl', array($this, 'wps_free_product_form_page_tpl')); |
|
17 | + add_action('wp_ajax_wps_create_new_free_product', array($this, 'wps_create_new_free_product')); |
|
18 | + add_action('init', array($this, 'wps_free_product_post_status')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Inclusion des feuilles de styles pour l'administration / Admin css enqueue |
24 | 24 | */ |
25 | 25 | function admin_assets() { |
26 | - wp_enqueue_script( 'wps_quotation_admin_js', WPS_QUOTATION_URL . '/assets/js/backend.js', array( 'jquery', ), WPSHOP_VERSION ); |
|
26 | + wp_enqueue_script('wps_quotation_admin_js', WPS_QUOTATION_URL . '/assets/js/backend.js', array('jquery',), WPSHOP_VERSION); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | /* |
32 | 32 | * Create a new post status for free products |
33 | 33 | */ |
34 | - function wps_free_product_post_status(){ |
|
35 | - register_post_status( 'free_product', array( |
|
36 | - 'label' => __( 'Free product', 'wpshop' ), |
|
34 | + function wps_free_product_post_status() { |
|
35 | + register_post_status('free_product', array( |
|
36 | + 'label' => __('Free product', 'wpshop'), |
|
37 | 37 | 'public' => false, |
38 | 38 | 'exclude_from_search' => true, |
39 | 39 | 'show_in_admin_all_list' => false, |
40 | 40 | 'show_in_admin_status_list' => false, |
41 | - ) ); |
|
41 | + )); |
|
42 | 42 | } |
43 | 43 | /* |
44 | 44 | * Template for display button - Filter : 'wps_orders\templates\backend\product-listing\wps_orders_product_listing.php' |
45 | 45 | * @param integer $order_id ID of order |
46 | 46 | */ |
47 | 47 | public function wps_free_product_bton_tpl($order_id) { |
48 | - $order_post_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
49 | - if ( 'completed' != $order_post_meta ) { |
|
50 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_bton_tpl") ); |
|
48 | + $order_post_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
49 | + if ('completed' != $order_post_meta) { |
|
50 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_bton_tpl")); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | /* |
54 | 54 | * Template for display form (AjaxForm) - Call from : Line 3 'templates\backend\add_free_product_form_page_tpl.php' |
55 | 55 | */ |
56 | 56 | public function wps_free_product_form_page_tpl() { |
57 | - $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
57 | + $_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
58 | 58 | |
59 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_free_product_form_page_tpl' ) ) |
|
59 | + if (!wp_verify_nonce($_wpnonce, 'wps_free_product_form_page_tpl')) |
|
60 | 60 | wp_die(); |
61 | 61 | |
62 | - $order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
|
63 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_form_page_tpl") ); |
|
62 | + $order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null; |
|
63 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_form_page_tpl")); |
|
64 | 64 | wp_die(); |
65 | 65 | } |
66 | 66 | /* |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return integer $pid Product ID |
71 | 71 | */ |
72 | 72 | public function wps_create_new_free_product() { |
73 | - $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
73 | + $_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
74 | 74 | |
75 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_create_new_free_product' ) ) |
|
75 | + if (!wp_verify_nonce($_wpnonce, 'wps_create_new_free_product')) |
|
76 | 76 | wp_die(); |
77 | 77 | |
78 | 78 | global $wpdb; |
@@ -80,43 +80,43 @@ discard block |
||
80 | 80 | $output = __('Error at product creation!', 'wpshop'); |
81 | 81 | $new_product_id = -1; |
82 | 82 | |
83 | - $post_title = ( !empty($_POST['post_title']) ) ? sanitize_text_field( $_POST['post_title'] ) : -1; |
|
84 | - $post_content = ( !empty($_POST['post_content']) ) ? sanitize_text_field( $_POST['post_content'] ) : ''; |
|
85 | - $attributes = ( !empty($_POST['attribute']) ) ? (array) $_POST['attribute'] : array(); |
|
83 | + $post_title = (!empty($_POST['post_title'])) ? sanitize_text_field($_POST['post_title']) : -1; |
|
84 | + $post_content = (!empty($_POST['post_content'])) ? sanitize_text_field($_POST['post_content']) : ''; |
|
85 | + $attributes = (!empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array(); |
|
86 | 86 | |
87 | - if( $post_title != -1 ) { |
|
88 | - $new_product_id = wp_insert_post( array( |
|
87 | + if ($post_title != -1) { |
|
88 | + $new_product_id = wp_insert_post(array( |
|
89 | 89 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
90 | 90 | 'post_status' => 'free_product', |
91 | 91 | 'post_title' => $post_title, |
92 | 92 | 'post_content' => $post_content, |
93 | - ) ); |
|
94 | - if( !is_object( $new_product_id ) ) { |
|
93 | + )); |
|
94 | + if (!is_object($new_product_id)) { |
|
95 | 95 | $attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code('wpshop_product')); |
96 | 96 | $id_attribute_set = null; |
97 | - foreach( $attribute_set_list as $attribute_set ) { |
|
98 | - if( $attribute_set->slug == 'free_product' ) { |
|
97 | + foreach ($attribute_set_list as $attribute_set) { |
|
98 | + if ($attribute_set->slug == 'free_product') { |
|
99 | 99 | $id_attribute_set = $attribute_set->id; |
100 | 100 | break; |
101 | 101 | } |
102 | 102 | } |
103 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set ); |
|
104 | - $data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $new_product_id ); |
|
105 | - $data_to_save['wpshop_product_attribute'] = ( !empty($attributes) ) ? $attributes : array(); |
|
103 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set); |
|
104 | + $data_to_save['post_ID'] = $data_to_save['product_id'] = intval($new_product_id); |
|
105 | + $data_to_save['wpshop_product_attribute'] = (!empty($attributes)) ? $attributes : array(); |
|
106 | 106 | $data_to_save['user_ID'] = get_current_user_id(); |
107 | 107 | $data_to_save['action'] = 'editpost'; |
108 | 108 | $status = false; |
109 | 109 | $output = __('Product created partially!', 'wpshop'); |
110 | - if( !empty($new_product_id) && !empty( $data_to_save['user_ID'] ) ) { |
|
110 | + if (!empty($new_product_id) && !empty($data_to_save['user_ID'])) { |
|
111 | 111 | $product_class = new wpshop_products(); |
112 | - $product_class->save_product_custom_informations( $new_product_id, $data_to_save ); |
|
112 | + $product_class->save_product_custom_informations($new_product_id, $data_to_save); |
|
113 | 113 | $status = true; |
114 | 114 | $output = __('Product created successfully.', 'wpshop'); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - echo json_encode( array( 'status' => $status, 'message' => $output, 'pid' => $new_product_id ) ); |
|
119 | + echo json_encode(array('status' => $status, 'message' => $output, 'pid' => $new_product_id)); |
|
120 | 120 | wp_die(); |
121 | 121 | } |
122 | 122 | |
@@ -126,78 +126,78 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param string $module Le nom du module en cours d'affichage et pour lequel il faut afficher le champs/ The module being displayed and to add input for |
128 | 128 | */ |
129 | - function display_addon_activation_form( $module ) { |
|
130 | - if ( WPS_QUOTATION_DIR == $module ) { |
|
129 | + function display_addon_activation_form($module) { |
|
130 | + if (WPS_QUOTATION_DIR == $module) { |
|
131 | 131 | |
132 | 132 | /** Récupération du statut du module devis / Get current quotation addon state */ |
133 | - $addon_option = get_option( 'wpshop_addons' ); |
|
133 | + $addon_option = get_option('wpshop_addons'); |
|
134 | 134 | |
135 | - if ( empty( $addon_option ) || ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( false === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) ) { |
|
136 | - $quotation_module_def = get_plugin_data( WPS_QUOTATION_PATH . '/wps_quotation.php' ); |
|
137 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activation" ) ); |
|
135 | + if (empty($addon_option) || (!empty($addon_option['WPSHOP_ADDONS_QUOTATION']) && (false === ($addon_option['WPSHOP_ADDONS_QUOTATION']['activate'])))) { |
|
136 | + $quotation_module_def = get_plugin_data(WPS_QUOTATION_PATH . '/wps_quotation.php'); |
|
137 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activation")); |
|
138 | 138 | } |
139 | - else if ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( true === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) { |
|
140 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activated" ) ); |
|
139 | + else if (!empty($addon_option['WPSHOP_ADDONS_QUOTATION']) && (true === ($addon_option['WPSHOP_ADDONS_QUOTATION']['activate']))) { |
|
140 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activated")); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | function check_code_for_activation() { |
146 | - $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
146 | + $_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
147 | 147 | |
148 | - if ( !wp_verify_nonce( $_wpnonce, 'check_code_for_activation' ) ) |
|
148 | + if (!wp_verify_nonce($_wpnonce, 'check_code_for_activation')) |
|
149 | 149 | wp_die(); |
150 | 150 | |
151 | 151 | $response = array( |
152 | 152 | 'status' => false, |
153 | - 'message' => __( 'Activation code for quotation addon is invalid, please check it and try again.', 'wpshop' ), |
|
153 | + 'message' => __('Activation code for quotation addon is invalid, please check it and try again.', 'wpshop'), |
|
154 | 154 | ); |
155 | - $required_code = wpshop_tools::get_plugin_validation_code( WPS_QUOTATION_DIR, site_url() ); |
|
156 | - $code = sanitize_text_field( $_POST[ 'code' ] ); |
|
157 | - if ( $code === $required_code ) { |
|
155 | + $required_code = wpshop_tools::get_plugin_validation_code(WPS_QUOTATION_DIR, site_url()); |
|
156 | + $code = sanitize_text_field($_POST['code']); |
|
157 | + if ($code === $required_code) { |
|
158 | 158 | $this->action_to_do_to_activate(); |
159 | 159 | $response = array( |
160 | 160 | 'status' => true, |
161 | - 'message' => __( 'Quotation addon have been successfully activated.', 'wpshop' ), |
|
161 | + 'message' => __('Quotation addon have been successfully activated.', 'wpshop'), |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
165 | - wp_die( json_encode( $response ) ); |
|
165 | + wp_die(json_encode($response)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Action to do when the activation code is OK |
170 | 170 | */ |
171 | - function action_to_do_to_activate(){ |
|
171 | + function action_to_do_to_activate() { |
|
172 | 172 | global $wpdb; |
173 | 173 | /** Activate the plug in **/ |
174 | - $addon_option = get_option( 'wpshop_addons' ); |
|
174 | + $addon_option = get_option('wpshop_addons'); |
|
175 | 175 | $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] = true; |
176 | 176 | $addon_option['WPSHOP_ADDONS_QUOTATION']['activation_date'] = current_time('mysql', 0); |
177 | 177 | |
178 | - update_option( 'wpshop_addons', $addon_option ); |
|
178 | + update_option('wpshop_addons', $addon_option); |
|
179 | 179 | |
180 | 180 | /** Activate the Quotation attribute **/ |
181 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => 'quotation_allowed') ); |
|
181 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => 'quotation_allowed')); |
|
182 | 182 | |
183 | - $attribute_def = wpshop_attributes::getElement( 'quotation_allowed', '"valid"', 'code' ); |
|
183 | + $attribute_def = wpshop_attributes::getElement('quotation_allowed', '"valid"', 'code'); |
|
184 | 184 | |
185 | 185 | /** Add the attribute in attributes groups section **/ |
186 | - $query = $wpdb->prepare('SELECT id, attribute_set_id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'general'); |
|
187 | - $attribute_set_sections = $wpdb->get_results( $query ); |
|
188 | - |
|
189 | - if ( !empty($attribute_set_sections) ) { |
|
190 | - $entity_type_def = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
191 | - if ( !empty( $entity_type_def) ) { |
|
192 | - foreach ( $attribute_set_sections as $attribute_set_section ) { |
|
193 | - $query = $wpdb->prepare('SELECT COUNT(*) AS count_attribute_affectation FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id, $attribute_def->id); |
|
194 | - $count_attribute_affectation = $wpdb->get_var( $query ); |
|
195 | - |
|
196 | - if ( $count_attribute_affectation == 0 ) { |
|
197 | - $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id); |
|
198 | - $max_position = $wpdb->get_var( $query ); |
|
186 | + $query = $wpdb->prepare('SELECT id, attribute_set_id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'general'); |
|
187 | + $attribute_set_sections = $wpdb->get_results($query); |
|
188 | + |
|
189 | + if (!empty($attribute_set_sections)) { |
|
190 | + $entity_type_def = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
191 | + if (!empty($entity_type_def)) { |
|
192 | + foreach ($attribute_set_sections as $attribute_set_section) { |
|
193 | + $query = $wpdb->prepare('SELECT COUNT(*) AS count_attribute_affectation FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id, $attribute_def->id); |
|
194 | + $count_attribute_affectation = $wpdb->get_var($query); |
|
195 | + |
|
196 | + if ($count_attribute_affectation == 0) { |
|
197 | + $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id); |
|
198 | + $max_position = $wpdb->get_var($query); |
|
199 | 199 | /** Insert attribute detail **/ |
200 | - $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_type_def, 'attribute_set_id' => $attribute_set_section->attribute_set_id, 'attribute_group_id' => $attribute_set_section->id, 'attribute_id' => $attribute_def->id, 'position' => (int)$max_position + 1) ); |
|
200 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_type_def, 'attribute_set_id' => $attribute_set_section->attribute_set_id, 'attribute_group_id' => $attribute_set_section->id, 'attribute_id' => $attribute_def->id, 'position' => (int)$max_position + 1)); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_quotation_backend_ctr { |
3 | 5 | /* |
4 | 6 | * Declare filter and actions |
@@ -56,8 +58,9 @@ discard block |
||
56 | 58 | public function wps_free_product_form_page_tpl() { |
57 | 59 | $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
58 | 60 | |
59 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_free_product_form_page_tpl' ) ) |
|
60 | - wp_die(); |
|
61 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_free_product_form_page_tpl' ) ) { |
|
62 | + wp_die(); |
|
63 | + } |
|
61 | 64 | |
62 | 65 | $order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
63 | 66 | require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_form_page_tpl") ); |
@@ -72,8 +75,9 @@ discard block |
||
72 | 75 | public function wps_create_new_free_product() { |
73 | 76 | $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
74 | 77 | |
75 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_create_new_free_product' ) ) |
|
76 | - wp_die(); |
|
78 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_create_new_free_product' ) ) { |
|
79 | + wp_die(); |
|
80 | + } |
|
77 | 81 | |
78 | 82 | global $wpdb; |
79 | 83 | $status = false; |
@@ -135,8 +139,7 @@ discard block |
||
135 | 139 | if ( empty( $addon_option ) || ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( false === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) ) { |
136 | 140 | $quotation_module_def = get_plugin_data( WPS_QUOTATION_PATH . '/wps_quotation.php' ); |
137 | 141 | require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activation" ) ); |
138 | - } |
|
139 | - else if ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( true === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) { |
|
142 | + } else if ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( true === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) { |
|
140 | 143 | require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activated" ) ); |
141 | 144 | } |
142 | 145 | } |
@@ -145,8 +148,9 @@ discard block |
||
145 | 148 | function check_code_for_activation() { |
146 | 149 | $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
147 | 150 | |
148 | - if ( !wp_verify_nonce( $_wpnonce, 'check_code_for_activation' ) ) |
|
149 | - wp_die(); |
|
151 | + if ( !wp_verify_nonce( $_wpnonce, 'check_code_for_activation' ) ) { |
|
152 | + wp_die(); |
|
153 | + } |
|
150 | 154 | |
151 | 155 | $response = array( |
152 | 156 | 'status' => false, |