@@ -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,21 +35,21 @@ 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 | - add_action( 'admin_post_wps_direct_payment_link', array( 'wpshop_checkout', 'wps_direct_payment_link' ) ); |
|
| 52 | - add_action( 'admin_post_nopriv_wps_direct_payment_link', array( 'wpshop_checkout', 'wps_direct_payment_link_nopriv' ) ); |
|
| 51 | + add_action('admin_post_wps_direct_payment_link', array('wpshop_checkout', 'wps_direct_payment_link')); |
|
| 52 | + add_action('admin_post_nopriv_wps_direct_payment_link', array('wpshop_checkout', 'wps_direct_payment_link_nopriv')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,145 +57,145 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | function add_scripts() { |
| 59 | 59 | wp_enqueue_script('jquery'); |
| 60 | - wp_enqueue_script( 'wps_classic_checkout', plugins_url('templates/frontend/js/wps_classic_checkout.js', __FILE__) ); |
|
| 60 | + wp_enqueue_script('wps_classic_checkout', plugins_url('templates/frontend/js/wps_classic_checkout.js', __FILE__)); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Display Classic Checkout |
| 65 | 65 | */ |
| 66 | 66 | function show_classic_checkout() { |
| 67 | - $order_id = !empty( $_GET['order_id'] ) ? (int) $_GET['order_id'] : ''; |
|
| 67 | + $order_id = !empty($_GET['order_id']) ? (int)$_GET['order_id'] : ''; |
|
| 68 | 68 | |
| 69 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
| 70 | - $current_step = !empty( $_GET[ 'order_step' ] ) && is_int( (int)$_GET[ 'order_step' ] ) ? (int)$_GET[ 'order_step' ] : null; |
|
| 69 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
| 70 | + $current_step = !empty($_GET['order_step']) && is_int((int)$_GET['order_step']) ? (int)$_GET['order_step'] : null; |
|
| 71 | 71 | |
| 72 | 72 | /** 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 */ |
| 73 | - 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] ) ) ) { |
|
| 74 | - if( empty($_SESSION) || empty($_SESSION['cart']) || empty($_SESSION['cart']['order_items']) ) { |
|
| 75 | - $product_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_product_page_id' ) ); |
|
| 76 | - $url = get_permalink( $product_page_id ); |
|
| 77 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 73 | + 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]))) { |
|
| 74 | + if (empty($_SESSION) || empty($_SESSION['cart']) || empty($_SESSION['cart']['order_items'])) { |
|
| 75 | + $product_page_id = wpshop_tools::get_page_id(get_option('wpshop_product_page_id')); |
|
| 76 | + $url = get_permalink($product_page_id); |
|
| 77 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 78 | 78 | } |
| 79 | 79 | else { |
| 80 | 80 | $current_step = 2; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $checkout_step_indicator = do_shortcode( '[wps_checkout_step_indicator]'); |
|
| 84 | + $checkout_step_indicator = do_shortcode('[wps_checkout_step_indicator]'); |
|
| 85 | 85 | $checkout_content = ''; |
| 86 | 86 | |
| 87 | - if ( !empty($current_step) ) { |
|
| 88 | - switch( $current_step) { |
|
| 87 | + if (!empty($current_step)) { |
|
| 88 | + switch ($current_step) { |
|
| 89 | 89 | case 1 : |
| 90 | 90 | ob_start(); |
| 91 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one") ); |
|
| 91 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one")); |
|
| 92 | 92 | $checkout_content .= ob_get_contents(); |
| 93 | 93 | ob_end_clean(); |
| 94 | 94 | break; |
| 95 | 95 | case 2 : |
| 96 | - if ( get_current_user_id() != 0 ) { |
|
| 97 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 98 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 99 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
| 100 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 96 | + if (get_current_user_id() != 0) { |
|
| 97 | + $permalink_option = get_option('permalink_structure'); |
|
| 98 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 99 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
| 100 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 101 | 101 | } |
| 102 | 102 | else { |
| 103 | 103 | ob_start(); |
| 104 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-two") ); |
|
| 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(); |
| 106 | 106 | ob_end_clean(); |
| 107 | 107 | } |
| 108 | 108 | break; |
| 109 | 109 | case 3 : |
| 110 | - if ( get_current_user_id() == 0 ) { |
|
| 111 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 112 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 113 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
| 114 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 110 | + if (get_current_user_id() == 0) { |
|
| 111 | + $permalink_option = get_option('permalink_structure'); |
|
| 112 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 113 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
| 114 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 115 | 115 | } |
| 116 | 116 | else { |
| 117 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
| 117 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
| 118 | 118 | ob_start(); |
| 119 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three") ); |
|
| 119 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-three")); |
|
| 120 | 120 | $checkout_content .= ob_get_contents(); |
| 121 | 121 | ob_end_clean(); |
| 122 | - $url = apply_filters('wps_extra_signup_actions', ( isset( $url ) ? $url : '' ) ); |
|
| 123 | - if(!empty($url)) { |
|
| 124 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 122 | + $url = apply_filters('wps_extra_signup_actions', (isset($url) ? $url : '')); |
|
| 123 | + if (!empty($url)) { |
|
| 124 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | else { |
| 128 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 129 | - $url = get_permalink( $checkout_page_id ); |
|
| 130 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 128 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 129 | + $url = get_permalink($checkout_page_id); |
|
| 130 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | break; |
| 134 | 134 | case 4 : |
| 135 | - if ( get_current_user_id() == 0 ) { |
|
| 136 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 137 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 138 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
| 139 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 135 | + if (get_current_user_id() == 0) { |
|
| 136 | + $permalink_option = get_option('permalink_structure'); |
|
| 137 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 138 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
| 139 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 140 | 140 | } |
| 141 | 141 | else { |
| 142 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
| 142 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
| 143 | 143 | ob_start(); |
| 144 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four") ); |
|
| 144 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-four")); |
|
| 145 | 145 | $checkout_content .= ob_get_contents(); |
| 146 | 146 | ob_end_clean(); |
| 147 | 147 | } |
| 148 | 148 | else { |
| 149 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 150 | - $url = get_permalink( $checkout_page_id ); |
|
| 151 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 149 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 150 | + $url = get_permalink($checkout_page_id); |
|
| 151 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | break; |
| 155 | 155 | case 5 : |
| 156 | - if ( get_current_user_id() == 0 ) { |
|
| 157 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 158 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 159 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=2'; |
|
| 160 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 156 | + if (get_current_user_id() == 0) { |
|
| 157 | + $permalink_option = get_option('permalink_structure'); |
|
| 158 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 159 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2'; |
|
| 160 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 161 | 161 | } |
| 162 | 162 | else { |
| 163 | 163 | $wps_cart = new wps_cart(); |
| 164 | - $order = $wps_cart->calcul_cart_information( array() ); |
|
| 164 | + $order = $wps_cart->calcul_cart_information(array()); |
|
| 165 | 165 | $wps_cart->store_cart_in_session($order); |
| 166 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 167 | - 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']) ) ) ) { |
|
| 168 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 166 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 167 | + 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'])))) { |
|
| 168 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 169 | 169 | ob_start(); |
| 170 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-five") ); |
|
| 170 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-five")); |
|
| 171 | 171 | $checkout_content .= ob_get_contents(); |
| 172 | 172 | ob_end_clean(); |
| 173 | - $checkout_content = apply_filters( 'classic_checkout_step_six_extra_content', $checkout_content ); |
|
| 173 | + $checkout_content = apply_filters('classic_checkout_step_six_extra_content', $checkout_content); |
|
| 174 | 174 | } |
| 175 | 175 | else { |
| 176 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 177 | - $url = get_permalink( $checkout_page_id ); |
|
| 178 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 176 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 177 | + $url = get_permalink($checkout_page_id); |
|
| 178 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | break; |
| 182 | 182 | case 6 : |
| 183 | 183 | |
| 184 | - if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ){ |
|
| 184 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
| 185 | 185 | $wps_marketing_tools_ctr = new wps_marketing_tools_ctr(); |
| 186 | - $checkout_content .= $wps_marketing_tools_ctr->display_ecommerce_ga_tracker( $_SESSION['order_id'] ); |
|
| 186 | + $checkout_content .= $wps_marketing_tools_ctr->display_ecommerce_ga_tracker($_SESSION['order_id']); |
|
| 187 | 187 | $checkout_content .= $this->wps_classic_confirmation_message(); |
| 188 | 188 | $checkout_content .= $this->wps_summary_order(); |
| 189 | 189 | } |
| 190 | 190 | else { |
| 191 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 192 | - $url = get_permalink( $checkout_page_id ); |
|
| 193 | - wpshop_tools::wpshop_safe_redirect( $url ); |
|
| 191 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 192 | + $url = get_permalink($checkout_page_id); |
|
| 193 | + wpshop_tools::wpshop_safe_redirect($url); |
|
| 194 | 194 | } |
| 195 | 195 | break; |
| 196 | 196 | default : |
| 197 | 197 | ob_start(); |
| 198 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one") ); |
|
| 198 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic-checkout", "step-one")); |
|
| 199 | 199 | $checkout_content .= ob_get_contents(); |
| 200 | 200 | ob_end_clean(); |
| 201 | 201 | break; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $checkout_content = do_shortcode('[wps_cart]'); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - require_once( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic_checkout") ); |
|
| 209 | + require_once(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "classic_checkout")); |
|
| 210 | 210 | |
| 211 | 211 | } |
| 212 | 212 | |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | function wps_classic_confirmation_message() { |
| 218 | 218 | $output = ''; |
| 219 | 219 | $wps_cart = new wps_cart(); |
| 220 | - $available_templates = array( 'banktransfer', 'checks', 'free', 'paypal', 'cic', 'quotation', 'cash_on_delivery' ); |
|
| 221 | - $payment_method = ( !empty($_SESSION['payment_method']) && in_array($_SESSION['payment_method'], $available_templates) ) ? $_SESSION['payment_method'] : 'others'; |
|
| 220 | + $available_templates = array('banktransfer', 'checks', 'free', 'paypal', 'cic', 'quotation', 'cash_on_delivery'); |
|
| 221 | + $payment_method = (!empty($_SESSION['payment_method']) && in_array($_SESSION['payment_method'], $available_templates)) ? $_SESSION['payment_method'] : 'others'; |
|
| 222 | 222 | ob_start(); |
| 223 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir,"frontend", "confirmation/confirmation", $payment_method) ); |
|
| 223 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "confirmation/confirmation", $payment_method)); |
|
| 224 | 224 | $output .= ob_get_contents(); |
| 225 | 225 | ob_end_clean(); |
| 226 | 226 | return $output; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | function wps_summary_order() { |
| 230 | 230 | ob_start(); |
| 231 | - require( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir,"frontend", "confirmation/confirmation-summary") ); |
|
| 231 | + require(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "confirmation/confirmation-summary")); |
|
| 232 | 232 | $output = ob_get_contents(); |
| 233 | 233 | ob_end_clean(); |
| 234 | 234 | return $output; |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | * @return String |
| 240 | 240 | */ |
| 241 | 241 | function get_checkout_step_indicator() { |
| 242 | - $default_step = ( !empty( $_GET['order_step'] ) ) ? wpshop_tools::varSanitizer( $_GET['order_step'] ) : 1; |
|
| 242 | + $default_step = (!empty($_GET['order_step'])) ? wpshop_tools::varSanitizer($_GET['order_step']) : 1; |
|
| 243 | 243 | $steps = array(); |
| 244 | 244 | |
| 245 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 246 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
| 247 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 248 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 245 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
| 246 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
| 247 | + $permalink_option = get_option('permalink_structure'); |
|
| 248 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | $no_cart = false; |
| 252 | - if ( empty( $wpshop_cart_option ) || empty( $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) || ( 'no' === $wpshop_cart_option[ 'total_nb_of_item_allowed' ] ) ) { |
|
| 252 | + if (empty($wpshop_cart_option) || empty($wpshop_cart_option['total_nb_of_item_allowed']) || ('no' === $wpshop_cart_option['total_nb_of_item_allowed'])) { |
|
| 253 | 253 | $steps[] = __('Cart', 'wpshop'); |
| 254 | 254 | } |
| 255 | 255 | else { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $steps[] = __('Addresses', 'wpshop'); |
| 261 | 261 | |
| 262 | 262 | $no_shipping = false; |
| 263 | - if ( !empty( $shipping_address_option ) && !empty( $shipping_address_option[ 'activate' ] ) && !empty( $shipping_address_option[ 'choice' ] ) ) { |
|
| 263 | + if (!empty($shipping_address_option) && !empty($shipping_address_option['activate']) && !empty($shipping_address_option['choice'])) { |
|
| 264 | 264 | $steps[] = __('Shipping Mode', 'wpshop'); |
| 265 | 265 | } |
| 266 | 266 | else { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | $no_payment = false; |
| 271 | 271 | $partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
| 272 | - 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'] ) ) ) ) { |
|
| 272 | + 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 | 273 | $no_payment = true; |
| 274 | 274 | } |
| 275 | 275 | else { |
@@ -280,45 +280,45 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | $steps = apply_filters('wps_extra_action_checkout_indicator', $steps); |
| 282 | 282 | |
| 283 | - require_once( wpshop_tools::get_template_part( WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir,"frontend", "checkout_step_indicator/checkout_step_indicator") ); |
|
| 283 | + require_once(wpshop_tools::get_template_part(WPS_CLASSIC_CHECKOUT_DIR, $this->template_dir, "frontend", "checkout_step_indicator/checkout_step_indicator")); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * AJAX - Valid Checkout Step three |
| 288 | 288 | */ |
| 289 | 289 | function wps_checkout_valid_step_three() { |
| 290 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 290 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 291 | 291 | |
| 292 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_three' ) ) |
|
| 292 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_three')) |
|
| 293 | 293 | wp_die(); |
| 294 | 294 | |
| 295 | 295 | $response = ''; $status = true; |
| 296 | 296 | |
| 297 | - $shipping_address = ( !empty($_POST['shipping_address_id']) ) ? wpshop_tools::varSanitizer( $_POST['shipping_address_id'] ): null; |
|
| 298 | - $billing_address = ( !empty($_POST['billing_address_id']) ) ? wpshop_tools::varSanitizer( $_POST['billing_address_id'] ): null; |
|
| 297 | + $shipping_address = (!empty($_POST['shipping_address_id'])) ? wpshop_tools::varSanitizer($_POST['shipping_address_id']) : null; |
|
| 298 | + $billing_address = (!empty($_POST['billing_address_id'])) ? wpshop_tools::varSanitizer($_POST['billing_address_id']) : null; |
|
| 299 | 299 | |
| 300 | 300 | $user_id = get_current_user_id(); |
| 301 | 301 | |
| 302 | 302 | $response = '<div class="wps-alert-error"><ul>'; |
| 303 | 303 | |
| 304 | - if( $user_id != 0 ) { |
|
| 305 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 306 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 307 | - $user_addresses = wps_address::get_addresses_list( $user_id ); |
|
| 304 | + if ($user_id != 0) { |
|
| 305 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 306 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 307 | + $user_addresses = wps_address::get_addresses_list($user_id); |
|
| 308 | 308 | |
| 309 | 309 | // Check if is only downloadable else display address |
| 310 | 310 | $cart_is_downloadable = false; |
| 311 | - if ( !empty( $_SESSION['cart'] ) && !empty( $_SESSION['cart']['order_items'] ) ) { |
|
| 312 | - foreach( $_SESSION['cart']['order_items'] as $c ) { |
|
| 313 | - $product = wpshop_products::get_product_data( $c['item_id'] ); |
|
| 311 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
| 312 | + foreach ($_SESSION['cart']['order_items'] as $c) { |
|
| 313 | + $product = wpshop_products::get_product_data($c['item_id']); |
|
| 314 | 314 | /** Check if it's a variation and check the parent product **/ |
| 315 | - if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 316 | - $parent_def = wpshop_products::get_parent_variation( $c['item_id'] ); |
|
| 317 | - if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) { |
|
| 315 | + if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 316 | + $parent_def = wpshop_products::get_parent_variation($c['item_id']); |
|
| 317 | + if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) { |
|
| 318 | 318 | $product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_']; |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | - if( !empty($product['is_downloadable_']) && ( __( $product['is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $product['is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) { |
|
| 321 | + if (!empty($product['is_downloadable_']) && (__($product['is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($product['is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) { |
|
| 322 | 322 | $cart_is_downloadable = true; |
| 323 | 323 | } else { |
| 324 | 324 | $cart_is_downloadable = false; |
@@ -327,144 +327,144 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if( !empty($shipping_option) && !empty($shipping_option['activate']) && !$cart_is_downloadable ) { |
|
| 330 | + if (!empty($shipping_option) && !empty($shipping_option['activate']) && !$cart_is_downloadable) { |
|
| 331 | 331 | /** Check Shipping address **/ |
| 332 | - if ( empty($shipping_address) ) { |
|
| 332 | + if (empty($shipping_address)) { |
|
| 333 | 333 | $status = false; |
| 334 | 334 | /** Check if user have already create a shipping address **/ |
| 335 | - if ( !empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $shipping_option['choice'] ]) ){ |
|
| 336 | - $response .= '<li>'.__( 'You must select a shipping address', 'wpshop' ).'</li>'; |
|
| 335 | + if (!empty($shipping_option['choice']) && !empty($user_addresses) && !empty($user_addresses[$shipping_option['choice']])) { |
|
| 336 | + $response .= '<li>' . __('You must select a shipping address', 'wpshop') . '</li>'; |
|
| 337 | 337 | } |
| 338 | 338 | else { |
| 339 | - $response .= '<li>'.__( 'You must create a shipping address', 'wpshop' ).'</li>'; |
|
| 339 | + $response .= '<li>' . __('You must create a shipping address', 'wpshop') . '</li>'; |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | } |
| 344 | 344 | /** Check Billing address **/ |
| 345 | - if( empty($billing_address) ) { |
|
| 345 | + if (empty($billing_address)) { |
|
| 346 | 346 | $status = false; |
| 347 | - if ( !empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[ $billing_option['choice'] ]) ){ |
|
| 348 | - $response .= '<li>'.__( 'You must select a billing address', 'wpshop' ).'</li>'; |
|
| 347 | + if (!empty($billing_option['choice']) && !empty($user_addresses) && !empty($user_addresses[$billing_option['choice']])) { |
|
| 348 | + $response .= '<li>' . __('You must select a billing address', 'wpshop') . '</li>'; |
|
| 349 | 349 | } |
| 350 | 350 | else { |
| 351 | - $response .= '<li>'.__( 'You must create a billing address', 'wpshop' ).'</li>'; |
|
| 351 | + $response .= '<li>' . __('You must create a billing address', 'wpshop') . '</li>'; |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | else { |
| 356 | 356 | $status = false; |
| 357 | - $response .= '<li>'.__( 'You must be logged to pass to next step', 'wpshop' ).'</li>'; |
|
| 357 | + $response .= '<li>' . __('You must be logged to pass to next step', 'wpshop') . '</li>'; |
|
| 358 | 358 | } |
| 359 | 359 | $response .= '</ul></div>'; |
| 360 | 360 | |
| 361 | 361 | /** If no error **/ |
| 362 | - if( $status ) { |
|
| 362 | + if ($status) { |
|
| 363 | 363 | $_SESSION['shipping_address'] = $shipping_address; |
| 364 | 364 | $_SESSION['billing_address'] = $billing_address; |
| 365 | 365 | |
| 366 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 367 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 366 | + $permalink_option = get_option('permalink_structure'); |
|
| 367 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 368 | 368 | /** Checking if no shipping method is required and it is a quotation or a free order **/ |
| 369 | - $shipping_option = get_option( 'wps_shipping_mode' ); |
|
| 369 | + $shipping_option = get_option('wps_shipping_mode'); |
|
| 370 | 370 | |
| 371 | 371 | /** Quotation, no shipping, no payment */ |
| 372 | - if ( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
| 372 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
| 373 | 373 | $status = true; |
| 374 | 374 | $_SESSION['shipping_method'] = 'No Shipping method required'; |
| 375 | 375 | $payment_method = $_SESSION['payment_method'] = 'quotation'; |
| 376 | - $order_id = wpshop_checkout::process_checkout( $payment_method, ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
| 377 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
| 376 | + $order_id = wpshop_checkout::process_checkout($payment_method, (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
| 377 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
| 378 | 378 | } else { |
| 379 | 379 | $available_shipping_method = false; |
| 380 | - if( !empty($shipping_option) && !empty($shipping_option['modes']) && !$cart_is_downloadable ) { |
|
| 381 | - foreach( $shipping_option['modes'] as $shipping_mode_id => $shipping_mode ) { |
|
| 382 | - if( !empty($shipping_mode['active']) && $shipping_mode['active'] == 'on' ) { |
|
| 380 | + if (!empty($shipping_option) && !empty($shipping_option['modes']) && !$cart_is_downloadable) { |
|
| 381 | + foreach ($shipping_option['modes'] as $shipping_mode_id => $shipping_mode) { |
|
| 382 | + if (!empty($shipping_mode['active']) && $shipping_mode['active'] == 'on') { |
|
| 383 | 383 | $available_shipping_method = true; |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if( !$available_shipping_method ) { |
|
| 388 | + if (!$available_shipping_method) { |
|
| 389 | 389 | $_SESSION['shipping_method'] = 'No Shipping method required'; |
| 390 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 390 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 391 | 391 | |
| 392 | - if( !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' ) { |
|
| 392 | + if (!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') { |
|
| 393 | 393 | $status = true; |
| 394 | 394 | $payment_method = $_SESSION['payment_method'] = 'free'; |
| 395 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
| 396 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 397 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 398 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
| 395 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
| 396 | + $permalink_option = get_option('permalink_structure'); |
|
| 397 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 398 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
| 399 | 399 | // wpshop_tools::wpshop_safe_redirect( $url ); |
| 400 | 400 | $response = $url; |
| 401 | 401 | } |
| 402 | 402 | else { |
| 403 | 403 | $status = true; |
| 404 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
|
| 404 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=5'; |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | else { |
| 408 | 408 | $status = true; |
| 409 | - $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=4'; |
|
| 409 | + $response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=4'; |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | //Stock checking verification |
| 414 | 414 | $this->checking_stock(); |
| 415 | 415 | |
| 416 | - wp_die( json_encode( array( 'status' => $status, 'response' => $response ) ) ); |
|
| 416 | + wp_die(json_encode(array('status' => $status, 'response' => $response))); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * AJAX - Valid Checkout step four |
| 421 | 421 | */ |
| 422 | 422 | function wps_checkout_valid_step_four() { |
| 423 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 423 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 424 | 424 | |
| 425 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_four' ) ) |
|
| 425 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_four')) |
|
| 426 | 426 | wp_die(); |
| 427 | 427 | |
| 428 | - $shipping_method = ( !empty($_POST['shipping_mode']) ) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null; |
|
| 428 | + $shipping_method = (!empty($_POST['shipping_mode'])) ? wpshop_tools::varSanitizer($_POST['shipping_mode']) : null; |
|
| 429 | 429 | $status = false; |
| 430 | 430 | $response = ''; |
| 431 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 432 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 433 | - if ( !empty($shipping_method) ) { |
|
| 431 | + $permalink_option = get_option('permalink_structure'); |
|
| 432 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 433 | + if (!empty($shipping_method)) { |
|
| 434 | 434 | $status = true; |
| 435 | 435 | $_SESSION['shipping_method'] = $shipping_method; |
| 436 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 437 | - if ( !empty($_SESSION) && !empty( $_SESSION['cart'] ) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
| 436 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? wpshop_tools::varSanitizer($_SESSION['cart']['order_id']) : 0; |
|
| 437 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
| 438 | 438 | $partial_payment_for_quotation = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
| 439 | - if( isset( $partial_payment_for_quotation['for_quotation']['activate'] ) ) { |
|
| 439 | + if (isset($partial_payment_for_quotation['for_quotation']['activate'])) { |
|
| 440 | 440 | $step = '5'; |
| 441 | 441 | } else { |
| 442 | 442 | $payment_method = $_SESSION['payment_method'] = 'quotation'; |
| 443 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
| 443 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
| 444 | 444 | $step = '6'; |
| 445 | 445 | } |
| 446 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step; |
|
| 446 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=' . $step; |
|
| 447 | 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' ) { |
|
| 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') { |
|
| 449 | 449 | $payment_method = $_SESSION['payment_method'] = 'free'; |
| 450 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
| 451 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 452 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 453 | - $url = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
| 450 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
| 451 | + $permalink_option = get_option('permalink_structure'); |
|
| 452 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 453 | + $url = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
| 454 | 454 | $response = $url; |
| 455 | 455 | } |
| 456 | 456 | else { |
| 457 | - $response = get_permalink( wpshop_tools::get_page_id( $checkout_page_id ) ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=5'; |
|
| 457 | + $response = get_permalink(wpshop_tools::get_page_id($checkout_page_id)) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=5'; |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | else { |
| 461 | - $response .= '<div class="wps-alert-error">'.__( 'You must select a shipping method', 'wpshop' ).'</div>'; |
|
| 461 | + $response .= '<div class="wps-alert-error">' . __('You must select a shipping method', 'wpshop') . '</div>'; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | //Stock checking verification |
| 465 | 465 | $this->checking_stock(); |
| 466 | 466 | |
| 467 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
| 467 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 468 | 468 | die(); |
| 469 | 469 | } |
| 470 | 470 | |
@@ -472,46 +472,46 @@ discard block |
||
| 472 | 472 | * AJAX - Valid Checkout step four |
| 473 | 473 | */ |
| 474 | 474 | function wps_checkout_valid_step_five() { |
| 475 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 476 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_checkout_valid_step_five' ) ) |
|
| 475 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 476 | + if (!wp_verify_nonce($_wpnonce, 'wps_checkout_valid_step_five')) |
|
| 477 | 477 | wp_die(); |
| 478 | 478 | |
| 479 | 479 | $status = false; |
| 480 | 480 | $response = ''; |
| 481 | - $payment_method = ( !empty($_POST['wps-payment-method']) ) ? wpshop_tools::varSanitizer( $_POST['wps-payment-method'] ): null; |
|
| 482 | - $order_id = ( !empty($_SESSION['cart']['order_id']) ) ? (int) $_SESSION['cart']['order_id'] : 0; |
|
| 483 | - $customer_comment = ( !empty($_POST['wps-customer-comment']) ) ? wpshop_tools::varSanitizer( $_POST['wps-customer-comment'] ) : null; |
|
| 481 | + $payment_method = (!empty($_POST['wps-payment-method'])) ? wpshop_tools::varSanitizer($_POST['wps-payment-method']) : null; |
|
| 482 | + $order_id = (!empty($_SESSION['cart']['order_id'])) ? (int)$_SESSION['cart']['order_id'] : 0; |
|
| 483 | + $customer_comment = (!empty($_POST['wps-customer-comment'])) ? wpshop_tools::varSanitizer($_POST['wps-customer-comment']) : null; |
|
| 484 | 484 | |
| 485 | - $terms_of_sale_required = isset( $_POST['terms_of_sale_indicator'] ) && !empty( $_POST['terms_of_sale_indicator'] ) ? (bool)$_POST['terms_of_sale_indicator'] : (bool)false; |
|
| 486 | - $terms_of_sale_checked = isset( $_POST['terms_of_sale'] ) && !empty( $_POST['terms_of_sale'] ) ? (bool)$_POST['terms_of_sale_indicator'] : (bool)false; |
|
| 485 | + $terms_of_sale_required = isset($_POST['terms_of_sale_indicator']) && !empty($_POST['terms_of_sale_indicator']) ? (bool)$_POST['terms_of_sale_indicator'] : (bool)false; |
|
| 486 | + $terms_of_sale_checked = isset($_POST['terms_of_sale']) && !empty($_POST['terms_of_sale']) ? (bool)$_POST['terms_of_sale_indicator'] : (bool)false; |
|
| 487 | 487 | |
| 488 | - if ( ( $terms_of_sale_required && $terms_of_sale_checked ) || !$terms_of_sale_required ) { |
|
| 489 | - if ( !empty($payment_method) ) { |
|
| 488 | + if (($terms_of_sale_required && $terms_of_sale_checked) || !$terms_of_sale_required) { |
|
| 489 | + if (!empty($payment_method)) { |
|
| 490 | 490 | /** Check if the payment method exist for the shop **/ |
| 491 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 491 | + $payment_option = get_option('wps_payment_mode'); |
|
| 492 | 492 | |
| 493 | - if( !empty($payment_option) && !empty($payment_option['mode']) && array_key_exists( $payment_method, $payment_option['mode']) && !empty($payment_option['mode'][$payment_method]['active']) ) { |
|
| 494 | - if( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) { |
|
| 493 | + if (!empty($payment_option) && !empty($payment_option['mode']) && array_key_exists($payment_method, $payment_option['mode']) && !empty($payment_option['mode'][$payment_method]['active'])) { |
|
| 494 | + if (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') { |
|
| 495 | 495 | $new_payment_method = $payment_method; |
| 496 | 496 | $payment_method = 'quotation'; |
| 497 | 497 | $is_quotation = true; |
| 498 | 498 | } else { |
| 499 | 499 | $is_quotation = false; |
| 500 | 500 | } |
| 501 | - $order_id = wpshop_checkout::process_checkout( $payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address'] ); |
|
| 502 | - if( !empty($order_id) && !empty($customer_comment) ) { |
|
| 501 | + $order_id = wpshop_checkout::process_checkout($payment_method, $order_id, get_current_user_id(), $_SESSION['billing_address'], $_SESSION['shipping_address']); |
|
| 502 | + if (!empty($order_id) && !empty($customer_comment)) { |
|
| 503 | 503 | $wps_back_office_orders_mdl = new wps_back_office_orders_mdl(); |
| 504 | 504 | $wps_back_office_orders_mdl->add_private_comment($order_id, $customer_comment); |
| 505 | 505 | //wp_update_post( array('ID' => $order_id, 'post_excerpt' => $customer_comment) ); |
| 506 | 506 | } |
| 507 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 508 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 509 | - $response = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=6'; |
|
| 510 | - if( $is_quotation ) { |
|
| 511 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 512 | - $params = array( 'method' => $new_payment_method, 'waited_amount' => $order_meta['order_partial_payment'], 'status' => 'waiting_payment', 'author' => get_current_user_id() ); |
|
| 507 | + $permalink_option = get_option('permalink_structure'); |
|
| 508 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 509 | + $response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=6'; |
|
| 510 | + if ($is_quotation) { |
|
| 511 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 512 | + $params = array('method' => $new_payment_method, 'waited_amount' => $order_meta['order_partial_payment'], 'status' => 'waiting_payment', 'author' => get_current_user_id()); |
|
| 513 | 513 | $order_meta['order_payment']['received'][0] = $params; |
| 514 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 514 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 515 | 515 | $_SESSION['payment_method'] = $new_payment_method; |
| 516 | 516 | } else { |
| 517 | 517 | $_SESSION['payment_method'] = $payment_method; |
@@ -519,22 +519,22 @@ discard block |
||
| 519 | 519 | $status = true; |
| 520 | 520 | //Add an action to extra actions on order save |
| 521 | 521 | // @TODO : REQUEST |
| 522 | - $args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST); |
|
| 523 | - wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args ); |
|
| 522 | + $args = array('order_id' => $order_id, 'posted_data' => $_REQUEST); |
|
| 523 | + wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args); |
|
| 524 | 524 | } |
| 525 | 525 | else { |
| 526 | - $response = '<div class="wps-alert-error">' .__( 'This payment method is unavailable', 'wpshop' ).'</div>'; |
|
| 526 | + $response = '<div class="wps-alert-error">' . __('This payment method is unavailable', 'wpshop') . '</div>'; |
|
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | else { |
| 530 | - $response = '<div class="wps-alert-error">' .__( 'You must choose a payment method', 'wpshop' ).'</div>'; |
|
| 530 | + $response = '<div class="wps-alert-error">' . __('You must choose a payment method', 'wpshop') . '</div>'; |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | else { |
| 534 | - $response = '<div class="wps-alert-error">' .__( 'You must accept the terms of sale to order', 'wpshop' ).'</div>'; |
|
| 534 | + $response = '<div class="wps-alert-error">' . __('You must accept the terms of sale to order', 'wpshop') . '</div>'; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - echo json_encode( array('status' => $status, 'response' => $response) ); |
|
| 537 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 538 | 538 | die(); |
| 539 | 539 | } |
| 540 | 540 | |
@@ -542,15 +542,15 @@ discard block |
||
| 542 | 542 | * Checking stock in differents checkout steps |
| 543 | 543 | */ |
| 544 | 544 | function checking_stock() { |
| 545 | - if( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) { |
|
| 546 | - foreach( $_SESSION['cart']['order_items'] as $item_id => $item ) { |
|
| 545 | + if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) { |
|
| 546 | + foreach ($_SESSION['cart']['order_items'] as $item_id => $item) { |
|
| 547 | 547 | $wps_product = new wps_product_ctr(); |
| 548 | - $checking = $wps_product->check_stock( $item['item_id'], $item['item_qty'], $item_id ); |
|
| 549 | - if( $checking !== true ) { |
|
| 550 | - unset( $_SESSION['cart']['order_items'][$item_id] ); |
|
| 548 | + $checking = $wps_product->check_stock($item['item_id'], $item['item_qty'], $item_id); |
|
| 549 | + if ($checking !== true) { |
|
| 550 | + unset($_SESSION['cart']['order_items'][$item_id]); |
|
| 551 | 551 | $wps_cart_ctr = new wps_cart(); |
| 552 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
| 553 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
| 552 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
| 553 | + $wps_cart_ctr->store_cart_in_session($order); |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | } |
@@ -558,6 +558,6 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | -if ( class_exists("wps_classic_checkout") ) { |
|
| 561 | +if (class_exists("wps_classic_checkout")) { |
|
| 562 | 562 | $wps_classic_checkout = new wps_classic_checkout(); |
| 563 | 563 | } |
@@ -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]> |
@@ -75,8 +77,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |