Completed
Push — master ( 60fe5b...278d60 )
by
unknown
14:18
created
includes/modules/wps_classic_checkout/wps_classic_checkout.php 1 patch
Braces   +36 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
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]>
@@ -75,8 +77,7 @@  discard block
 block discarded – undo
75 77
 					$product_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_product_page_id' ) );
76 78
 					$url = get_permalink( $product_page_id );
77 79
 					wpshop_tools::wpshop_safe_redirect( $url );
78
-				}
79
-				else {
80
+				} else {
80 81
 					$current_step = 2;
81 82
 				}
82 83
 			}
@@ -98,8 +99,7 @@  discard block
 block discarded – undo
98 99
 							$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
99 100
 							$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3';
100 101
 							wpshop_tools::wpshop_safe_redirect( $url );
101
-						}
102
-						else {
102
+						} else {
103 103
 							ob_start();
104 104
 							require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-two") );
105 105
 							$checkout_content .= ob_get_contents();
@@ -112,8 +112,7 @@  discard block
 block discarded – undo
112 112
 							$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
113 113
 							$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2';
114 114
 							wpshop_tools::wpshop_safe_redirect( $url );
115
-						}
116
-						else {
115
+						} else {
117 116
 							if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) {
118 117
 								ob_start();
119 118
 								require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three") );
@@ -123,8 +122,7 @@  discard block
 block discarded – undo
123 122
 								if(!empty($url)) {
124 123
 									wpshop_tools::wpshop_safe_redirect( $url );
125 124
 								}
126
-							}
127
-							else {
125
+							} else {
128 126
 								$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
129 127
 								$url = get_permalink( $checkout_page_id  );
130 128
 								wpshop_tools::wpshop_safe_redirect( $url );
@@ -137,15 +135,13 @@  discard block
 block discarded – undo
137 135
 							$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
138 136
 							$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2';
139 137
 							wpshop_tools::wpshop_safe_redirect( $url );
140
-						}
141
-						else {
138
+						} else {
142 139
 							if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) {
143 140
 								ob_start();
144 141
 								require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four") );
145 142
 								$checkout_content .= ob_get_contents();
146 143
 								ob_end_clean();
147
-							}
148
-							else {
144
+							} else {
149 145
 								$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
150 146
 								$url = get_permalink( $checkout_page_id  );
151 147
 								wpshop_tools::wpshop_safe_redirect( $url );
@@ -158,8 +154,7 @@  discard block
 block discarded – undo
158 154
 							$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
159 155
 							$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2';
160 156
 							wpshop_tools::wpshop_safe_redirect( $url );
161
-						}
162
-						else {
157
+						} else {
163 158
 							$wps_cart = new wps_cart();
164 159
 							$order = $wps_cart->calcul_cart_information( array() );
165 160
 							$wps_cart->store_cart_in_session($order);
@@ -171,8 +166,7 @@  discard block
 block discarded – undo
171 166
 								$checkout_content .= ob_get_contents();
172 167
 								ob_end_clean();
173 168
 								$checkout_content = apply_filters( 'classic_checkout_step_six_extra_content', $checkout_content );
174
-							}
175
-							else {
169
+							} else {
176 170
 								$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
177 171
 								$url = get_permalink( $checkout_page_id  );
178 172
 								wpshop_tools::wpshop_safe_redirect( $url );
@@ -186,8 +180,7 @@  discard block
 block discarded – undo
186 180
 						 	$checkout_content .=  $wps_marketing_tools_ctr->display_ecommerce_ga_tracker( $_SESSION['order_id'] );
187 181
 						 	$checkout_content .= $this->wps_classic_confirmation_message();
188 182
 						 	$checkout_content .= $this->wps_summary_order();
189
-						}
190
-						else {
183
+						} else {
191 184
 							$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
192 185
 							$url = get_permalink( $checkout_page_id  );
193 186
 							wpshop_tools::wpshop_safe_redirect( $url );
@@ -201,8 +194,7 @@  discard block
 block discarded – undo
201 194
 					break;
202 195
 				}
203 196
 
204
-			}
205
-			else {
197
+			} else {
206 198
 				$checkout_content = do_shortcode('[wps_cart]');
207 199
 			}
208 200
 
@@ -251,8 +243,7 @@  discard block
 block discarded – undo
251 243
 			$no_cart = false;
252 244
 			if ( empty( $wpshop_cart_option ) || empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) || ( 'no' === $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) ) {
253 245
 				$steps[] = __('Cart', 'wpshop');
254
-			}
255
-			else {
246
+			} else {
256 247
 				$no_cart = true;
257 248
 			}
258 249
 
@@ -262,8 +253,7 @@  discard block
 block discarded – undo
262 253
 			$no_shipping = false;
263 254
 			if ( !empty( $shipping_address_option ) && !empty( $shipping_address_option[ 'activate' ] ) && !empty( $shipping_address_option[ 'choice' ] ) ) {
264 255
 				$steps[] = __('Shipping Mode', 'wpshop');
265
-			}
266
-			else {
256
+			} else {
267 257
 				$no_shipping = true;
268 258
 			}
269 259
 
@@ -271,8 +261,7 @@  discard block
 block discarded – undo
271 261
 			$partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array()));
272 262
 			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'] ) ) ) ) {
273 263
 				$no_payment = true;
274
-			}
275
-			else {
264
+			} else {
276 265
 				$steps[] = __('Payment', 'wpshop');
277 266
 			}
278 267
 
@@ -289,8 +278,9 @@  discard block
 block discarded – undo
289 278
 		function wps_checkout_valid_step_three() {
290 279
 			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
291 280
 
292
-			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) )
293
-				wp_die();
281
+			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) ) {
282
+							wp_die();
283
+			}
294 284
 
295 285
 			$response = ''; $status = true;
296 286
 
@@ -334,8 +324,7 @@  discard block
 block discarded – undo
334 324
 						/** Check if user have already create a shipping address **/
335 325
 						if ( !empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $shipping_option['choice'] ]) ){
336 326
 							$response .= '<li>'.__( 'You must select a shipping address', 'wpshop' ).'</li>';
337
-						}
338
-						else {
327
+						} else {
339 328
 							$response .= '<li>'.__( 'You must create a shipping address', 'wpshop' ).'</li>';
340 329
 						}
341 330
 					}
@@ -346,13 +335,11 @@  discard block
 block discarded – undo
346 335
 					$status = false;
347 336
 					if ( !empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $billing_option['choice'] ]) ){
348 337
 						$response .= '<li>'.__( 'You must select a billing address', 'wpshop' ).'</li>';
349
-					}
350
-					else {
338
+					} else {
351 339
 						$response .= '<li>'.__( 'You must create a billing address', 'wpshop' ).'</li>';
352 340
 					}
353 341
 				}
354
-			}
355
-			else {
342
+			} else {
356 343
 				$status = false;
357 344
 				$response .= '<li>'.__( 'You must be logged to pass to next step', 'wpshop' ).'</li>';
358 345
 			}
@@ -398,13 +385,11 @@  discard block
 block discarded – undo
398 385
 							$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6';
399 386
 	// 						wpshop_tools::wpshop_safe_redirect( $url );
400 387
 							$response = $url;
401
-						}
402
-						else {
388
+						} else {
403 389
 							$status = true;
404 390
 							$response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id )  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5';
405 391
 						}
406
-					}
407
-					else {
392
+					} else {
408 393
 						$status = true;
409 394
 						$response = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=4';
410 395
 					}
@@ -422,8 +407,9 @@  discard block
 block discarded – undo
422 407
 		function wps_checkout_valid_step_four() {
423 408
 			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
424 409
 
425
-			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) )
426
-				wp_die();
410
+			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) ) {
411
+							wp_die();
412
+			}
427 413
 
428 414
 			$shipping_method = ( !empty($_POST['shipping_mode']) ) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null;
429 415
 			$status = false;
@@ -444,20 +430,17 @@  discard block
 block discarded – undo
444 430
 						$step = '6';
445 431
 					}
446 432
 					$response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id )  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step;
447
-				}
448
-				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' ) {
433
+				} 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' ) {
449 434
 					$payment_method = $_SESSION['payment_method'] = 'free';
450 435
 					$order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] );
451 436
 					$permalink_option = get_option( 'permalink_structure' );
452 437
 					$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
453 438
 					$url = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6';
454 439
 					$response = $url;
455
-				}
456
-				else {
440
+				} else {
457 441
 					$response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id )  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5';
458 442
 				}
459
-			}
460
-			else {
443
+			} else {
461 444
 				$response .= '<div class="wps-alert-error">'.__( 'You must select a shipping method', 'wpshop' ).'</div>';
462 445
 			}
463 446
 
@@ -473,8 +456,9 @@  discard block
 block discarded – undo
473 456
 		 */
474 457
 		function wps_checkout_valid_step_five() {
475 458
 			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
476
-			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) )
477
-				wp_die();
459
+			if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) ) {
460
+							wp_die();
461
+			}
478 462
 
479 463
 			$status = false;
480 464
 			$response = '';
@@ -521,16 +505,13 @@  discard block
 block discarded – undo
521 505
 						// @TODO : REQUEST
522 506
 						$args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST);
523 507
 						wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args );
524
-					}
525
-					else {
508
+					} else {
526 509
 						$response = '<div class="wps-alert-error">' .__( 'This payment method is unavailable', 'wpshop' ).'</div>';
527 510
 					}
528
-				}
529
-				else {
511
+				} else {
530 512
 					$response = '<div class="wps-alert-error">' .__( 'You must choose a payment method', 'wpshop' ).'</div>';
531 513
 				}
532
-			}
533
-			else {
514
+			} else {
534 515
 				$response = '<div class="wps-alert-error">' .__( 'You must accept the terms of sale to order', 'wpshop' ).'</div>';
535 516
 			}
536 517
 
Please login to merge, or discard this patch.