Completed
Push — master ( b0f2bc...f5c725 )
by
unknown
52:31
created
includes/modules/wps_orders/templates/frontend/order_row_in_account.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 ?>
3 3
 <div class="wps-table-content wps-table-row">
4
-	<?php $order_status = unserialize( WPSHOP_ORDER_STATUS ); ?>
5
-	<?php $color_label = array( 'awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu' ); ?>
6
-	<?php $currency = wpshop_tools::wpshop_get_currency( false ); ?>
7
-	<div class="wps-table-cell"><?php echo !empty( $order_meta['order_date'] ) ? mysql2date( get_option('date_format'), $order_meta['order_date'], true ) . '<br>' . mysql2date( get_option('time_format'), $order_meta['order_date'], true ) : ''; ?></div>
8
-	<div class="wps-table-cell"><?php echo !empty( $order_meta['order_key'] ) ? $order_meta['order_key'] : ( !empty( $order_meta['order_temporary_key'] ) ? $order_meta['order_temporary_key'] : '' ); ?></div>
9
-	<div class="wps-table-cell"><?php echo !empty( $order_meta['order_grand_total'] ) ? wpshop_tools::formate_number( $order_meta['order_grand_total'] ).' '.$currency : ''; ?></div>
4
+	<?php $order_status = unserialize(WPSHOP_ORDER_STATUS); ?>
5
+	<?php $color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu'); ?>
6
+	<?php $currency = wpshop_tools::wpshop_get_currency(false); ?>
7
+	<div class="wps-table-cell"><?php echo !empty($order_meta['order_date']) ? mysql2date(get_option('date_format'), $order_meta['order_date'], true) . '<br>' . mysql2date(get_option('time_format'), $order_meta['order_date'], true) : ''; ?></div>
8
+	<div class="wps-table-cell"><?php echo !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_temporary_key']) ? $order_meta['order_temporary_key'] : ''); ?></div>
9
+	<div class="wps-table-cell"><?php echo !empty($order_meta['order_grand_total']) ? wpshop_tools::formate_number($order_meta['order_grand_total']) . ' ' . $currency : ''; ?></div>
10 10
 	<div class="wps-table-cell">
11
-		<span class="wps-label-<?php echo $color_label[$order_meta['order_status']]; ?>"><?php _e( $order_status[$order_meta['order_status']], 'wpshop' ); ?></span>
11
+		<span class="wps-label-<?php echo $color_label[$order_meta['order_status']]; ?>"><?php _e($order_status[$order_meta['order_status']], 'wpshop'); ?></span>
12 12
 	</div>
13 13
 	<div class="wps-table-cell">
14
-		<?php if(!empty($order_meta['order_trackingLink'])):?>
14
+		<?php if (!empty($order_meta['order_trackingLink'])):?>
15 15
 			<?php /** Check if http:// it's found in the link */
16 16
 			$url = $order_meta['order_trackingLink'];
17
-			if('http://' != substr($url, 0, 7))
17
+			if ('http://' != substr($url, 0, 7))
18 18
 				$url = 'http://' . $url;
19 19
 			?>
20 20
 			<a href="<?php echo $url; ?>" target="_blank"><?php echo !empty($order_meta['order_trackingNumber']) ? $order_meta['order_trackingNumber'] : ""; ?></a>
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 			<?php _e('No tracking links', 'wpshop'); ?>
23 23
 		<?php endif; ?>
24 24
 	</div>
25
-	<?php if( !is_admin() ): ?>
25
+	<?php if (!is_admin()): ?>
26 26
 		<div class="wps-table-cell wps-customer-order-list-actions">
27
-			<button data-nonce="<?php echo wp_create_nonce( 'wps_orders_load_details' ); ?>" class="wps-bton-third wps-orders-details-opener" id="wps-order-details-opener-<?php echo $order_id; ?>"><?php _e( 'Order details', 'wpshop' ); ?></button>
27
+			<button data-nonce="<?php echo wp_create_nonce('wps_orders_load_details'); ?>" class="wps-bton-third wps-orders-details-opener" id="wps-order-details-opener-<?php echo $order_id; ?>"><?php _e('Order details', 'wpshop'); ?></button>
28 28
 
29
-			<?php if( !empty( $order_meta ) && $order_meta['order_status'] != 'canceled' && ( ( !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' ) || !empty( $order_meta['order_temporary_key'] ) ) && (float) $order_meta['order_amount_to_pay_now'] != (float) 0 ) : ?>
30
-				<a href="<?php echo wpshop_checkout::wps_direct_payment_link_url($order_id); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e( 'Pay quotation', 'wpshop' ); ?></a>
29
+			<?php if (!empty($order_meta) && $order_meta['order_status'] != 'canceled' && ((!empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation') || !empty($order_meta['order_temporary_key'])) && (float)$order_meta['order_amount_to_pay_now'] != (float)0) : ?>
30
+				<a href="<?php echo wpshop_checkout::wps_direct_payment_link_url($order_id); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e('Pay quotation', 'wpshop'); ?></a>
31 31
 			<?php endif; ?>
32 32
 
33
-			<?php if ( !empty( $order_meta ) && !empty( $order_meta[ 'order_invoice_ref' ] ) ) : ?>
34
-			<br/><a href="<?php echo admin_url( 'admin-post.php?action=wps_invoice&order_id='.$order_id.'&invoice_ref='.$order_meta[ 'order_invoice_ref' ].'&mode=pdf' ); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e( 'Download invoice', 'wpshop' ); ?></a>
33
+			<?php if (!empty($order_meta) && !empty($order_meta['order_invoice_ref'])) : ?>
34
+			<br/><a href="<?php echo admin_url('admin-post.php?action=wps_invoice&order_id=' . $order_id . '&invoice_ref=' . $order_meta['order_invoice_ref'] . '&mode=pdf'); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e('Download invoice', 'wpshop'); ?></a>
35 35
 			<?php endif; ?>
36 36
 
37 37
 			<!-- Display delete order -->
38 38
 			<?php $wpshop_display_delete_order_option = get_option('wpshop_display_option'); ?>
39
-			<?php if( !empty($wpshop_display_delete_order_option) && !empty($wpshop_display_delete_order_option['wpshop_display_delete_order']) && $wpshop_display_delete_order_option['wpshop_display_delete_order'] && !empty( $order_meta ) && $order_meta['order_status'] == 'awaiting_payment' ):?>
40
-			<br/><button data-nonce="<?php echo wp_create_nonce( 'wps_delete_order' ); ?>" class="wps-bton-first-mini-rounded wps-orders-delete button-secondary" data-id="<?php echo $order_id; ?>"><?php _e( 'Delete order', 'wpshop' ); ?></button>
39
+			<?php if (!empty($wpshop_display_delete_order_option) && !empty($wpshop_display_delete_order_option['wpshop_display_delete_order']) && $wpshop_display_delete_order_option['wpshop_display_delete_order'] && !empty($order_meta) && $order_meta['order_status'] == 'awaiting_payment'):?>
40
+			<br/><button data-nonce="<?php echo wp_create_nonce('wps_delete_order'); ?>" class="wps-bton-first-mini-rounded wps-orders-delete button-secondary" data-id="<?php echo $order_id; ?>"><?php _e('Delete order', 'wpshop'); ?></button>
41 41
 			<?php endif; ?>
42 42
 		</div>
43 43
 	<?php else : ?>
44
-		<div class="wps-table-cell"><a href="<?php echo admin_url( 'post.php?post='.$order_id.'&action=edit' ); ?>" target="_blank" role="button" class="wps-bton-first-mini-rounded" ><?php _e( 'Order details', 'wpshop' ); ?></a></div>
44
+		<div class="wps-table-cell"><a href="<?php echo admin_url('post.php?post=' . $order_id . '&action=edit'); ?>" target="_blank" role="button" class="wps-bton-first-mini-rounded" ><?php _e('Order details', 'wpshop'); ?></a></div>
45 45
 	<?php endif?>
46 46
 </div>
Please login to merge, or discard this patch.
includes/modules/wps_cart/controller/wps_cart_ctr.php 1 patch
Spacing   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -1,48 +1,48 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 class wps_cart {
3 3
 
4 4
 	function __construct() {
5 5
 		/** WPShop Cart Shortcode **/
6
-		add_shortcode( 'wps_cart', array( &$this, 'display_cart' ) );
7
-		add_shortcode( 'wpshop_cart', array( &$this, 'display_cart' ) );
6
+		add_shortcode('wps_cart', array(&$this, 'display_cart'));
7
+		add_shortcode('wpshop_cart', array(&$this, 'display_cart'));
8 8
 		/** WPShop Mini Cart Shortcode **/
9
-		add_shortcode( 'wps_mini_cart', array( &$this, 'display_mini_cart' ) );
10
-		add_shortcode( 'wpshop_mini_cart', array( &$this, 'display_mini_cart' ) );
9
+		add_shortcode('wps_mini_cart', array(&$this, 'display_mini_cart'));
10
+		add_shortcode('wpshop_mini_cart', array(&$this, 'display_mini_cart'));
11 11
 		/** WPShop Resume Cart Shorcode **/
12
-		add_shortcode( 'wps_resume_cart', array( &$this, 'display_resume_cart' ) );
13
-		add_shortcode( 'wpshop_resume_cart', array( &$this, 'display_resume_cart' ) );
12
+		add_shortcode('wps_resume_cart', array(&$this, 'display_resume_cart'));
13
+		add_shortcode('wpshop_resume_cart', array(&$this, 'display_resume_cart'));
14 14
 		/** Apply Coupon Interface **/
15
-		add_shortcode( 'wps_apply_coupon', array( &$this, 'display_apply_coupon_interface' ) );
16
-		add_shortcode( 'wpshop_apply_coupon', array( &$this, 'display_apply_coupon_interface' ) );
15
+		add_shortcode('wps_apply_coupon', array(&$this, 'display_apply_coupon_interface'));
16
+		add_shortcode('wpshop_apply_coupon', array(&$this, 'display_apply_coupon_interface'));
17 17
 		/** NUmeration Cart **/
18
-		add_shortcode( 'wps-numeration-cart', array( &$this, 'display_wps_numeration_cart' ) );
19
-		add_shortcode( 'wpshop-numeration-cart', array( &$this, 'display_wps_numeration_cart' ) );
18
+		add_shortcode('wps-numeration-cart', array(&$this, 'display_wps_numeration_cart'));
19
+		add_shortcode('wpshop-numeration-cart', array(&$this, 'display_wps_numeration_cart'));
20 20
 		/** Button add to cart */
21
-		add_shortcode( 'wpshop_button_add_to_cart', array( &$this, 'display_button_add_to_cart' ) );
21
+		add_shortcode('wpshop_button_add_to_cart', array(&$this, 'display_button_add_to_cart'));
22 22
 
23
-		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
24
-		add_action( 'init', array( $this, 'load_cart_from_db' ) );
23
+		add_action('wp_enqueue_scripts', array($this, 'add_scripts'));
24
+		add_action('init', array($this, 'load_cart_from_db'));
25 25
 
26 26
 		/** Ajax Actions **/
27
-		add_action( 'wp_ajax_wps_reload_cart', array( $this, 'wps_reload_cart' ) );
28
-		add_action( 'wp_ajax_nopriv_wps_reload_cart', array( $this, 'wps_reload_cart' ) );
27
+		add_action('wp_ajax_wps_reload_cart', array($this, 'wps_reload_cart'));
28
+		add_action('wp_ajax_nopriv_wps_reload_cart', array($this, 'wps_reload_cart'));
29 29
 
30
-		add_action( 'wp_ajax_wps_reload_mini_cart', array( &$this, 'wps_reload_mini_cart' ) );
31
-		add_action( 'wp_ajax_nopriv_wps_reload_mini_cart', array( &$this, 'wps_reload_mini_cart' ) );
30
+		add_action('wp_ajax_wps_reload_mini_cart', array(&$this, 'wps_reload_mini_cart'));
31
+		add_action('wp_ajax_nopriv_wps_reload_mini_cart', array(&$this, 'wps_reload_mini_cart'));
32 32
 
33
-		add_action( 'wp_ajax_wps_reload_summary_cart', array( &$this, 'wps_reload_summary_cart' ) );
34
-		add_action( 'wp_ajax_nopriv_wps_reload_summary_cart', array( &$this, 'wps_reload_summary_cart' ) );
33
+		add_action('wp_ajax_wps_reload_summary_cart', array(&$this, 'wps_reload_summary_cart'));
34
+		add_action('wp_ajax_nopriv_wps_reload_summary_cart', array(&$this, 'wps_reload_summary_cart'));
35 35
 
36
-		add_action( 'wp_ajax_wps_apply_coupon', array( &$this, 'wps_apply_coupon' ) );
37
-		add_action( 'wp_ajax_nopriv_wps_apply_coupon', array( &$this, 'wps_apply_coupon' ) );
36
+		add_action('wp_ajax_wps_apply_coupon', array(&$this, 'wps_apply_coupon'));
37
+		add_action('wp_ajax_nopriv_wps_apply_coupon', array(&$this, 'wps_apply_coupon'));
38 38
 
39
-		add_action( 'wp_ajax_wps_cart_pass_to_step_two', array( &$this, 'wps_cart_pass_to_step_two' ) );
40
-		add_action( 'wp_ajax_nopriv_wps_cart_pass_to_step_two', array( &$this, 'wps_cart_pass_to_step_two' ) );
39
+		add_action('wp_ajax_wps_cart_pass_to_step_two', array(&$this, 'wps_cart_pass_to_step_two'));
40
+		add_action('wp_ajax_nopriv_wps_cart_pass_to_step_two', array(&$this, 'wps_cart_pass_to_step_two'));
41 41
 
42
-		add_action( 'wp_ajax_wps_empty_cart', array( &$this, 'wps_empty_cart' ) );
43
-		add_action( 'wp_ajax_nopriv_wps_empty_cart', array( &$this, 'wps_empty_cart' ) );
42
+		add_action('wp_ajax_wps_empty_cart', array(&$this, 'wps_empty_cart'));
43
+		add_action('wp_ajax_nopriv_wps_empty_cart', array(&$this, 'wps_empty_cart'));
44 44
 
45
-		add_action( 'wsphop_options', array(&$this, 'declare_options' ), 8);
45
+		add_action('wsphop_options', array(&$this, 'declare_options'), 8);
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function add_scripts() {
52 52
 		wp_enqueue_script('jquery');
53
-		wp_enqueue_script( 'wps_cart_js',  WPS_CART_URL . WPS_CART_DIR.'/assets/frontend/js/wps_cart.js' );
53
+		wp_enqueue_script('wps_cart_js', WPS_CART_URL . WPS_CART_DIR . '/assets/frontend/js/wps_cart.js');
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * Declare Cart Options
58 58
 	 */
59
-	public static function declare_options () {
60
-		if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
61
-			$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
62
-			$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : '';
59
+	public static function declare_options() {
60
+		if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
61
+			$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
62
+			$old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : '';
63 63
 
64
-			if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' )
65
-				&& ( $old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation' ) ) {
64
+			if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation')
65
+				&& ($old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation')) {
66 66
 					/**	Add module option to wpshop general options	*/
67 67
 					register_setting('wpshop_options', 'wpshop_cart_option', array('wps_cart', 'wpshop_options_validate_cart_type'));
68 68
 					add_settings_field('wpshop_cart_type', __('Which type of cart do you want to display', 'wpshop'), array('wps_cart', 'wpshop_cart_type_field'), 'wpshop_cart_info', 'wpshop_cart_info');
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param unknown_type $input
76 76
 	 * @return unknown
77 77
 	 */
78
-	public static function wpshop_options_validate_cart_type( $input ) {
78
+	public static function wpshop_options_validate_cart_type($input) {
79 79
 		return $input;
80 80
 	}
81 81
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * Cart Options Fields
84 84
 	 */
85 85
 	public static function wpshop_cart_type_field() {
86
-		$cart_option = get_option( 'wpshop_cart_option' );
86
+		$cart_option = get_option('wpshop_cart_option');
87 87
 
88 88
 		$output  = '<select name="wpshop_cart_option[cart_type]">';
89
-		$output .= '<option value="simplified_ati" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_ati' ) ? 'selected="selected"' : ''). ' >' .__( 'Simplified cart ATI', 'wpshop'). '</option>';
90
-		$output .= '<option value="simplified_et" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_et' ) ? 'selected="selected"' : ''). ' >' .__( 'Simplified cart ET', 'wpshop'). '</option>';
91
-		$output .= '<option value="full_cart" ' .( ( !empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'full_cart' ) ? 'selected="selected"' : ''). ' >' .__( 'Full cart', 'wpshop'). '</option>';
89
+		$output .= '<option value="simplified_ati" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_ati') ? 'selected="selected"' : '') . ' >' . __('Simplified cart ATI', 'wpshop') . '</option>';
90
+		$output .= '<option value="simplified_et" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'simplified_et') ? 'selected="selected"' : '') . ' >' . __('Simplified cart ET', 'wpshop') . '</option>';
91
+		$output .= '<option value="full_cart" ' . ((!empty($cart_option) && !empty($cart_option['cart_type']) && $cart_option['cart_type'] == 'full_cart') ? 'selected="selected"' : '') . ' >' . __('Full cart', 'wpshop') . '</option>';
92 92
 		$output .= '</select>';
93 93
 
94 94
 		echo $output;
95 95
 	}
96 96
 
97 97
 	/** Display Cart **/
98
-	function display_cart( $args ) {
99
-		$cart_type = ( !empty($args) && !empty($args['cart_type']) ) ?  $args['cart_type']: '';
100
-		$oid =  ( !empty($args) && !empty($args['oid']) ) ?  $args['oid'] : '';
101
-		$output  = '<div id="wps_cart_container" data-nonce="' . wp_create_nonce( 'wps_reload_cart' ) . '" class="wps-bloc-loader wps-cart-wrapper">';
98
+	function display_cart($args) {
99
+		$cart_type = (!empty($args) && !empty($args['cart_type'])) ? $args['cart_type'] : '';
100
+		$oid = (!empty($args) && !empty($args['oid'])) ? $args['oid'] : '';
101
+		$output  = '<div id="wps_cart_container" data-nonce="' . wp_create_nonce('wps_reload_cart') . '" class="wps-bloc-loader wps-cart-wrapper">';
102 102
 		$output .= self::cart_content($cart_type, $oid);
103 103
 		$output .= '</div>';
104 104
 
@@ -106,84 +106,84 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 	/** Cart Content **/
109
-	public static function cart_content( $cart_type = '', $oid = '' ) {
109
+	public static function cart_content($cart_type = '', $oid = '') {
110 110
 		global $wpdb;
111 111
 		$output = '';
112 112
 		$account_origin = false;
113
-		$cart_option = get_option( 'wpshop_cart_option' );
114
-		$cart_option = ( !empty($cart_option) && !empty($cart_option['cart_type']) ) ? $cart_option['cart_type'] : 'simplified_ati';
113
+		$cart_option = get_option('wpshop_cart_option');
114
+		$cart_option = (!empty($cart_option) && !empty($cart_option['cart_type'])) ? $cart_option['cart_type'] : 'simplified_ati';
115 115
 
116
-		$price_piloting  = get_option( 'wpshop_shop_price_piloting' );
116
+		$price_piloting = get_option('wpshop_shop_price_piloting');
117 117
 
118 118
 		$coupon_title = $coupon_value = '';
119
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
120
-		if( !empty($oid) ) {
119
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
120
+		if (!empty($oid)) {
121 121
 			$account_origin = true;
122
-			$cart_content = get_post_meta( $oid, '_order_postmeta', true);
122
+			$cart_content = get_post_meta($oid, '_order_postmeta', true);
123 123
 		}
124
-		$currency = wpshop_tools::wpshop_get_currency( false );
124
+		$currency = wpshop_tools::wpshop_get_currency(false);
125 125
 
126
-		if ( !empty($cart_content) ) {
127
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
126
+		if (!empty($cart_content)) {
127
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
128 128
 
129
-			if ( !empty($cart_content['coupon_id']) ) {
130
-				$coupon_title = get_the_title( $cart_content['coupon_id']);
131
-				$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
129
+			if (!empty($cart_content['coupon_id'])) {
130
+				$coupon_title = get_the_title($cart_content['coupon_id']);
131
+				$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
132 132
 			}
133 133
 
134
-			if ( !empty($cart_items) ) {
134
+			if (!empty($cart_items)) {
135 135
 				/** Total values **/
136
-				$shipping_cost_et = ( !empty($cart_content['order_shipping_cost']) ) ? ( (!empty($price_piloting) && $price_piloting != 'HT') ? ( $cart_content['order_shipping_cost'] / ( 1 + ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) ) ) : $cart_content['order_shipping_cost'] ) : 0;
137
-				$shipping_cost_vat = ( !empty( $shipping_cost_et) ) ? ( $shipping_cost_et * ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) ) : 0;
138
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? ( (!empty($price_piloting) && $price_piloting != 'HT') ? $cart_content['order_shipping_cost'] : $cart_content['order_shipping_cost'] + $shipping_cost_vat ) : 0;
139
-				$total_et = ( !empty( $cart_content['order_total_ht']) ) ? $cart_content['order_total_ht'] : 0;
140
-				$order_totla_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
141
-				$order_amount_to_pay_now = wpshop_tools::formate_number( $cart_content['order_amount_to_pay_now'] );
142
-				$total_ati = ( !empty( $order_amount_to_pay_now ) && !empty($oid) && $order_amount_to_pay_now > 0 ) ? $cart_content['order_amount_to_pay_now'] : ( (!empty($cart_content['order_grand_total']) ) ? $cart_content['order_grand_total'] : 0 );
136
+				$shipping_cost_et = (!empty($cart_content['order_shipping_cost'])) ? ((!empty($price_piloting) && $price_piloting != 'HT') ? ($cart_content['order_shipping_cost'] / (1 + (WPSHOP_VAT_ON_SHIPPING_COST / 100))) : $cart_content['order_shipping_cost']) : 0;
137
+				$shipping_cost_vat = (!empty($shipping_cost_et)) ? ($shipping_cost_et * (WPSHOP_VAT_ON_SHIPPING_COST / 100)) : 0;
138
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? ((!empty($price_piloting) && $price_piloting != 'HT') ? $cart_content['order_shipping_cost'] : $cart_content['order_shipping_cost'] + $shipping_cost_vat) : 0;
139
+				$total_et = (!empty($cart_content['order_total_ht'])) ? $cart_content['order_total_ht'] : 0;
140
+				$order_totla_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
141
+				$order_amount_to_pay_now = wpshop_tools::formate_number($cart_content['order_amount_to_pay_now']);
142
+				$total_ati = (!empty($order_amount_to_pay_now) && !empty($oid) && $order_amount_to_pay_now > 0) ? $cart_content['order_amount_to_pay_now'] : ((!empty($cart_content['order_grand_total'])) ? $cart_content['order_grand_total'] : 0);
143 143
 				unset($tracking);
144
-				if( !empty($cart_content['order_trackingNumber']) ) {
144
+				if (!empty($cart_content['order_trackingNumber'])) {
145 145
 					$tracking['number'] = $cart_content['order_trackingNumber'];
146 146
 				}
147
-				if( !empty($cart_content['order_trackingLink']) ) {
147
+				if (!empty($cart_content['order_trackingLink'])) {
148 148
 					$tracking['link'] = $cart_content['order_trackingLink'];
149 149
 				}
150 150
 				ob_start();
151
-				require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart") );
151
+				require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart"));
152 152
 				$output = ob_get_contents();
153 153
 				ob_end_clean();
154 154
 			}
155 155
 			else {
156
-				return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
156
+				return '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; ;
157 157
 			}
158 158
 		}
159 159
 		else {
160
-			return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
160
+			return '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; ;
161 161
 		}
162 162
 		return $output;
163 163
 	}
164 164
 
165 165
 	/** Display mini cart **/
166
-	function display_mini_cart( $args ) {
166
+	function display_mini_cart($args) {
167 167
 		$total_cart_item = 0;
168
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
169
-		$type = ( !empty($args) && !empty($args['type']) ) ? $args['type'] : '';
168
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
169
+		$type = (!empty($args) && !empty($args['type'])) ? $args['type'] : '';
170 170
 
171 171
 
172
-		if ( !empty($cart_content) ) {
173
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
172
+		if (!empty($cart_content)) {
173
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
174 174
 			/** Count items **/
175
-			$total_cart_item = self::total_cart_items( $cart_items );
176
-			$mini_cart_body = self::mini_cart_content( $type );
175
+			$total_cart_item = self::total_cart_items($cart_items);
176
+			$mini_cart_body = self::mini_cart_content($type);
177 177
 		}
178 178
 		else {
179
-			$mini_cart_body = __( 'Your cart is empty', 'wpshop' );
179
+			$mini_cart_body = __('Your cart is empty', 'wpshop');
180 180
 		}
181 181
 		ob_start();
182
-		if( !empty($type) && $type == 'fixed' ) {
183
-			require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart") );
182
+		if (!empty($type) && $type == 'fixed') {
183
+			require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart"));
184 184
 		}
185 185
 		else {
186
-			require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart") );
186
+			require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart"));
187 187
 		}
188 188
 
189 189
 		$output = ob_get_contents();
@@ -192,37 +192,37 @@  discard block
 block discarded – undo
192 192
 	}
193 193
 
194 194
 	/** Mini cart Content **/
195
-	public static function mini_cart_content( $type = '') {
196
-		$currency = wpshop_tools::wpshop_get_currency( false );
197
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
195
+	public static function mini_cart_content($type = '') {
196
+		$currency = wpshop_tools::wpshop_get_currency(false);
197
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
198 198
 		$output = '';
199
-		if ( !empty($cart_content) ) {
200
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
201
-			if ( !empty($cart_items) ) {
202
-				if ( !empty($cart_content['coupon_id']) ) {
203
-					$coupon_title = get_the_title( $cart_content['coupon_id']);
204
-					$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
199
+		if (!empty($cart_content)) {
200
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
201
+			if (!empty($cart_items)) {
202
+				if (!empty($cart_content['coupon_id'])) {
203
+					$coupon_title = get_the_title($cart_content['coupon_id']);
204
+					$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
205 205
 				}
206
-				$order_total_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
207
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? $cart_content['order_shipping_cost'] : 0;
208
-				$total_ati  = $total_cart = ( !empty($cart_content['order_amount_to_pay_now']) ) ? $cart_content['order_amount_to_pay_now'] : 0;
206
+				$order_total_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
207
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? $cart_content['order_shipping_cost'] : 0;
208
+				$total_ati = $total_cart = (!empty($cart_content['order_amount_to_pay_now'])) ? $cart_content['order_amount_to_pay_now'] : 0;
209 209
 
210 210
 				ob_start();
211
-				if( !empty($type) && $type == 'fixed' ) {
212
-					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content") );
211
+				if (!empty($type) && $type == 'fixed') {
212
+					require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content"));
213 213
 				}
214 214
 				else {
215
-					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content") );
215
+					require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content"));
216 216
 				}
217 217
 				$output = ob_get_contents();
218 218
 				ob_end_clean();
219 219
 			}
220 220
 			else {
221
-				$output = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
221
+				$output = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
222 222
 			}
223 223
 		}
224 224
 		else {
225
-			$output = '<div class="wps-alert-info">' . __( 'Your cart is empty', 'wpshop' ).'</div>';
225
+			$output = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
226 226
 		}
227 227
 		return $output;
228 228
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	function display_resume_cart() {
232 232
 		$cart_summary_content = self::resume_cart_content();
233 233
 		ob_start();
234
-		require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart") );
234
+		require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart"));
235 235
 		$output = ob_get_contents();
236 236
 		ob_end_clean();
237 237
 		return $output;
@@ -240,29 +240,29 @@  discard block
 block discarded – undo
240 240
 	/** Resume cart Content **/
241 241
 	public static function resume_cart_content() {
242 242
 		$output = '';
243
-		$currency = wpshop_tools::wpshop_get_currency( false );
244
-		$cart_content = ( !empty($_SESSION) && !empty($_SESSION['cart']) ) ? $_SESSION['cart'] : array();
245
-		if ( !empty($cart_content) ) {
246
-			$cart_items = ( !empty($cart_content['order_items']) ) ? $cart_content['order_items'] : array();
247
-			if ( !empty($cart_items) ) {
248
-				if ( !empty($cart_content['coupon_id']) ) {
249
-					$coupon_title = get_the_title( $cart_content['coupon_id']);
250
-					$coupon_value = wpshop_tools::formate_number( $cart_content['order_discount_amount_total_cart'] );
243
+		$currency = wpshop_tools::wpshop_get_currency(false);
244
+		$cart_content = (!empty($_SESSION) && !empty($_SESSION['cart'])) ? $_SESSION['cart'] : array();
245
+		if (!empty($cart_content)) {
246
+			$cart_items = (!empty($cart_content['order_items'])) ? $cart_content['order_items'] : array();
247
+			if (!empty($cart_items)) {
248
+				if (!empty($cart_content['coupon_id'])) {
249
+					$coupon_title = get_the_title($cart_content['coupon_id']);
250
+					$coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']);
251 251
 				}
252
-				$order_total_before_discount = ( !empty($cart_content['order_grand_total_before_discount']) ) ? $cart_content['order_grand_total_before_discount'] : 0;
253
-				$shipping_cost_ati = ( !empty($cart_content['order_shipping_cost']) ) ? $cart_content['order_shipping_cost'] : 0;
254
-				$total_ati  = $total_cart = ( !empty($cart_content['order_amount_to_pay_now']) ) ? $cart_content['order_amount_to_pay_now'] : 0;
252
+				$order_total_before_discount = (!empty($cart_content['order_grand_total_before_discount'])) ? $cart_content['order_grand_total_before_discount'] : 0;
253
+				$shipping_cost_ati = (!empty($cart_content['order_shipping_cost'])) ? $cart_content['order_shipping_cost'] : 0;
254
+				$total_ati = $total_cart = (!empty($cart_content['order_amount_to_pay_now'])) ? $cart_content['order_amount_to_pay_now'] : 0;
255 255
 				ob_start();
256
-				require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content") );
256
+				require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content"));
257 257
 				$output = ob_get_contents();
258 258
 				ob_end_clean();
259 259
 			}
260 260
 			else {
261
-				$resume_cart_body = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
261
+				$resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
262 262
 			}
263 263
 		}
264 264
 		else {
265
-			$resume_cart_body ='<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
265
+			$resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>';
266 266
 		}
267 267
 		return $output;
268 268
 	}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	 * @param array cart
273 273
 	 * @return int total items
274 274
 	 */
275
-	public static function total_cart_items( $cart_items ) {
275
+	public static function total_cart_items($cart_items) {
276 276
 		$count = 0;
277
-		if( !empty($cart_items) && is_array( $cart_items )) {
278
-			foreach( $cart_items as $cart_item ) {
277
+		if (!empty($cart_items) && is_array($cart_items)) {
278
+			foreach ($cart_items as $cart_item) {
279 279
 				$count += $cart_item['item_qty'];
280 280
 			}
281 281
 		}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * Reload Persistent cart for logged user and if a persistent cart exists
287 287
 	 */
288 288
 	function load_cart_from_db() {
289
-		if(empty($_SESSION['cart']) && get_current_user_id() ) {
289
+		if (empty($_SESSION['cart']) && get_current_user_id()) {
290 290
 			$cart = $this->get_persistent_cart();
291 291
 			$_SESSION['cart'] = $cart;
292 292
 			$_SESSION['coupon'] = 0;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return array()
299 299
 	 */
300 300
 	function get_persistent_cart() {
301
-		if(get_current_user_id())
301
+		if (get_current_user_id())
302 302
 			$cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true);
303 303
 		return empty($cart) ? array() : $cart;
304 304
 	}
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * Save the persistent cart when updated
315 315
 	 */
316 316
 	function persistent_cart_update() {
317
-		if(get_current_user_id())
318
-			update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array(
317
+		if (get_current_user_id())
318
+			update_user_meta(get_current_user_id(), '_wpshop_persistent_cart', array(
319 319
 					'cart' => $_SESSION['cart'],
320 320
 			));
321 321
 	}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * Delete the persistent cart
325 325
 	 */
326 326
 	function persistent_cart_destroy() {
327
-		delete_user_meta( get_current_user_id(), '_wpshop_persistent_cart' );
327
+		delete_user_meta(get_current_user_id(), '_wpshop_persistent_cart');
328 328
 	}
329 329
 
330 330
 	/**
@@ -344,60 +344,60 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @return mixed If an error occured return a alert message. In the other case if the quantity is correctly set return true
346 346
 	 */
347
-	function set_product_qty($product_id, $quantity, $combined_variation_id = '', $cart = array(), $from_admin = '', $order_id = '' ) {
347
+	function set_product_qty($product_id, $quantity, $combined_variation_id = '', $cart = array(), $from_admin = '', $order_id = '') {
348 348
 		// Init Cart var
349
-		$cart = ( !empty($cart) ) ? $cart : $_SESSION['cart'];
350
-		$wpshop_cart_type = ( !empty($cart) && !empty($cart['cart_type']) ) ? $cart['cart_type'] : 'normal';
349
+		$cart = (!empty($cart)) ? $cart : $_SESSION['cart'];
350
+		$wpshop_cart_type = (!empty($cart) && !empty($cart['cart_type'])) ? $cart['cart_type'] : 'normal';
351 351
 		$parent_product_id = $product_id;
352 352
 		$selected_variations = array();
353 353
 
354 354
 		// Test if Product exists
355
-		if( !empty($product_id) && !empty($cart['order_items']) && !empty( $cart['order_items'][ $product_id ] ) ) {
355
+		if (!empty($product_id) && !empty($cart['order_items']) && !empty($cart['order_items'][$product_id])) {
356 356
 			// Test if is composed product ID
357 357
 			$pid = $product_id;
358
-			if (strpos($pid,'__') !== false) {
359
-				$product_data_id = explode( '__', $pid );
360
-				$pid = ( !empty( $product_data_id ) && !empty( $product_data_id[1] ) ) ? $product_data_id[1] : $cart['order_items'][ $product_id ]['item_id'];
358
+			if (strpos($pid, '__') !== false) {
359
+				$product_data_id = explode('__', $pid);
360
+				$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $cart['order_items'][$product_id]['item_id'];
361 361
 			}
362 362
 
363 363
 			// Checking stock
364 364
 			$wps_product_ctr = new wps_product_ctr();
365
-			$return = $wps_product_ctr->check_stock($pid, $quantity, $combined_variation_id );
366
-			if( $return !== true) {
365
+			$return = $wps_product_ctr->check_stock($pid, $quantity, $combined_variation_id);
366
+			if ($return !== true) {
367 367
 				return $return;
368 368
 			}
369 369
 
370 370
 			// Check Variations to construct product to add to cart
371
-			if( !empty($product_data_id) || get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
371
+			if (!empty($product_data_id) || get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
372 372
 				// Check Parent ID
373
-				if( get_post_type($cart['order_items'][ $product_id ]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
374
-					$parent_product_id = $cart['order_items'][ $product_id ]['item_id'];
373
+				if (get_post_type($cart['order_items'][$product_id]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
374
+					$parent_product_id = $cart['order_items'][$product_id]['item_id'];
375 375
 				}
376 376
 				else {
377
-					$parent_data = wpshop_products::get_parent_variation( $cart['order_items'][ $product_id ]['item_id'] );
377
+					$parent_data = wpshop_products::get_parent_variation($cart['order_items'][$product_id]['item_id']);
378 378
 					$parent_post = $parent_data['parent_post'];
379 379
 					$parent_product_id = $parent_post->ID;
380 380
 				}
381
-				if( !empty($product_data_id) ) {
382
-					unset( $product_data_id[0] );
383
-					if( !empty($product_data_id) ) {
384
-						foreach( $product_data_id as $i ) {
385
-							$mtdt = get_post_meta( $i, '_wpshop_variations_attribute_def', true );
386
-							if( !empty($mtdt) && is_array($mtdt) ) {
387
-								$selected_variations = array_merge( $selected_variations, $mtdt );
381
+				if (!empty($product_data_id)) {
382
+					unset($product_data_id[0]);
383
+					if (!empty($product_data_id)) {
384
+						foreach ($product_data_id as $i) {
385
+							$mtdt = get_post_meta($i, '_wpshop_variations_attribute_def', true);
386
+							if (!empty($mtdt) && is_array($mtdt)) {
387
+								$selected_variations = array_merge($selected_variations, $mtdt);
388 388
 							}
389 389
 						}
390 390
 					}
391 391
 				}
392 392
 				else {
393
-					$selected_variations = get_post_meta( $product_id, '_wpshop_variations_attribute_def', true );
393
+					$selected_variations = get_post_meta($product_id, '_wpshop_variations_attribute_def', true);
394 394
 				}
395 395
 			}
396 396
 
397
-			$formatted_product = $this->prepare_product_to_add_to_cart( $parent_product_id, $quantity, $selected_variations );
397
+			$formatted_product = $this->prepare_product_to_add_to_cart($parent_product_id, $quantity, $selected_variations);
398 398
 			$product_to_add_to_cart = $formatted_product[0];
399 399
 			$new_pid = $product_id;
400
-			$return = $this->add_to_cart( $product_to_add_to_cart, array( $new_pid => $quantity ), $wpshop_cart_type, array(), $from_admin, $cart, $order_id );
400
+			$return = $this->add_to_cart($product_to_add_to_cart, array($new_pid => $quantity), $wpshop_cart_type, array(), $from_admin, $cart, $order_id);
401 401
 			return $return;
402 402
 		}
403 403
 		else {
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
 	 * @param   string	product_id	contains the id of the product to add to the cart
411 411
 	 * @param   string	quantity	contains the quantity of the item to add
412 412
 	 */
413
-	function add_to_cart( $product_list, $quantity, $type='normal', $extra_params=array(), $from_admin = '', $order_meta = '', $order_id = '' ) {
413
+	function add_to_cart($product_list, $quantity, $type = 'normal', $extra_params = array(), $from_admin = '', $order_meta = '', $order_id = '') {
414 414
 		global $wpdb;
415 415
 		/** Check if a cart already exist. If there is already a cart that is not the same type (could be a cart or a quotation)	*/
416
-		if ( empty( $from_admin ) ){
417
-			if(isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type'] ) {
416
+		if (empty($from_admin)) {
417
+			if (isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type']) {
418 418
 				return __('You have another element type into your cart. Please finalize it by going to cart page.', 'wpshop');
419 419
 			}
420 420
 			else {
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
 		$order_items = array();
428 428
 
429 429
 		foreach ($product_list as $pid => $product_more_content) {
430
-			if ( count($product_list) == 1 ) {
431
-				if ( !isset( $quantity[$pid] ) ) $quantity[$pid] = 1;
430
+			if (count($product_list) == 1) {
431
+				if (!isset($quantity[$pid])) $quantity[$pid] = 1;
432 432
 				$product = wpshop_products::get_product_data($product_more_content['id'], false, '"publish", "free_product"');
433 433
 				/** Check if the selected product exist	*/
434
-				if ( $product === false ) return __('This product does not exist', 'wpshop');
434
+				if ($product === false) return __('This product does not exist', 'wpshop');
435 435
 
436 436
 				/** Get information about the product price	*/
437 437
 				$product_price_check = wpshop_prices::get_product_price($product, 'check_only');
438
-				if ( $product_price_check !== true ) return $product_price_check;
438
+				if ($product_price_check !== true) return $product_price_check;
439 439
 
440 440
 				$the_quantity = 1;
441 441
 
442
-				if ( !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) ) {
442
+				if (!empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0])) {
443 443
 					/** Get the asked quantity for each product and check if there is enough stock	*/
444 444
 					$the_quantity = $quantity[$pid];
445 445
 				}
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 				//$quantity[$pid] = $the_quantity;
452 452
 
453 453
 				$variation_id = 0;
454
-				if ( !empty($product_more_content) && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) && !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined' ){
454
+				if (!empty($product_more_content) && !empty($product_more_content['variations']) && !empty($product_more_content['variations'][0]) && !empty($product_more_content['defined_variation_priority']) && $product_more_content['defined_variation_priority'] == 'combined') {
455 455
 					$variation_id = $product_more_content['variations'][0];
456 456
 				}
457 457
 				//$quantity_to_check = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$pid]) && !empty($_SESSION['cart']['order_items'][$pid]['item_qty'])  ) ? $_SESSION['cart']['order_items'][$pid]['item_qty'] : $the_quantity;
458 458
 
459 459
 				$wps_product_ctr = new wps_product_ctr();
460
-				$product_stock = $wps_product_ctr->check_stock($product_more_content['id'], $the_quantity, $variation_id );
461
-				if ( $product_stock !== true ) {
460
+				$product_stock = $wps_product_ctr->check_stock($product_more_content['id'], $the_quantity, $variation_id);
461
+				if ($product_stock !== true) {
462 462
 					return $product_stock;
463 463
 				}
464 464
 			}
@@ -467,99 +467,99 @@  discard block
 block discarded – undo
467 467
 			$order_items[$pid]['product_qty'] = $the_quantity;
468 468
 
469 469
 			/** For product with variation	*/
470
-			$order_items[$pid]['product_variation_type'] = !empty( $product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
470
+			$order_items[$pid]['product_variation_type'] = !empty($product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
471 471
 			$order_items[$pid]['free_variation'] = !empty($product_more_content['free_variation']) ? $product_more_content['free_variation'] : '';
472 472
 			$order_items[$pid]['product_variation'] = '';
473
-			if ( !empty($product_more_content['variations']) ) {
474
-				foreach ( $product_more_content['variations'] as $variation_id) {
473
+			if (!empty($product_more_content['variations'])) {
474
+				foreach ($product_more_content['variations'] as $variation_id) {
475 475
 					$order_items[$pid]['product_variation'][] = $variation_id;
476 476
 				}
477 477
 			}
478 478
 		}
479 479
 
480
-		$current_cart = ( !empty( $order_meta )) ? $order_meta : array();
481
-		$order = $this->calcul_cart_information($order_items, $extra_params, $current_cart );
480
+		$current_cart = (!empty($order_meta)) ? $order_meta : array();
481
+		$order = $this->calcul_cart_information($order_items, $extra_params, $current_cart);
482 482
 
483
-		if( empty($from_admin) ) {
483
+		if (empty($from_admin)) {
484 484
 			self::store_cart_in_session($order);
485 485
 			/** Store the cart into database for connected user */
486
-			if ( get_current_user_id() ) {
486
+			if (get_current_user_id()) {
487 487
 				$this->persistent_cart_update();
488 488
 			}
489 489
 		}
490 490
 		else {
491
-			update_post_meta($order_id, '_order_postmeta', $order );
491
+			update_post_meta($order_id, '_order_postmeta', $order);
492 492
 
493 493
 		}
494 494
 		return 'success';
495 495
 	}
496 496
 
497
-	function prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected = array() ) {
497
+	function prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected = array()) {
498 498
 		$product_price = '';
499 499
 		$product_data = wpshop_products::get_product_data($product_id);
500 500
 
501 501
 		// Free vars
502
-		if ( !empty($wpshop_variation_selected['free']) ){
502
+		if (!empty($wpshop_variation_selected['free'])) {
503 503
 			$free_variations = $wpshop_variation_selected['free'];
504 504
 			unset($wpshop_variation_selected['free']);
505 505
 		}
506 506
 
507 507
 		// If product have many variations
508
-		if ( count($wpshop_variation_selected ) > 1 ) {
509
-			if ( !empty($wpshop_variation_selected) ) {
510
-				$product_with_variation = wpshop_products::get_variation_by_priority( $wpshop_variation_selected, $product_id, true );
508
+		if (count($wpshop_variation_selected) > 1) {
509
+			if (!empty($wpshop_variation_selected)) {
510
+				$product_with_variation = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true);
511 511
 			}
512 512
 
513
-			if ( !empty($product_with_variation[$product_id]['variations']) ) {
513
+			if (!empty($product_with_variation[$product_id]['variations'])) {
514 514
 				$product = $product_data;
515 515
 				$has_variation = true;
516 516
 				$head_product_id = $product_id;
517 517
 
518
-				if ( !empty($product_with_variation[$product_id]['variations']) && ( count($product_with_variation[$product_id]['variations']) == 1 ) && ($product_with_variation[$product_id]['variation_priority'] != 'single') ) {
518
+				if (!empty($product_with_variation[$product_id]['variations']) && (count($product_with_variation[$product_id]['variations']) == 1) && ($product_with_variation[$product_id]['variation_priority'] != 'single')) {
519 519
 					$product_id = $product_with_variation[$product_id]['variations'][0];
520 520
 				}
521 521
 				$product = wpshop_products::get_product_data($product_id, true);
522 522
 
523
-				$the_product = array_merge( array(
523
+				$the_product = array_merge(array(
524 524
 						'product_id'	=> $product_id,
525 525
 						'product_qty' 	=> $product_qty
526 526
 				), $product);
527 527
 
528 528
 				/*	Add variation to product into cart for storage	*/
529
-				if ( !empty($product_with_variation[$head_product_id]['variations']) ) {
530
-					$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_with_variation[$head_product_id]['variations'], $head_product_id, array('type' => $product_with_variation[$head_product_id]['variation_priority']) );
529
+				if (!empty($product_with_variation[$head_product_id]['variations'])) {
530
+					$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_with_variation[$head_product_id]['variations'], $head_product_id, array('type' => $product_with_variation[$head_product_id]['variation_priority']));
531 531
 				}
532 532
 
533 533
 				$product_data = $the_product;
534 534
 			}
535 535
 		}
536 536
 
537
-		$product_to_add_to_cart = array( $product_id => array( 'id' => $product_id, 'product_qty' => $product_qty ) );
537
+		$product_to_add_to_cart = array($product_id => array('id' => $product_id, 'product_qty' => $product_qty));
538 538
 
539
-		if ( !empty( $wpshop_variation_selected ) ) {
540
-			$variation_calculator = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true );
541
-			if ( !empty($variation_calculator[$product_id]) ) {
539
+		if (!empty($wpshop_variation_selected)) {
540
+			$variation_calculator = wpshop_products::get_variation_by_priority($wpshop_variation_selected, $product_id, true);
541
+			if (!empty($variation_calculator[$product_id])) {
542 542
 				$product_to_add_to_cart[$product_id] = array_merge($product_to_add_to_cart[$product_id], $variation_calculator[$product_id]);
543 543
 			}
544 544
 		}
545 545
 
546 546
 		$new_pid = $product_id;
547 547
 		//Create custom ID on single variations Product
548
-		if( !empty($product_to_add_to_cart[$product_id]['variations']) && count( $product_to_add_to_cart[$product_id]['variations'] ) && !empty( $product_to_add_to_cart[$product_id]['variation_priority'] ) && $product_to_add_to_cart[$product_id]['variation_priority'] == 'single' ) {
548
+		if (!empty($product_to_add_to_cart[$product_id]['variations']) && count($product_to_add_to_cart[$product_id]['variations']) && !empty($product_to_add_to_cart[$product_id]['variation_priority']) && $product_to_add_to_cart[$product_id]['variation_priority'] == 'single') {
549 549
 			$tmp_obj = $product_to_add_to_cart[$product_id];
550
-			unset( $product_to_add_to_cart[$product_id] );
550
+			unset($product_to_add_to_cart[$product_id]);
551 551
 			$key = $product_id;
552
-			foreach( $tmp_obj['variations'] as $variation_key) {
553
-				$key.= '__'. $variation_key;
552
+			foreach ($tmp_obj['variations'] as $variation_key) {
553
+				$key .= '__' . $variation_key;
554 554
 			}
555 555
 			$product_to_add_to_cart[$key] = $tmp_obj;
556 556
 			$new_pid = $key;
557 557
 		}
558 558
 		// Add free variations
559
-		if( !empty($free_variations) ) {
559
+		if (!empty($free_variations)) {
560 560
 			$product_to_add_to_cart[$new_pid]['free_variation'] = $free_variations;
561 561
 		}
562
-		return array( $product_to_add_to_cart, $new_pid );
562
+		return array($product_to_add_to_cart, $new_pid);
563 563
 	}
564 564
 
565 565
 	/**
@@ -570,67 +570,67 @@  discard block
 block discarded – undo
570 570
 	 * @param boolean $from_admin
571 571
 	 * @return array
572 572
 	 */
573
-	function calcul_cart_information( $product_list, $custom_order_information = '', $current_cart = array(), $from_admin = false ) {
573
+	function calcul_cart_information($product_list, $custom_order_information = '', $current_cart = array(), $from_admin = false) {
574 574
 		// Price piloting option
575
-		$price_piloting = get_option( 'wpshop_shop_price_piloting' );
575
+		$price_piloting = get_option('wpshop_shop_price_piloting');
576 576
 
577 577
 		// Init vars
578
-		$cart_infos = ( !empty($current_cart) ) ? $current_cart : ( ( !empty($_SESSION) && !empty($_SESSION['cart']) && !$from_admin ) ? $_SESSION['cart'] : array() );
579
-		$cart_items = ( !empty($current_cart) && !empty($current_cart['order_items']) ) ? $current_cart['order_items'] : array();
580
-		$cart_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !$from_admin ) ? $_SESSION['cart']['order_items'] : $cart_items;
578
+		$cart_infos = (!empty($current_cart)) ? $current_cart : ((!empty($_SESSION) && !empty($_SESSION['cart']) && !$from_admin) ? $_SESSION['cart'] : array());
579
+		$cart_items = (!empty($current_cart) && !empty($current_cart['order_items'])) ? $current_cart['order_items'] : array();
580
+		$cart_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !$from_admin) ? $_SESSION['cart']['order_items'] : $cart_items;
581 581
 		$order_total_ht = $order_total_ttc = $total_vat = 0; $order_tva = array();
582 582
 		$total_weight = $nb_of_items = $order_shipping_cost_by_article = 0;
583 583
 		$order_discount_rate = $order_discount_amount = $order_items_discount_amount = $order_total_discount_amount = 0;
584 584
 		$cart_infos['order_amount_to_pay_now'] = 0;
585 585
 
586 586
 		// If Product list is not empty, add products to order
587
-		if( !empty($product_list) ) {
588
-			foreach ( $product_list as $product_id => $d ) {
587
+		if (!empty($product_list)) {
588
+			foreach ($product_list as $product_id => $d) {
589 589
 				$product_key = $product_id;
590
-				if( isset( $d['product_qty']) ) {
590
+				if (isset($d['product_qty'])) {
591 591
 					// Formate datas
592 592
 					$product_id = $head_product_id = $d['product_id'];
593 593
 					$product_qty = $d['product_qty'];
594 594
 					$product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
595 595
 
596 596
 					// If product is a single variation product
597
-					if ( !empty($product_variation) && ( count($product_variation) == 1 ) ) {
597
+					if (!empty($product_variation) && (count($product_variation) == 1)) {
598 598
 						$product_id = $product_variation[0];
599 599
 					}
600 600
 
601 601
 					// Construct final product
602 602
 					$product = wpshop_products::get_product_data($d['product_id'], true, '"publish", "free_product"');
603
-					$the_product = array_merge( array('product_id'	=> $d['product_id'], 'product_qty' 	=> $product_qty ), $product);
603
+					$the_product = array_merge(array('product_id'	=> $d['product_id'], 'product_qty' 	=> $product_qty), $product);
604 604
 
605 605
 					//	Add variation to product into cart for storage
606
-					if ( !empty($product_variation) ) {
607
-						$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']) );
606
+					if (!empty($product_variation)) {
607
+						$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
608 608
 					}
609 609
 
610 610
 					// Free Variations Checking
611
-					if ( !empty( $d['free_variation'] ) ) {
611
+					if (!empty($d['free_variation'])) {
612 612
 						$the_product['item_meta']['free_variation'] = $d['free_variation'];
613 613
 						$head_product_id = $the_product['product_id'];
614 614
 					}
615 615
 
616 616
 					// If product is a variation, we check parent product general
617
-					if( get_post_type( $the_product['product_id'] )  == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
618
-						$parent_def = wpshop_products::get_parent_variation( $the_product['product_id'] );
619
-						if( !empty($parent_def) && !empty($parent_def['parent_post']) ) {
620
-							$variation_def = get_post_meta( $parent_def['parent_post']->ID, '_wpshop_variation_defining', true );
617
+					if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
618
+						$parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
619
+						if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
620
+							$variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
621 621
 							$parent_meta = $parent_def['parent_post_meta'];
622
-							if( !empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority'] ) && !empty($variation_def['options']['price_behaviour']) && in_array( 'addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1 ) {
623
-								$the_product['product_price'] += number_format( str_replace( ',', '.', $parent_meta['product_price'] ), 2, '.', '' );
624
-								$the_product['price_ht'] += number_format( str_replace( ',', '.',$parent_meta['price_ht']) , 2, '.', '' );
625
-								$the_product['tva'] += number_format( str_replace( ',', '.', $parent_meta['tva']) , 2, '.', '' );
622
+							if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
623
+								$the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
624
+								$the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
625
+								$the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
626 626
 							}
627 627
 						}
628 628
 					}
629 629
 
630 630
 					// Delete product if its qty is equals to zero, else add this product to order
631
-					if( empty( $d['product_qty'] ) ) {
632
-						unset( $cart_items[$product_key] );
633
-						unset( $cart_infos['order_items'][$product_key] );
631
+					if (empty($d['product_qty'])) {
632
+						unset($cart_items[$product_key]);
633
+						unset($cart_infos['order_items'][$product_key]);
634 634
 					}
635 635
 					else {
636 636
 						$wps_orders = new wps_orders_ctr();
@@ -641,16 +641,16 @@  discard block
 block discarded – undo
641 641
 		}
642 642
 
643 643
 		// Add automaticaly Add-to-cart Products
644
-		$cart_items = $this->add_automaticaly_product_to_cart( $cart_items );
644
+		$cart_items = $this->add_automaticaly_product_to_cart($cart_items);
645 645
 
646 646
 		// Calcul Cart Informations
647 647
 		$cart_has_special_product = false;
648
-		if( !empty($cart_items) && is_array($cart_items) ) {
649
-			foreach( $cart_items as $item_id => $item ) {
648
+		if (!empty($cart_items) && is_array($cart_items)) {
649
+			foreach ($cart_items as $item_id => $item) {
650 650
 
651
-				if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) {
651
+				if (!empty($item['item_amount_to_pay_now'])) {
652 652
 					$cart_has_special_product = true;
653
-					$cart_infos['order_amount_to_pay_now'] += ( $item[ 'item_amount_to_pay_now' ] * $item[ 'item_qty' ] );
653
+					$cart_infos['order_amount_to_pay_now'] += ($item['item_amount_to_pay_now'] * $item['item_qty']);
654 654
 				}
655 655
 				else {
656 656
 					$cart_infos['order_amount_to_pay_now'] += $item['item_total_ttc'];
@@ -659,11 +659,11 @@  discard block
 block discarded – undo
659 659
 				$order_total_ht += $item['item_total_ht'];
660 660
 				$order_total_ttc += $item['item_total_ttc'];
661 661
 				// VAT
662
-				if( !empty($order_tva[ $item['item_tva_rate'] ]) ) {
663
-					$order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount'];
662
+				if (!empty($order_tva[$item['item_tva_rate']])) {
663
+					$order_tva[$item['item_tva_rate']] += $item['item_tva_total_amount'];
664 664
 				}
665 665
 				else {
666
-					$order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount'];
666
+					$order_tva[$item['item_tva_rate']] = $item['item_tva_total_amount'];
667 667
 				}
668 668
 			}
669 669
 		}
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 		$cart_infos['order_total_ttc'] = $order_total_ttc;
678 678
 
679 679
 		// Calcul Shipping cost
680
-		if( !$from_admin && empty( $cart_infos['order_shipping_cost_fixe'] ) && !empty($_SESSION[ 'wps-pos-addon' ]) ) {
680
+		if (!$from_admin && empty($cart_infos['order_shipping_cost_fixe']) && !empty($_SESSION['wps-pos-addon'])) {
681 681
 			$wps_shipping = new wps_shipping();
682
-			$total_cart_ht_or_ttc_regarding_config = ( !empty($price_piloting) && $price_piloting == 'HT' ) ? $cart_infos['order_total_ht'] : $cart_infos['order_total_ttc'];
683
-			$cart_weight = $wps_shipping->calcul_cart_weight( $cart_infos['order_items'] );
684
-			$total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost( $cart_infos['order_items'] );
685
-			foreach( $cart_infos['order_items'] as $item ) {
686
-				if( !empty($item['item_is_downloadable_']) && ( __( $item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) {
682
+			$total_cart_ht_or_ttc_regarding_config = (!empty($price_piloting) && $price_piloting == 'HT') ? $cart_infos['order_total_ht'] : $cart_infos['order_total_ttc'];
683
+			$cart_weight = $wps_shipping->calcul_cart_weight($cart_infos['order_items']);
684
+			$total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost($cart_infos['order_items']);
685
+			foreach ($cart_infos['order_items'] as $item) {
686
+				if (!empty($item['item_is_downloadable_']) && (__($item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) {
687 687
 					$is_downloadable_products = 'is_downloadable_';
688 688
 				} else {
689 689
 					$is_downloadable_products = '';
@@ -695,39 +695,39 @@  discard block
 block discarded – undo
695 695
 		}
696 696
 
697 697
 		// If Price piloting is ET, calcul VAT on Shipping cost
698
-		if ( !empty($price_piloting) && $price_piloting == 'HT') {
699
-			$shipping_cost_vat = ( !empty($cart_infos['order_shipping_cost']) ) ? ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) * number_format(  $cart_infos['order_shipping_cost'], 2, '.', '') : 0;
698
+		if (!empty($price_piloting) && $price_piloting == 'HT') {
699
+			$shipping_cost_vat = (!empty($cart_infos['order_shipping_cost'])) ? (WPSHOP_VAT_ON_SHIPPING_COST / 100) * number_format($cart_infos['order_shipping_cost'], 2, '.', '') : 0;
700 700
 			$order_tva['VAT_shipping_cost'] = $shipping_cost_vat;
701 701
 		}
702 702
 
703 703
 		// Calcul VAT Total
704
-		if( !empty($order_tva) ) {
705
-			foreach( $order_tva as $vat_rate => $vat_value ) {
704
+		if (!empty($order_tva)) {
705
+			foreach ($order_tva as $vat_rate => $vat_value) {
706 706
 				$total_vat += $vat_value;
707 707
 			}
708 708
 		}
709 709
 
710 710
 		// Recap totals
711
-		$cart_infos['order_total_ttc'] = ( $cart_infos['order_total_ht'] + ( !empty( $cart_infos ) && !empty( $cart_infos[ 'order_shipping_cost' ] )  ? $cart_infos['order_shipping_cost'] : 0 )  + $total_vat );
711
+		$cart_infos['order_total_ttc'] = ($cart_infos['order_total_ht'] + (!empty($cart_infos) && !empty($cart_infos['order_shipping_cost']) ? $cart_infos['order_shipping_cost'] : 0) + $total_vat);
712 712
 		$cart_infos['order_grand_total_before_discount'] = $cart_infos['order_grand_total'] = $cart_infos['order_total_ttc'];
713 713
 
714 714
 		// Total to pay now
715 715
 		$total_received = 0;
716
-		if( !empty( $cart_infos['order_payment']['received'] ) ) {
717
-			foreach( $cart_infos['order_payment']['received'] as $received ) {
718
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
716
+		if (!empty($cart_infos['order_payment']['received'])) {
717
+			foreach ($cart_infos['order_payment']['received'] as $received) {
718
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
719 719
 			}
720 720
 		}
721 721
 		$cart_infos['order_amount_to_pay_now'] = $cart_infos['order_grand_total'] - $total_received;
722 722
 
723 723
 		// Apply cart rules
724
-		$cart_rule = wpshop_cart_rules::get_cart_rule( $cart_infos['order_grand_total'] );
725
-		if( $cart_rule['cart_rule_exist'] ) {
726
-			if ( !empty( $cart_rule['cart_rule_info']['discount_type'] ) ) {
727
-				if ( $cart_rule['cart_rule_info']['discount_type'] == 'absolute_discount' ) {
724
+		$cart_rule = wpshop_cart_rules::get_cart_rule($cart_infos['order_grand_total']);
725
+		if ($cart_rule['cart_rule_exist']) {
726
+			if (!empty($cart_rule['cart_rule_info']['discount_type'])) {
727
+				if ($cart_rule['cart_rule_info']['discount_type'] == 'absolute_discount') {
728 728
 					$cart_infos['order_discount_type'] = 'amount';
729 729
 				}
730
-				if ( $cart_rule['cart_rule_info']['discount_type'] == 'percent_discount' ) {
730
+				if ($cart_rule['cart_rule_info']['discount_type'] == 'percent_discount') {
731 731
 					$cart_infos['order_discount_type'] = 'percent';
732 732
 				}
733 733
 			}
@@ -735,15 +735,15 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 
737 737
 		// Apply coupons
738
-		if( !empty( $_SESSION['cart']) && !$from_admin ) {
739
-			if( !empty($_SESSION['cart']['coupon_id']) ) {
738
+		if (!empty($_SESSION['cart']) && !$from_admin) {
739
+			if (!empty($_SESSION['cart']['coupon_id'])) {
740 740
 				$wps_coupon_mdl = new wps_coupon_model();
741
-				$coupon = $wps_coupon_mdl->get_coupon_data( $_SESSION['cart']['coupon_id'] );
742
-				if( !empty($coupon) && !empty($coupon['wpshop_coupon_code']) ) {
741
+				$coupon = $wps_coupon_mdl->get_coupon_data($_SESSION['cart']['coupon_id']);
742
+				if (!empty($coupon) && !empty($coupon['wpshop_coupon_code'])) {
743 743
 					$wps_coupon = new wps_coupon_ctr();
744
-					$coupon_checking = $wps_coupon->applyCoupon( $coupon['wpshop_coupon_code'] );
744
+					$coupon_checking = $wps_coupon->applyCoupon($coupon['wpshop_coupon_code']);
745 745
 					// If Coupon conditions are Ok
746
-					if( !empty($coupon_checking) && !empty( $coupon_checking['status'] ) && ( true == $coupon_checking['status'] ) ) {
746
+					if (!empty($coupon_checking) && !empty($coupon_checking['status']) && (true == $coupon_checking['status'])) {
747 747
 						$cart_infos['order_discount_type'] = $coupon['wpshop_coupon_discount_type'];
748 748
 						$cart_infos['order_discount_value'] = $coupon['wpshop_coupon_discount_value'];
749 749
 					}
@@ -752,51 +752,51 @@  discard block
 block discarded – undo
752 752
 		}
753 753
 
754 754
 		// Checking Discounts
755
-		if( !empty($cart_infos['order_discount_type']) && isset( $cart_infos['order_discount_value'] ) ) {
755
+		if (!empty($cart_infos['order_discount_type']) && isset($cart_infos['order_discount_value'])) {
756 756
 			// Calcul discount on Order
757 757
 			switch ($cart_infos['order_discount_type']) {
758 758
 				case 'amount':
759
-					$cart_infos['order_discount_amount_total_cart'] = number_format( str_replace( ',', '.', $cart_infos['order_discount_value'] ), 2, '.', '');
759
+					$cart_infos['order_discount_amount_total_cart'] = number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '');
760 760
 				break;
761 761
 				case 'percent':
762
-					$cart_infos['order_discount_amount_total_cart'] = number_format( $cart_infos['order_grand_total'], 2, '.', '') * ( number_format( str_replace( ',', '.', $cart_infos['order_discount_value']), 2, '.', '') / 100);
762
+					$cart_infos['order_discount_amount_total_cart'] = number_format($cart_infos['order_grand_total'], 2, '.', '') * (number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '') / 100);
763 763
 				break;
764 764
 			}
765
-			if ( number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '') > number_format( $cart_infos['order_grand_total'], 2, '.', '') ) {
765
+			if (number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '') > number_format($cart_infos['order_grand_total'], 2, '.', '')) {
766 766
 				$cart_infos['order_grand_total'] = 0;
767 767
 			}
768 768
 			else {
769
-				$cart_infos['order_grand_total'] -= number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '');
769
+				$cart_infos['order_grand_total'] -= number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '');
770 770
 			}
771
-			$cart_infos['order_amount_to_pay_now'] = number_format( $cart_infos['order_grand_total'] - $total_received, 2, '.', '');
771
+			$cart_infos['order_amount_to_pay_now'] = number_format($cart_infos['order_grand_total'] - $total_received, 2, '.', '');
772 772
 		}
773 773
 
774 774
 		// Apply Partial Payments
775 775
 		$wpshop_payment = new wpshop_payment();
776
-		if( !empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation' ) {
777
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'], 'for_quotation' );
776
+		if (!empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation') {
777
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total'], 'for_quotation');
778 778
 		}
779 779
 		else {
780
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'] );
780
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total']);
781 781
 		}
782
-		if ( !empty($partial_payment['amount_to_pay']) && ( empty( $cart_infos['order_status'] ) || $cart_infos['order_status'] == 'awaiting_payment' ) && ( empty( $product_partial_payment_amount ) ) ) {
782
+		if (!empty($partial_payment['amount_to_pay']) && (empty($cart_infos['order_status']) || $cart_infos['order_status'] == 'awaiting_payment') && (empty($product_partial_payment_amount))) {
783 783
 			unset($partial_payment['display']);
784
-			$cart_infos['order_partial_payment'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
785
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
784
+			$cart_infos['order_partial_payment'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
785
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
786 786
 		}
787 787
 		// Apply Partial Payments : Subscription part.
788
-		elseif ( ! empty( $cart_has_special_product ) ) {
789
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $cart_infos['order_amount_to_pay_now'] ), 2, '.', '');
788
+		elseif (!empty($cart_has_special_product)) {
789
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $cart_infos['order_amount_to_pay_now']), 2, '.', '');
790 790
 			$cart_infos['order_product_partial_payment'] = 'subscription';
791 791
 		}
792 792
 
793 793
 		// Cart Type
794
-		if ( isset( $_SESSION['cart']['cart_type'] ) ) {
794
+		if (isset($_SESSION['cart']['cart_type'])) {
795 795
 			$cart_infos['cart_type'] = $_SESSION['cart']['cart_type'];
796 796
 		}
797 797
 
798 798
 		// Apply Extra actions on cart infos
799
-		$cart_infos = apply_filters( 'wps_extra_calcul_in_cart', $cart_infos, $_SESSION );
799
+		$cart_infos = apply_filters('wps_extra_calcul_in_cart', $cart_infos, $_SESSION);
800 800
 
801 801
 		return $cart_infos;
802 802
 	}
@@ -806,18 +806,18 @@  discard block
 block discarded – undo
806 806
 	 * @param array $cart_items
807 807
 	 * @return array
808 808
 	 */
809
-	function add_automaticaly_product_to_cart( $cart_items ) {
809
+	function add_automaticaly_product_to_cart($cart_items) {
810 810
 		global $wpdb;
811 811
 		// Recovery all products with options
812 812
 		$query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
813 813
 		$post_list_with_options = $wpdb->get_results($query);
814 814
 		$wps_orders = new wps_orders_ctr();
815
-		if ( !empty($post_list_with_options) && !empty($cart_items) ) {
816
-			foreach ( $post_list_with_options as $product_info) {
815
+		if (!empty($post_list_with_options) && !empty($cart_items)) {
816
+			foreach ($post_list_with_options as $product_info) {
817 817
 				$product_meta = unserialize($product_info->meta_value);
818
-				if ( !empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id]) ) {
818
+				if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id])) {
819 819
 					$product = wpshop_products::get_product_data($product_info->post_id, true, '"draft", "publish"');
820
-					$the_product = array_merge( array(
820
+					$the_product = array_merge(array(
821 821
 							'product_id'	=> $product_info->post_id,
822 822
 							'product_qty' 	=> 1
823 823
 					), $product);
@@ -831,28 +831,28 @@  discard block
 block discarded – undo
831 831
 
832 832
 	/** Ajax action to reload cart **/
833 833
 	public static function wps_reload_cart() {
834
-		check_ajax_referer( 'wps_reload_cart' );
834
+		check_ajax_referer('wps_reload_cart');
835 835
 
836 836
 		$wps_cart = new wps_cart();
837 837
 		$result = $wps_cart->cart_content();
838 838
 
839
-		wp_die( json_encode( array( 'response' => $result) ) );
839
+		wp_die(json_encode(array('response' => $result)));
840 840
 	}
841 841
 
842 842
 
843 843
 	/** Ajax action to reload mini cart */
844 844
 	public function wps_reload_mini_cart() {
845
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
845
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
846 846
 
847
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) )
847
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_mini_cart'))
848 848
 			wp_die();
849 849
 
850 850
 		$wps_cart = new wps_cart();
851
-		$result = $wps_cart->mini_cart_content( sanitize_title( $_POST['type']) );
852
-		$count_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])  ) ? $wps_cart->total_cart_items( $_SESSION['cart']['order_items'] ) : 0;
851
+		$result = $wps_cart->mini_cart_content(sanitize_title($_POST['type']));
852
+		$count_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $wps_cart->total_cart_items($_SESSION['cart']['order_items']) : 0;
853 853
 		$free_shipping_alert = wpshop_tools::create_custom_hook('wpshop_free_shipping_cost_alert');
854 854
 
855
-		echo json_encode( array( 'response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert) );
855
+		echo json_encode(array('response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert));
856 856
 		die();
857 857
 	}
858 858
 
@@ -862,35 +862,35 @@  discard block
 block discarded – undo
862 862
 	 * @return string
863 863
 	 */
864 864
 	function display_wps_numeration_cart() {
865
-		$cart_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) ? $_SESSION['cart']['order_items'] : array();
866
-		$total_cart_item = self::total_cart_items( $cart_items );
865
+		$cart_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $_SESSION['cart']['order_items'] : array();
866
+		$total_cart_item = self::total_cart_items($cart_items);
867 867
 
868 868
 		ob_start();
869
-		require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart") );
869
+		require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart"));
870 870
 		$output = ob_get_contents();
871 871
 		ob_end_clean();
872 872
 		return $output;
873 873
 	}
874 874
 
875
-	public function display_button_add_to_cart( $args ) {
876
-		$button_text = __( 'Add to cart', 'wpshop' );
875
+	public function display_button_add_to_cart($args) {
876
+		$button_text = __('Add to cart', 'wpshop');
877 877
 		$use_button = true;
878
-		$output = __( 'No product has been found.', 'wpshop' );
878
+		$output = __('No product has been found.', 'wpshop');
879 879
 
880
-		if ( !empty( $args ) && !empty( $args['pid'] ) ) {
880
+		if (!empty($args) && !empty($args['pid'])) {
881 881
 
882 882
 			/** The user send the text in argument */
883
-			if ( !empty( $args['text' ] ) ) {
883
+			if (!empty($args['text'])) {
884 884
 				$button_text = $args['text'];
885 885
 			}
886 886
 
887 887
 			/** The user send use input */
888
-			if ( !empty( $args['use_button'] ) && 'false' == $args['use_button'] ) {
888
+			if (!empty($args['use_button']) && 'false' == $args['use_button']) {
889 889
 				$use_button = false;
890 890
 			}
891 891
 
892 892
 			ob_start();
893
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart' ) );
893
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart'));
894 894
 			$output = ob_get_clean();
895 895
 		}
896 896
 
@@ -899,21 +899,21 @@  discard block
 block discarded – undo
899 899
 
900 900
 	/** Ajax action to reload summary cart */
901 901
 	public static function wps_reload_summary_cart() {
902
-		check_ajax_referer( 'wps_reload_summary_cart' );
902
+		check_ajax_referer('wps_reload_summary_cart');
903 903
 
904 904
 		$wps_cart = new wps_cart();
905 905
 		$result = $wps_cart->resume_cart_content();
906 906
 
907
-		wp_die( json_encode( array( 'response' => $result, ) ) );
907
+		wp_die(json_encode(array('response' => $result,)));
908 908
 	}
909 909
 
910 910
 
911 911
 	/** Display Apply Coupon Interface **/
912 912
 	function display_apply_coupon_interface() {
913 913
 		$output = '';
914
-		if ( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) {
914
+		if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) {
915 915
 			ob_start();
916
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon") );
916
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon"));
917 917
 			$output = ob_get_contents();
918 918
 			ob_end_clean();
919 919
 		}
@@ -923,30 +923,30 @@  discard block
 block discarded – undo
923 923
 
924 924
 	/** AJAX - action to apply coupon **/
925 925
 	function wps_apply_coupon() {
926
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
926
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
927 927
 
928
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) )
928
+		if (!wp_verify_nonce($_wpnonce, 'wps_apply_coupon'))
929 929
 			wp_die();
930 930
 
931 931
 		$status = false; $response = '';
932
-		$coupon = ( !empty($_POST['coupon_code']) ) ? wpshop_tools::varSanitizer( $_POST['coupon_code']) : null;
933
-		if( !empty($coupon) ) {
932
+		$coupon = (!empty($_POST['coupon_code'])) ? wpshop_tools::varSanitizer($_POST['coupon_code']) : null;
933
+		if (!empty($coupon)) {
934 934
 			$wps_coupon_ctr = new wps_coupon_ctr();
935 935
 			$result = $wps_coupon_ctr->applyCoupon($coupon);
936
-			if ($result['status']===true) {
936
+			if ($result['status'] === true) {
937 937
 				$order = $this->calcul_cart_information(array());
938 938
 				$this->store_cart_in_session($order);
939 939
 				$status = true;
940
-				$response = '<div class="wps-alert-success">' .__( 'The coupon has been applied', 'wpshop' ). '</div>';
940
+				$response = '<div class="wps-alert-success">' . __('The coupon has been applied', 'wpshop') . '</div>';
941 941
 			}
942 942
 			else {
943
-				$response = '<div class="wps-alert-error">' .$result['message']. '</div>';
943
+				$response = '<div class="wps-alert-error">' . $result['message'] . '</div>';
944 944
 			}
945 945
 		}
946 946
 		else {
947
-			$response = '<div class="wps-alert-error">'.__( 'A coupon code is required', 'wpshop'). '</div>';
947
+			$response = '<div class="wps-alert-error">' . __('A coupon code is required', 'wpshop') . '</div>';
948 948
 		}
949
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
949
+		echo json_encode(array('status' => $status, 'response' => $response));
950 950
 		die();
951 951
 	}
952 952
 
@@ -955,24 +955,24 @@  discard block
 block discarded – undo
955 955
 	 * AJAX - Pass to step two in the Checkout tunnel
956 956
 	 */
957 957
 	public static function wps_cart_pass_to_step_two() {
958
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
958
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
959 959
 
960
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) )
960
+		if (!wp_verify_nonce($_wpnonce, 'wps_cart_pass_to_step_two'))
961 961
 			wp_die();
962 962
 
963 963
 		$status = false; $response = '';
964
-		$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
965
-		if( !empty($checkout_page_id) ) {
966
-			$permalink_option = get_option( 'permalink_structure' );
967
-			$step = ( get_current_user_id() != 0 ) ?  3 : 2;
968
-			$response = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step;
964
+		$checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'));
965
+		if (!empty($checkout_page_id)) {
966
+			$permalink_option = get_option('permalink_structure');
967
+			$step = (get_current_user_id() != 0) ? 3 : 2;
968
+			$response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=' . $step;
969 969
 			$response = apply_filters('wps_extra_signup_actions', $response);
970 970
 			$status = true;
971 971
 		}
972 972
 		else {
973
-			$response = '<div class="wps-alert-error">' .__( 'An error was occured, please retry later or contact the website administrator', 'wpshop' ). '</div>';
973
+			$response = '<div class="wps-alert-error">' . __('An error was occured, please retry later or contact the website administrator', 'wpshop') . '</div>';
974 974
 		}
975
-		echo json_encode( array( 'status' => $status, 'response' => $response));
975
+		echo json_encode(array('status' => $status, 'response' => $response));
976 976
 		die();
977 977
 	}
978 978
 
@@ -981,14 +981,14 @@  discard block
 block discarded – undo
981 981
 	 * AJAX - Empty the cart
982 982
 	 */
983 983
 	function wps_empty_cart() {
984
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
984
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
985 985
 
986
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) )
986
+		if (!wp_verify_nonce($_wpnonce, 'wps_empty_cart'))
987 987
 			wp_die();
988 988
 
989 989
 
990 990
 		$this->empty_cart();
991
-		echo json_encode( array( 'status' => true) );
991
+		echo json_encode(array('status' => true));
992 992
 		die();
993 993
 	}
994 994
 }
Please login to merge, or discard this patch.
includes/modules/wps_cart/templates/frontend/cart/cart-total.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 ?>
3 3
 <div class="wps-cart-cartouche">
4 4
 	<div class="wps-cart-message">
5
-		<?php if( $cart_type != 'admin-panel' ) : ?>
6
-			<?php if ( !empty($cart_type) && $cart_type == 'summary' && !$account_origin ) : ?>
7
-				<?php $url_step_one = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ); ?>
8
-				<?php printf( __( 'You have forget an item ? <a href="%s">Modify your cart !</a>', 'wpshop'), $url_step_one ); ?>
5
+		<?php if ($cart_type != 'admin-panel') : ?>
6
+			<?php if (!empty($cart_type) && $cart_type == 'summary' && !$account_origin) : ?>
7
+				<?php $url_step_one = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))); ?>
8
+				<?php printf(__('You have forget an item ? <a href="%s">Modify your cart !</a>', 'wpshop'), $url_step_one); ?>
9 9
 			<?php else : ?>
10
-				<?php if( !$account_origin ) :
10
+				<?php if (!$account_origin) :
11 11
 							echo do_shortcode('[wps_apply_coupon]');
12 12
 						else : ?>
13
-					<button id="<?php echo $oid; ?>" class="wps-bton-first-mini-rounded make_order_again" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_restart_the_order' ); ?>"><?php _e( 'Make this order again', 'wpshop'); ?></button>
13
+					<button id="<?php echo $oid; ?>" class="wps-bton-first-mini-rounded make_order_again" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_restart_the_order'); ?>"><?php _e('Make this order again', 'wpshop'); ?></button>
14 14
 				<?php endif; ?>
15
-				<?php if( !empty($tracking) ) : ?>
15
+				<?php if (!empty($tracking)) : ?>
16 16
 					<p><br />
17
-					<?php if( !empty($tracking['number']) ) : ?>
18
-						<strong><?php _e('Tracking number','wpshop'); ?> :</strong> <?php _e($tracking['number']); ?><br />
17
+					<?php if (!empty($tracking['number'])) : ?>
18
+						<strong><?php _e('Tracking number', 'wpshop'); ?> :</strong> <?php _e($tracking['number']); ?><br />
19 19
 					<?php endif; ?>
20
-					<?php if( !empty($tracking['link']) ) : ?>
20
+					<?php if (!empty($tracking['link'])) : ?>
21 21
 						<?php /** Check if http:// it's found in the link */
22 22
 						$url = $tracking['link'];
23
-						if('http://' != substr($url, 0, 7))
23
+						if ('http://' != substr($url, 0, 7))
24 24
 							$url = 'http://' . $url;
25 25
 						?>
26
-						<a class="wps-bton-fourth-mini-rounded" href="<?php echo $url; ?>" target="_blank"><?php _e('Tracking link','wpshop'); ?></a>
26
+						<a class="wps-bton-fourth-mini-rounded" href="<?php echo $url; ?>" target="_blank"><?php _e('Tracking link', 'wpshop'); ?></a>
27 27
 					<?php endif; ?>
28 28
 					</p>
29 29
 				<?php endif; ?>
@@ -31,141 +31,141 @@  discard block
 block discarded – undo
31 31
 		<?php endif; ?>
32 32
 	</div><!-- wps-cart-message -->
33 33
 	<div class="wps-cart-total">
34
-		<?php $shipping_price_from = get_option( 'wpshop_shipping_cost_from' ); ?>
34
+		<?php $shipping_price_from = get_option('wpshop_shipping_cost_from'); ?>
35 35
 
36 36
 		<!--	Recap shipping	-->
37 37
 
38
-		<?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_et' || $price_piloting == 'HT' ) : ?>
38
+		<?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_et' || $price_piloting == 'HT') : ?>
39 39
 			<p>
40
-				<?php _e( 'Shipping cost ET', 'wpshop'); ?> <?php echo ( ( !empty($shipping_price_from) && empty( $_SESSION['shipping_address'] ) ) ? '<br/><i>('.__( 'From', 'wpshop').')</i>' : '' ); ?>
40
+				<?php _e('Shipping cost ET', 'wpshop'); ?> <?php echo ((!empty($shipping_price_from) && empty($_SESSION['shipping_address'])) ? '<br/><i>(' . __('From', 'wpshop') . ')</i>' : ''); ?>
41 41
 				<span class="wps-alignRight">
42
-					<?php if( $cart_type != 'admin-panel' ) : ?>
43
-						<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et ); ?></strong> <?php echo $currency; ?>
42
+					<?php if ($cart_type != 'admin-panel') : ?>
43
+						<strong><?php echo wpshop_tools::formate_number($shipping_cost_et); ?></strong> <?php echo $currency; ?>
44 44
 					<?php else : ?>
45
-						<?php if( ( empty( $cart_content['order_status'] ) || ( $cart_content['order_status'] == 'awaiting_payment' ) || ( ( !empty( $cart_content['cart_type'] ) && $cart_content['cart_type'] == 'quotation' ) && $cart_content['order_status'] != 'completed' ) ) && $price_piloting == 'HT' ) : ?>
46
-							<input type="text" size="5" value="<?php echo number_format( $shipping_cost_et, 2 ); ?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
45
+						<?php if ((empty($cart_content['order_status']) || ($cart_content['order_status'] == 'awaiting_payment') || ((!empty($cart_content['cart_type']) && $cart_content['cart_type'] == 'quotation') && $cart_content['order_status'] != 'completed')) && $price_piloting == 'HT') : ?>
46
+							<input type="text" size="5" value="<?php echo number_format($shipping_cost_et, 2); ?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
47 47
 						<?php else : ?>
48
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
48
+							<strong><?php echo wpshop_tools::formate_number($shipping_cost_et); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
49 49
 						<?php endif; ?>
50 50
 					<?php endif; ?>
51 51
 				</span>
52 52
 			</p>
53 53
 		<?php endif; ?>
54 54
 
55
-		<?php if( $cart_option == 'full_cart' ) : ?>
55
+		<?php if ($cart_option == 'full_cart') : ?>
56 56
 			<p>
57
-				<?php _e( 'VAT on Shipping cost', 'wpshop'); ?>
57
+				<?php _e('VAT on Shipping cost', 'wpshop'); ?>
58 58
 				<span class="wps-alignRight">
59
-					<strong><?php echo wpshop_tools::formate_number( $shipping_cost_vat ); ?></strong> <?php echo $currency; ?>
59
+					<strong><?php echo wpshop_tools::formate_number($shipping_cost_vat); ?></strong> <?php echo $currency; ?>
60 60
 				</span>
61 61
 			</p>
62 62
 		<?php endif; ?>
63 63
 
64
-		<?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' || $price_piloting == 'TTC' ) : ?>
64
+		<?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati' || $price_piloting == 'TTC') : ?>
65 65
 			<p>
66
-				<?php _e( 'Shipping cost', 'wpshop'); ?> <?php echo ( ( !empty($shipping_price_from) && empty( $_SESSION['shipping_address'] ) ) ? '<br/><i>('.__( 'From', 'wpshop').')</i>' : '' ); ?>
66
+				<?php _e('Shipping cost', 'wpshop'); ?> <?php echo ((!empty($shipping_price_from) && empty($_SESSION['shipping_address'])) ? '<br/><i>(' . __('From', 'wpshop') . ')</i>' : ''); ?>
67 67
 				<span class="wps-alignRight">
68
-					<?php if( $cart_type != 'admin-panel' ) : ?>
69
-						<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?></strong> <?php echo $currency; ?>
68
+					<?php if ($cart_type != 'admin-panel') : ?>
69
+						<strong><?php echo wpshop_tools::formate_number($shipping_cost_ati); ?></strong> <?php echo $currency; ?>
70 70
 					<?php else : ?>
71
-						<?php if( ( empty( $cart_content['order_status'] ) || ( $cart_content['order_status'] == 'awaiting_payment' ) || ( ( !empty( $cart_content['cart_type'] ) && $cart_content['cart_type'] == 'quotation' ) && $cart_content['order_status'] != 'completed' ) ) && $price_piloting == 'TTC' ) : ?>
72
-							<input type="text" size="5" value="<?php echo number_format( $shipping_cost_ati, 2 ); ?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
71
+						<?php if ((empty($cart_content['order_status']) || ($cart_content['order_status'] == 'awaiting_payment') || ((!empty($cart_content['cart_type']) && $cart_content['cart_type'] == 'quotation') && $cart_content['order_status'] != 'completed')) && $price_piloting == 'TTC') : ?>
72
+							<input type="text" size="5" value="<?php echo number_format($shipping_cost_ati, 2); ?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
73 73
 						<?php else : ?>
74
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
74
+							<strong><?php echo wpshop_tools::formate_number($shipping_cost_ati); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
75 75
 						<?php endif; ?>
76 76
 					<?php endif; ?>
77 77
 				</span>
78 78
 			</p>
79 79
 		<?php endif; ?>
80 80
 
81
-		<?php if( $cart_option == 'full_cart' && !empty($cart_content['order_tva']) ) : ?>
82
-		<?php foreach( $cart_content['order_tva'] as $order_vat_rate => $order_vat_value ) :
83
-				if( $order_vat_rate != 'VAT_shipping_cost') :
81
+		<?php if ($cart_option == 'full_cart' && !empty($cart_content['order_tva'])) : ?>
82
+		<?php foreach ($cart_content['order_tva'] as $order_vat_rate => $order_vat_value) :
83
+				if ($order_vat_rate != 'VAT_shipping_cost') :
84 84
 					?>
85 85
 					<p>
86
-						<?php printf( __( 'VAT (%s %%)', 'wpshop'), $order_vat_rate); ?>
86
+						<?php printf(__('VAT (%s %%)', 'wpshop'), $order_vat_rate); ?>
87 87
 						<span class="wps-alignRight">
88
-							<strong><?php echo wpshop_tools::formate_number( $order_vat_value ); ?></strong> <?php echo $currency; ?>
88
+							<strong><?php echo wpshop_tools::formate_number($order_vat_value); ?></strong> <?php echo $currency; ?>
89 89
 						</span>
90 90
 					</p>
91 91
 					<?php
92 92
 				endif;
93 93
 		endforeach; ?>
94 94
 		<?php endif; ?>
95
-			<?php if( !empty($cart_content['order_discount_value']) || ( $cart_type == 'admin-panel' ) ) : ?>
95
+			<?php if (!empty($cart_content['order_discount_value']) || ($cart_type == 'admin-panel')) : ?>
96 96
 				<p>
97
-					<?php _e( 'Discount on order', 'wpshop'); ?>
97
+					<?php _e('Discount on order', 'wpshop'); ?>
98 98
 					<span class="wps-alignRight">
99
-						<?php if( ( $cart_type == 'admin-panel' ) && ( empty( $cart_content['order_status'] ) || $cart_content['order_status'] == 'awaiting_payment' || ( ( !empty( $cart_content['cart_type'] ) && $cart_content['cart_type'] == 'quotation' ) && $cart_content['order_status'] != 'completed' ) ) ) : ?>
100
-							<input type="text" id="wps-orders-discount-value" size="5" style="text-align : right" value="<?php echo ( !empty($cart_content['order_discount_value']) ) ? $cart_content['order_discount_value'] : number_format( 0, 2 ); ?>"/>
99
+						<?php if (($cart_type == 'admin-panel') && (empty($cart_content['order_status']) || $cart_content['order_status'] == 'awaiting_payment' || ((!empty($cart_content['cart_type']) && $cart_content['cart_type'] == 'quotation') && $cart_content['order_status'] != 'completed'))) : ?>
100
+							<input type="text" id="wps-orders-discount-value" size="5" style="text-align : right" value="<?php echo (!empty($cart_content['order_discount_value'])) ? $cart_content['order_discount_value'] : number_format(0, 2); ?>"/>
101 101
 						<?php else : ?>
102
-							<?php if( !empty($cart_content['order_discount_value']) ) : ?>
103
-								<strong><?php echo $cart_content['order_discount_value']; ?> <?php echo ( !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent' ) ? '%' : wpshop_tools::wpshop_get_currency(); ?></strong>
102
+							<?php if (!empty($cart_content['order_discount_value'])) : ?>
103
+								<strong><?php echo $cart_content['order_discount_value']; ?> <?php echo (!empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent') ? '%' : wpshop_tools::wpshop_get_currency(); ?></strong>
104 104
 							<?php else : ?>
105 105
 								0 <?php echo wpshop_tools::wpshop_get_currency(); ?>
106 106
 							<?php endif; ?>
107 107
 						<?php endif; ?>
108 108
 					</span>
109 109
 				</p>
110
-				<?php if( ( $cart_type == 'admin-panel' ) && ( empty( $cart_content['order_status'] ) || $cart_content['order_status'] == 'awaiting_payment' || ( ( !empty( $cart_content['cart_type'] ) && $cart_content['cart_type'] == 'quotation' ) && $cart_content['order_status'] != 'completed' ) ) ) : ?>
110
+				<?php if (($cart_type == 'admin-panel') && (empty($cart_content['order_status']) || $cart_content['order_status'] == 'awaiting_payment' || ((!empty($cart_content['cart_type']) && $cart_content['cart_type'] == 'quotation') && $cart_content['order_status'] != 'completed'))) : ?>
111 111
 					<p>
112
-						<?php _e( 'Type of discount on order', 'wpshop'); ?>
112
+						<?php _e('Type of discount on order', 'wpshop'); ?>
113 113
 						<span class="wps-alignRight">
114 114
 							<select id="wps-orders-discount-type">
115
-								<option value="percent" <?php echo ( !empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent' ) ? 'selected="selected"' : ''; ?>>%</option>
116
-								<option value="amount" <?php echo ( !empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'amount' ) ? 'selected="selected"' : ''; ?>><?php echo wpshop_tools::wpshop_get_currency(); ?></option>
115
+								<option value="percent" <?php echo (!empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent') ? 'selected="selected"' : ''; ?>>%</option>
116
+								<option value="amount" <?php echo (!empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'amount') ? 'selected="selected"' : ''; ?>><?php echo wpshop_tools::wpshop_get_currency(); ?></option>
117 117
 							</select>
118 118
 						</span>
119 119
 					</p>
120 120
 				<?php endif; ?>
121 121
 			<?php endif; ?>
122 122
 
123
-			<?php if ( !empty( $cart_content['coupon_id']) ) : ?>
124
-			<p><?php _e( 'Total ATI before discount', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $order_totla_before_discount ); ?></strong> <?php echo $currency; ?></span></p>
125
-			<p><?php _e( 'Discount', 'wpshop'); ?> (<?php echo $coupon_title; ?>) <span class="wps-alignRight"><strong><?php echo $coupon_value; ?></strong><?php echo $currency; ?></span></p>
123
+			<?php if (!empty($cart_content['coupon_id'])) : ?>
124
+			<p><?php _e('Total ATI before discount', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($order_totla_before_discount); ?></strong> <?php echo $currency; ?></span></p>
125
+			<p><?php _e('Discount', 'wpshop'); ?> (<?php echo $coupon_title; ?>) <span class="wps-alignRight"><strong><?php echo $coupon_value; ?></strong><?php echo $currency; ?></span></p>
126 126
 			<?php endif; ?>
127 127
 
128
-			<?php if( !empty($_SESSION['cart']['order_partial_payment']) ) :
129
-				$wps_partial_payment_data = get_option( 'wpshop_payment_partial' );
130
-				if( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) {
128
+			<?php if (!empty($_SESSION['cart']['order_partial_payment'])) :
129
+				$wps_partial_payment_data = get_option('wpshop_payment_partial');
130
+				if (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') {
131 131
 					$partial_payment_informations = $wps_partial_payment_data['for_quotation'];
132 132
 				} else {
133 133
 					$partial_payment_informations = $wps_partial_payment_data['for_all'];
134 134
 				}
135
-				$partial_payment_amount =  $_SESSION['cart']['order_partial_payment'];
135
+				$partial_payment_amount = $_SESSION['cart']['order_partial_payment'];
136 136
 			?>
137
-				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $cart_content['order_grand_total'] ); ?></strong> <?php echo $currency; ?></span></p>
137
+				<p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($cart_content['order_grand_total']); ?></strong> <?php echo $currency; ?></span></p>
138 138
 				<p class="wps-hightlight">
139
-				<?php printf(__('Payable now %s','wpshop'), '(' . $partial_payment_informations['value'] . ( ( !empty($partial_payment_informations['type']) && $partial_payment_informations['type'] == 'percentage' ) ? '%': wpshop_tools::wpshop_get_currency( false ) ) . ')'); ?>
140
-				<span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $partial_payment_amount ); ?></strong> <?php echo $currency; ?>
139
+				<?php printf(__('Payable now %s', 'wpshop'), '(' . $partial_payment_informations['value'] . ((!empty($partial_payment_informations['type']) && $partial_payment_informations['type'] == 'percentage') ? '%' : wpshop_tools::wpshop_get_currency(false)) . ')'); ?>
140
+				<span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($partial_payment_amount); ?></strong> <?php echo $currency; ?>
141 141
 				</span></p>
142
-			<?php elseif ( !empty( $cart_content ) && !empty( $cart_content[ 'order_status'] ) && ( 'partially_paid' == $cart_content[ 'order_status' ] ) && !empty( $cart_content[ 'order_payment' ] ) && !empty( $cart_content[ 'order_payment' ][ 'received' ] ) ) : ?>
143
-				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $cart_content['order_grand_total'] ); ?></strong> <?php echo $currency; ?></span></p>
142
+			<?php elseif (!empty($cart_content) && !empty($cart_content['order_status']) && ('partially_paid' == $cart_content['order_status']) && !empty($cart_content['order_payment']) && !empty($cart_content['order_payment']['received'])) : ?>
143
+				<p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($cart_content['order_grand_total']); ?></strong> <?php echo $currency; ?></span></p>
144 144
 				<?php $allready_received_amount = 0; ?>
145
-				<?php foreach ( $cart_content[ 'order_payment' ][ 'received' ] as $payment ) : ?>
146
-					<?php if ( ! empty( $payment[ 'status' ] ) && 'payment_received' == $payment[ 'status' ] ) : ?>
147
-						<?php $allready_received_amount += $payment[ 'received_amount' ]; ?>
145
+				<?php foreach ($cart_content['order_payment']['received'] as $payment) : ?>
146
+					<?php if (!empty($payment['status']) && 'payment_received' == $payment['status']) : ?>
147
+						<?php $allready_received_amount += $payment['received_amount']; ?>
148 148
 					<?php endif; ?>
149 149
 				<?php endforeach; ?>
150
-				<p><?php _e( 'Already paid', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $allready_received_amount ); ?></strong> <?php echo $currency; ?></span></p>
151
-				<p class="wps-hightlight"><?php _e( 'Due amount for this order', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $cart_content['order_grand_total'] - $allready_received_amount ); ?></strong> <?php echo $currency; ?></span></p>
150
+				<p><?php _e('Already paid', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($allready_received_amount); ?></strong> <?php echo $currency; ?></span></p>
151
+				<p class="wps-hightlight"><?php _e('Due amount for this order', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($cart_content['order_grand_total'] - $allready_received_amount); ?></strong> <?php echo $currency; ?></span></p>
152 152
 			<?php else : ?>
153
-				<?php if ( isset( $_SESSION[ 'cart' ][ 'order_product_partial_payment' ]) ) : ?>
154
-				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $_SESSION['cart']['order_amount_to_pay_now'] ); ?></strong> <?php echo $currency; ?></span></p>
153
+				<?php if (isset($_SESSION['cart']['order_product_partial_payment'])) : ?>
154
+				<p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($_SESSION['cart']['order_amount_to_pay_now']); ?></strong> <?php echo $currency; ?></span></p>
155 155
 				<?php else: ?>
156
-				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $total_ati ); ?></strong> <?php echo $currency; ?></span></p>
156
+				<p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($total_ati); ?></strong> <?php echo $currency; ?></span></p>
157 157
 				<?php endif; ?>
158 158
 			<?php endif; ?>
159 159
 	</div><!-- wps-cart-total -->
160 160
 </div><!-- wps-cart-cartouche -->
161 161
 
162
-<?php if ( empty($cart_type) || ( !empty($cart_type) && $cart_type != 'summary' && $cart_type != 'admin-panel')  ) : ?>
162
+<?php if (empty($cart_type) || (!empty($cart_type) && $cart_type != 'summary' && $cart_type != 'admin-panel')) : ?>
163 163
 <div class="wps-checkout-actions">
164
-	<button data-nonce="<?php echo wp_create_nonce( 'wps_empty_cart' ); ?>" class="wps-bton-second emptyCart"><?php _e( 'Empty the cart', 'wpshop' ); ?></button>
165
-	<?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?>
166
-		<button class="wps-bton-first" data-nonce="<?php echo wp_create_nonce( 'wps_cart_pass_to_step_two' ); ?>" id="wps-cart-order-action"><?php _e( 'Validate my quotation', 'wpshop' ); ?></button>
164
+	<button data-nonce="<?php echo wp_create_nonce('wps_empty_cart'); ?>" class="wps-bton-second emptyCart"><?php _e('Empty the cart', 'wpshop'); ?></button>
165
+	<?php if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') : ?>
166
+		<button class="wps-bton-first" data-nonce="<?php echo wp_create_nonce('wps_cart_pass_to_step_two'); ?>" id="wps-cart-order-action"><?php _e('Validate my quotation', 'wpshop'); ?></button>
167 167
 	<?php else : ?>
168
-		<button class="wps-bton-first" data-nonce="<?php echo wp_create_nonce( 'wps_cart_pass_to_step_two' ); ?>" id="wps-cart-order-action"><?php _e( 'Order', 'wpshop' ); ?></button>
168
+		<button class="wps-bton-first" data-nonce="<?php echo wp_create_nonce('wps_cart_pass_to_step_two'); ?>" id="wps-cart-order-action"><?php _e('Order', 'wpshop'); ?></button>
169 169
 	<?php endif; ?>
170 170
 </div>
171 171
 <div class="wps-cart-notices">
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 </div>
176 176
 <?php endif; ?>
177 177
 
178
-<?php if( !empty($cart_type) && $cart_type == 'admin-panel' && ( empty( $cart_content['order_status'] ) || $cart_content['order_status'] == 'awaiting_payment' || ( ( !empty( $cart_content['cart_type'] ) && $cart_content['cart_type'] == 'quotation' ) && $cart_content['order_status'] != 'completed' ) ) ) : ?>
179
-	<button class="wps-bton-second-rounded alignRight" data-nonce="<?php echo wp_create_nonce( 'wps_orders_update_cart_informations' ); ?>" id="wps-orders-update-cart-informations"><i class="dashicons dashicons-update"></i><?php _e( 'Update order informations', 'wpshop'); ?></button>
178
+<?php if (!empty($cart_type) && $cart_type == 'admin-panel' && (empty($cart_content['order_status']) || $cart_content['order_status'] == 'awaiting_payment' || ((!empty($cart_content['cart_type']) && $cart_content['cart_type'] == 'quotation') && $cart_content['order_status'] != 'completed'))) : ?>
179
+	<button class="wps-bton-second-rounded alignRight" data-nonce="<?php echo wp_create_nonce('wps_orders_update_cart_informations'); ?>" id="wps-orders-update-cart-informations"><i class="dashicons dashicons-update"></i><?php _e('Update order informations', 'wpshop'); ?></button>
180 180
 <?php endif; ?>
181 181
 <?php $wps_payment_mode = get_option('wps_payment_mode'); ?>
182
-<?php if( isset( $wps_payment_mode['mode']['paypal']['active'] ) ): ?>
182
+<?php if (isset($wps_payment_mode['mode']['paypal']['active'])): ?>
183 183
 	<div class="wps-secured-logos">
184 184
 		<span class="wps-logo-paypal"></span>
185 185
 		<span class="wps-logo-visa"></span>
Please login to merge, or discard this patch.
includes/librairies/purchase/orders.class.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Products management method file
4 4
  *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		/**	Add action button	*/
71 71
 		add_meta_box(
72 72
 			'wpshop_order_actions',
73
-			'<span class="dashicons dashicons-info"></span> '.__('Actions on order', 'wpshop'),
73
+			'<span class="dashicons dashicons-info"></span> ' . __('Actions on order', 'wpshop'),
74 74
 			array('wpshop_orders', 'order_actions'),
75 75
 				WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'high'
76 76
 		);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param object $order The current order being edited
112 112
 	 */
113
-	public static function order_actions( $order ) {
113
+	public static function order_actions($order) {
114 114
 		$output = '';
115 115
 
116 116
 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
@@ -118,37 +118,37 @@  discard block
 block discarded – undo
118 118
 
119 119
 		$tpl_component = array();
120 120
 
121
-		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url( get_delete_post_link($order->ID) ) , 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') :  __('Move to Trash', 'wpshop'))), array(), 'admin');
122
-		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : '';
121
+		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url(get_delete_post_link($order->ID)), 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin');
122
+		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : '';
123 123
 
124 124
 		/**	Add an action list	*/
125 125
 		$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = '';
126 126
 
127 127
 		/**	Display main information about the order	*/
128 128
 		$order_main_info = '';
129
-		if(!empty($order_postmeta['order_date'])){
130
-			$order_main_info .=  '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>'.__('Order date','wpshop').' : </strong><br/>'.mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true).'</div>';
129
+		if (!empty($order_postmeta['order_date'])) {
130
+			$order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>' . __('Order date', 'wpshop') . ' : </strong><br/>' . mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true) . '</div>';
131 131
 		}
132 132
 		$order_main_info .= '<div class="wps-product-section">';
133
-		if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){
134
-			$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>';
133
+		if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) {
134
+			$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>';
135 135
 		}
136
-		else{
137
-			if(!empty($order_postmeta['order_key'])){
138
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>';
136
+		else {
137
+			if (!empty($order_postmeta['order_key'])) {
138
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>';
139 139
 			}
140
-			if(!empty($order_postmeta['order_temporary_key'])){
141
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>';
142
-				$post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0;
143
-				$order_main_info .= '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf' ) . '">' .__('Download the quotation', 'wpshop'). '</a><br />';
140
+			if (!empty($order_postmeta['order_temporary_key'])) {
141
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>';
142
+				$post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0;
143
+				$order_main_info .= '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf') . '">' . __('Download the quotation', 'wpshop') . '</a><br />';
144 144
 			}
145
-			if(!empty($order_postmeta['order_invoice_ref'])){
145
+			if (!empty($order_postmeta['order_invoice_ref'])) {
146 146
 				$sub_tpl_component = array();
147 147
 				$sub_tpl_component['ADMIN_ORDER_RECEIVED_PAYMENT_INVOICE_REF'] = $order_postmeta['order_invoice_ref'];
148 148
 				$sub_tpl_component['ADMIN_ORDER_PAYMENT_RECEIVED_LINE_CLASSES'] = '';
149
-				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID );
149
+				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID);
150 150
 				$order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin');
151
-				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . '';
151
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . '';
152 152
 			}
153 153
 			else {
154 154
 				$order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin');
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 
160 160
 		/*Add the current order status in display**/
161
-			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= ( !empty($order_postmeta['order_status']) ) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) ) : '';
161
+			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= (!empty($order_postmeta['order_status'])) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop'))) : '';
162 162
 
163 163
 			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info;
164 164
 
@@ -184,21 +184,21 @@  discard block
 block discarded – undo
184 184
 		}*/
185 185
 
186 186
 		/*Add the button regarding the order status**/
187
-		if ( !empty($order_postmeta['order_status']) ) {
188
-			if( in_array( $order_postmeta['order_status'], array( 'awaiting_payment', 'partially_paid' ) ) ) {
189
-				$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url( $order->ID ) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __( 'Copy', 'wpshop' ) . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce( 'wps_send_direct_payment_link' ) . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __( 'Send by mail', 'wpshop' ) . '"><span class="dashicons dashicons-email"></span></a><p>' . sprintf( __( 'Link is valid until %s', 'wpshop' ), mysql2date( get_option( 'date_format' ), date_format( date_create( date('Y-m') . ' + 1month - 1day' ), 'Y-m-d H:i:s' ), true ) ) . '</div>';
187
+		if (!empty($order_postmeta['order_status'])) {
188
+			if (in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) {
189
+				$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url($order->ID) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __('Copy', 'wpshop') . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce('wps_send_direct_payment_link') . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __('Send by mail', 'wpshop') . '"><span class="dashicons dashicons-email"></span></a><p>' . sprintf(__('Link is valid until %s', 'wpshop'), mysql2date(get_option('date_format'), date_format(date_create(date('Y-m') . ' + 1month - 1day'), 'Y-m-d H:i:s'), true)) . '</div>';
190 190
 			}
191
-			if( $order_postmeta['order_status'] == 'awaiting_payment' ) {
192
-				$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_'.$order->ID.'" >'.__('Cancel this order', 'wpshop').'</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
191
+			if ($order_postmeta['order_status'] == 'awaiting_payment') {
192
+				$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_' . $order->ID . '" >' . __('Cancel this order', 'wpshop') . '</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
193 193
 			}
194
-			$credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true );
194
+			$credit_meta = get_post_meta($order->ID, '_wps_order_credit', true);
195 195
 
196
-			if ( empty($credit_meta) ) {
197
-				if( $order_postmeta['order_status'] == 'refunded') {
198
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' .$order->ID. '&amp;invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok' ). '" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>';
196
+			if (empty($credit_meta)) {
197
+				if ($order_postmeta['order_status'] == 'refunded') {
198
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' . __('Credit Slip number', 'wpshop') . ' : <strong>' . ((!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref'])) ? '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&amp;invoice_ref=' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '&credit_slip=ok') . '" target="_blank">' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '</a>' : '') . '</strong></div>';
199 199
 				}
200 200
 				else {
201
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
201
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' . $order->ID . '">' . __('Refund this order', 'wpshop') . '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
202 202
 				}
203 203
 			}
204 204
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	function order_container_in_admin() {
211 211
 		global $post;
212 212
 		$output  = '<div id="wps_order_content_container">';
213
-		$output .= self::order_content( $post );
213
+		$output .= self::order_content($post);
214 214
 		$output .= '</div>';
215 215
 		echo $output;
216 216
 	}
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param order $post The complete order content
223 223
 	 */
224
-	function order_content( $post ) {
224
+	function order_content($post) {
225 225
 		$order_content = '';
226 226
 
227 227
 		$order = get_post_meta($post->ID, '_order_postmeta', true);
228 228
 
229 229
 		$order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >';
230
-		if($order){/*	Read the order content if the order has product	*/
230
+		if ($order) {/*	Read the order content if the order has product	*/
231 231
 			$order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin');
232 232
 			if (empty($order['order_invoice_ref'])) {
233 233
 				$order_content .= '<div id="order_refresh_button_container" class="wpshop_clear_block" ><input type="button" class="button-primary alignright wpshopHide" id="wpshop_admin_order_recalculate" value="' . __('Refresh order informations', 'wpshop') . '" /></div>';
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
 	/** Generate the billing reference regarding the order $order_id
246 246
 	 * @return void
247 247
 	*/
248
-	function order_generate_billing_number($order_id, $force_invoicing = false){
248
+	function order_generate_billing_number($order_id, $force_invoicing = false) {
249 249
 		global $wpdb, $wpshop_modules_billing;
250 250
 
251 251
 		// Get the order from the db
252 252
 		$order = get_post_meta($order_id, '_order_postmeta', true);
253 253
 
254 254
 		// If the payment is completed
255
-		if(($order['order_status']=='completed') || $force_invoicing) {
255
+		if (($order['order_status'] == 'completed') || $force_invoicing) {
256 256
 
257 257
 			// If the reference hasn't been generated yet
258
-			if(empty($order['order_invoice_ref'])) {
259
-				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id );
258
+			if (empty($order['order_invoice_ref'])) {
259
+				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id);
260 260
 
261 261
 				update_post_meta($order_id, '_order_postmeta', $order);
262 262
 			}
@@ -267,45 +267,45 @@  discard block
 block discarded – undo
267 267
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
268 268
 	* @return int
269 269
 	*/
270
-	public static function get_new_order_reference(){
270
+	public static function get_new_order_reference() {
271 271
 		$number_figures = get_option('wpshop_order_number_figures', false);
272 272
 		/* If the number doesn't exist, we create a default one */
273
-		if(!$number_figures){
273
+		if (!$number_figures) {
274 274
 			$number_figures = 5;
275 275
 			update_option('wpshop_order_number_figures', $number_figures);
276 276
 		}
277 277
 
278 278
 		$order_current_number = get_option('wpshop_order_current_number', false);
279 279
 		/* If the counter doesn't exist, we initiate it */
280
-		if(!$order_current_number) { $order_current_number = 1; }
280
+		if (!$order_current_number) { $order_current_number = 1; }
281 281
 		else { $order_current_number++; }
282 282
 		update_option('wpshop_order_current_number', $order_current_number);
283 283
 
284
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
285
-		return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref;
284
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
285
+		return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref;
286 286
 	}
287 287
 
288 288
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
289 289
 	* @return int
290 290
 	*/
291
-	public static function get_new_pre_order_reference($save = true){
291
+	public static function get_new_pre_order_reference($save = true) {
292 292
 		$number_figures = get_option('wpshop_order_number_figures', false);
293 293
 		/* If the number doesn't exist, we create a default one */
294
-		if(!$number_figures){
294
+		if (!$number_figures) {
295 295
 			$number_figures = 5;
296 296
 			update_option('wpshop_order_number_figures', $number_figures);
297 297
 		}
298 298
 
299 299
 		$order_current_number = get_option('wpshop_preorder_current_number', false);
300 300
 		/* If the counter doesn't exist, we initiate it */
301
-		if(!$order_current_number) { $order_current_number = 1; }
301
+		if (!$order_current_number) { $order_current_number = 1; }
302 302
 		else { $order_current_number++; }
303
-		if($save){
303
+		if ($save) {
304 304
 			update_option('wpshop_preorder_current_number', $order_current_number);
305 305
 		}
306 306
 
307
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
308
-		return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref;
307
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
308
+		return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref;
309 309
 	}
310 310
 
311 311
 
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 *	@return void
322 322
 	 */
323
-	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){
323
+	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') {
324 324
 		/**	Get order informations	*/
325 325
 		$billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
326
-		$billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
327
-		$billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : '';
328
-		if ( !empty($_SESSION['shipping_partner_id']) ) {
329
-			$partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
326
+		$billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
327
+		$billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : '';
328
+		if (!empty($_SESSION['shipping_partner_id'])) {
329
+			$partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
330 330
 			if (!empty($partner_address_id)) {
331
-				foreach( $partner_address_id as $address_id ) {
331
+				foreach ($partner_address_id as $address_id) {
332 332
 					$shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
333
-					$shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
333
+					$shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
334 334
 				}
335 335
 			}
336 336
 		}
337 337
 		else {
338 338
 			$shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
339
-			$shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
340
-			$shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : '';
339
+			$shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
340
+			$shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : '';
341 341
 		}
342 342
 
343 343
 		$order_info = array('billing' => $billing_info, 'shipping' => $shipping_info);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	/** Set the custom colums
351 351
 	 * @return array
352 352
 	*/
353
-	static function orders_edit_columns($columns){
353
+	static function orders_edit_columns($columns) {
354 354
 	  $columns = array(
355 355
 		'cb' => '<input type="checkbox" />',
356 356
 		'order_identifier' => __('Identifiers', 'wpshop'),
@@ -370,42 +370,42 @@  discard block
 block discarded – undo
370 370
 	 * @return array
371 371
 	*/
372 372
 	public static function orders_custom_columns($column, $post_id) {
373
-		if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) {
373
+		if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) {
374 374
 			global $civility, $order_status;
375 375
 
376 376
 			$metadata = get_post_custom();
377 377
 
378
-			$order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):'';
379
-			$addresses = get_post_meta($post_id,'_order_info', true);
378
+			$order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : '';
379
+			$addresses = get_post_meta($post_id, '_order_info', true);
380 380
 
381
-			switch($column){
381
+			switch ($column) {
382 382
 				case "order_identifier":
383
-					if( !empty( $order_postmeta['order_key'] ) ) {
383
+					if (!empty($order_postmeta['order_key'])) {
384 384
 						echo '<b>' . $order_postmeta['order_key'] . '</b><br>';
385 385
 					}
386
-					if( !empty( $order_postmeta['order_invoice_ref'] ) ) {
386
+					if (!empty($order_postmeta['order_invoice_ref'])) {
387 387
 						echo '<i>' . $order_postmeta['order_invoice_ref'] . '</i>';
388
-					} elseif( !empty($order_postmeta['order_temporary_key'] ) ) {
388
+					} elseif (!empty($order_postmeta['order_temporary_key'])) {
389 389
 						echo '<b>' . $order_postmeta['order_temporary_key'] . '</b>';
390 390
 					}
391 391
 				break;
392 392
 
393 393
 				case "order_status":
394
-					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_'.$post_id.'">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
394
+					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_' . $post_id . '">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
395 395
 				break;
396 396
 
397 397
 				case "order_billing":
398
-					if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) {
398
+					if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) {
399 399
 						$billing = $addresses['billing']['address'];
400 400
 					}
401
-					else if ( !empty($addresses['billing']) ) {
401
+					else if (!empty($addresses['billing'])) {
402 402
 						$billing = $addresses['billing'];
403 403
 					}
404
-					if ( !empty($billing) ) {
405
-						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null).' <strong>'.(!empty($billing['address_first_name']) ? $billing['address_first_name'] : null).' '.(!empty($billing['address_last_name']) ? $billing['address_last_name'] : null).'</strong>';
406
-						echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />';
407
-						echo (!empty($billing['address']) ? $billing['address'] : null).'<br />';
408
-						echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null);
404
+					if (!empty($billing)) {
405
+						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null) . ' <strong>' . (!empty($billing['address_first_name']) ? $billing['address_first_name'] : null) . ' ' . (!empty($billing['address_last_name']) ? $billing['address_last_name'] : null) . '</strong>';
406
+						echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />';
407
+						echo (!empty($billing['address']) ? $billing['address'] : null) . '<br />';
408
+						echo (!empty($billing['postcode']) ? $billing['postcode'] : null) . ' ' . (!empty($billing['city']) ? $billing['city'] : null) . ', ' . (!empty($billing['country']) ? $billing['country'] : null);
409 409
 						echo (!empty($billing['phone']) ? '<br />' . $billing['phone'] : '');
410 410
 					}
411 411
 					else {
@@ -414,33 +414,33 @@  discard block
 block discarded – undo
414 414
 				break;
415 415
 
416 416
 				case "order_shipping":
417
-					if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) {
417
+					if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) {
418 418
 						$shipping = $addresses['shipping']['address'];
419 419
 					}
420
-					else if ( !empty($addresses['shipping']) ) {
420
+					else if (!empty($addresses['shipping'])) {
421 421
 						$shipping = $addresses['shipping'];
422 422
 					}
423
-					if ( !empty($shipping) ) {
424
-						echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>';
425
-						echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />';
426
-						echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />';
427
-						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null);
423
+					if (!empty($shipping)) {
424
+						echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>';
425
+						echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />';
426
+						echo (!empty($shipping['address']) ? $shipping['address'] : null) . '<br />';
427
+						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null) . ' ' . (!empty($shipping['city']) ? $shipping['city'] : null) . ', ' . (!empty($shipping['country']) ? $shipping['country'] : null);
428 428
 					}
429
-					else{
429
+					else {
430 430
 						echo __('No information available for user shipping', 'wpshop');
431 431
 					}
432 432
 				break;
433 433
 
434 434
 				case "order_type":
435
-						echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.(!empty($order_postmeta['order_temporary_key']) ? __('Quotation','wpshop') :  __('Basic order','wpshop')).'</a>';
435
+						echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>';
436 436
 						$buttons = '<p class="row-actions">';
437 437
 						// Voir la commande
438
-						$buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>';
438
+						$buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>';
439 439
 						// Marquer comme envoy�
440 440
 						if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) {
441
-							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> ';
441
+							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader">' . __('Mark as shipped', 'wpshop') . '</a> ';
442 442
 						}
443
-						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
443
+						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) {
444 444
 							//		$buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' ';
445 445
 						}
446 446
 						$buttons .= '</p>';
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
 				case "order_total":
455 455
 					$currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency');
456
-					echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '.  wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
456
+					echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
457 457
 				break;
458 458
 
459 459
 				/*case "order_actions":
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	}
482 482
 
483 483
 	public static function list_table_filters() {
484
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
485
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
486
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
487
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
484
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
485
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
486
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
487
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
488 488
 
489 489
 		if (isset($post_type)) {
490 490
 			if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) {
@@ -496,23 +496,23 @@  discard block
 block discarded – undo
496 496
 				echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index');
497 497
 				$min = $entity_filter_btpf;
498 498
 				$max = $entity_filter_btps;
499
-				echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> ';
500
-				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null);
501
-				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null);
499
+				echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> ';
500
+				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null);
501
+				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null);
502 502
 			}
503 503
 		}
504 504
 	}
505 505
 
506 506
 	public static function list_table_filter_parse_query($query) {
507 507
 		global $pagenow, $wpdb;
508
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
509
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
510
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
511
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
508
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
509
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
510
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
511
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
512 512
 
513
-		if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) {
513
+		if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) {
514 514
 			$check = null;
515
-			switch ( $entity_filter ) {
515
+			switch ($entity_filter) {
516 516
 				case 'all':
517 517
 					$sql_query = $wpdb->prepare(
518 518
 						"SELECT ID
@@ -576,27 +576,27 @@  discard block
 block discarded – undo
576 576
 						break;
577 577
 			}
578 578
 
579
-			if ( !empty( $check ) ) {
580
-				if( !empty($no_btp) && $no_btp == 'yes' ) {
579
+			if (!empty($check)) {
580
+				if (!empty($no_btp) && $no_btp == 'yes') {
581 581
 					$min = 'minimum';
582 582
 					$max = 'maximum';
583 583
 				} else {
584
-					$min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum';
585
-					$max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum';
584
+					$min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum';
585
+					$max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum';
586 586
 				}
587 587
 				$results = $wpdb->get_results($sql_query);
588 588
 				$post_id_list = array();
589 589
 				$i = 0;
590
-				foreach($results as $item){
590
+				foreach ($results as $item) {
591 591
 					$meta_value = get_post_meta($item->ID, '_order_postmeta');
592
-					$price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : '';
593
-					if( $price >= $min || $min == 'minimum' ) {
594
-						if( $price <= $max || $max == 'maximum' ) {
592
+					$price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : '';
593
+					if ($price >= $min || $min == 'minimum') {
594
+						if ($price <= $max || $max == 'maximum') {
595 595
 							$post_id_list[] = $item->ID;
596 596
 						}
597 597
 					}
598 598
 				}
599
-				if( empty($post_id_list) ) {
599
+				if (empty($post_id_list)) {
600 600
 					$post_id_list[] = 'no_result';
601 601
 				}
602 602
 				$query->query_vars[$check] = $post_id_list;
@@ -607,55 +607,55 @@  discard block
 block discarded – undo
607 607
 
608 608
 
609 609
 
610
-	function latest_products_ordered ( $orders ) {
610
+	function latest_products_ordered($orders) {
611 611
 		global $wpdb;
612 612
 		$product_id = $output = '';
613 613
 		$products = array();
614 614
 		$display_option = get_option('wpshop_display_option');
615
-		if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) {
616
-			foreach( $orders as $order ) {
617
-				$order_content = get_post_meta( $order->ID, '_order_postmeta', true );
618
-				if ( !empty($order_content) && !empty( $order_content['order_items']) ) {
615
+		if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) {
616
+			foreach ($orders as $order) {
617
+				$order_content = get_post_meta($order->ID, '_order_postmeta', true);
618
+				if (!empty($order_content) && !empty($order_content['order_items'])) {
619 619
 
620
-					foreach( $order_content['order_items'] as $item ) {
621
-						if ( count( $products) >= $display_option['latest_products_ordered'] ) {
620
+					foreach ($order_content['order_items'] as $item) {
621
+						if (count($products) >= $display_option['latest_products_ordered']) {
622 622
 							continue;
623 623
 						}
624 624
 						$product_id = $item['item_id'];
625
-						if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) {
626
-							$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );
627
-							if ( !empty( $parent_def ) ) {
625
+						if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) {
626
+							$parent_def = wpshop_products::get_parent_variation($item['item_id']);
627
+							if (!empty($parent_def)) {
628 628
 								$parent_post = $parent_def['parent_post'];
629 629
 								$product_id = $parent_post->ID;
630 630
 							}
631 631
 						}
632 632
 
633
-						if ( !in_array($product_id, $products) ) {
633
+						if (!in_array($product_id, $products)) {
634 634
 							$products[] = $product_id;
635 635
 						}
636 636
 					}
637 637
 				}
638 638
 			}
639
-			if ( !empty($products) ) {
639
+			if (!empty($products)) {
640 640
 				$products_id = implode(",", $products);
641
-				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) );
641
+				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]')));
642 642
 			}
643 643
 		}
644 644
 		return $output;
645 645
 	}
646 646
 
647
-	function get_order_list_for_customer( $customer_id ) {
647
+	function get_order_list_for_customer($customer_id) {
648 648
 		global $wpdb;
649 649
 		$output = '';
650 650
 
651
-		if( !empty($customer_id) ) {
652
-			 $query = $wpdb->prepare( 'SELECT *
653
-							 		   FROM ' .$wpdb->posts. '
651
+		if (!empty($customer_id)) {
652
+			 $query = $wpdb->prepare('SELECT *
653
+							 		   FROM ' .$wpdb->posts . '
654 654
 							 		   WHERE post_author = %d
655
-							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
656
-			 $orders = $wpdb->get_results( $query );
655
+							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
656
+			 $orders = $wpdb->get_results($query);
657 657
 
658
-			 foreach( $orders as $order ) {
658
+			 foreach ($orders as $order) {
659 659
 
660 660
 			 }
661 661
 		}
Please login to merge, or discard this patch.
includes/librairies/display/display.class.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	*
31 31
 	*	@return string Html code composing the page header
32 32
 	*/
33
-	public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){
34
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php');
33
+	public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = '') {
34
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_header.tpl.php');
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	*
42 42
 	*	@return string Html code composing the page footer
43 43
 	*/
44
-	public static function displayPageFooter($formActionButton){
45
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php');
44
+	public static function displayPageFooter($formActionButton) {
45
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_footer.tpl.php');
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	*
51 51
 	*	@return string The complete html page output
52 52
 	*/
53
-	public static function display_page(){
53
+	public static function display_page() {
54 54
 
55 55
 		$pageAddButton = false;
56 56
 		$pageMessage = $addButtonLink = $pageFormButton = $pageIcon = $pageIconTitle = $pageIconAlt = $objectType = '';
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : '';
61 61
 
62 62
 		/*	Select the content to add to the page looking for the parameter	*/
63
-		switch($pageSlug){
63
+		switch ($pageSlug) {
64 64
 			case WPSHOP_URL_SLUG_ATTRIBUTE_LISTING:
65 65
 				$objectType = new wpshop_attributes();
66 66
 				$current_user_can_edit = current_user_can('wpshop_edit_attributes');
67 67
 				$current_user_can_add = current_user_can('wpshop_add_attributes');
68 68
 				$current_user_can_delete = current_user_can('wpshop_delete_attributes');
69
-				if(current_user_can('wpshop_add_attributes')){
69
+				if (current_user_can('wpshop_add_attributes')) {
70 70
 					$pageAddButton = true;
71 71
 				}
72 72
 			break;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 				$current_user_can_edit = current_user_can('wpshop_edit_attribute_set');
76 76
 				$current_user_can_add = current_user_can('wpshop_add_attribute_set');
77 77
 				$current_user_can_delete = current_user_can('wpshop_delete_attribute_set');
78
-				if(current_user_can('wpshop_add_attribute_set')){
78
+				if (current_user_can('wpshop_add_attribute_set')) {
79 79
 					$pageAddButton = true;
80 80
 				}
81 81
 			break;
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 				$pageAddButton = false;
89 89
 				$objectType = new wpshop_messages();
90 90
 				$current_user_can_edit = true;
91
-				$mid = !empty( $_GET['mid'] ) ? sanitize_text_field( $_GET['mid'] ) : '';
92
-				if(!empty($mid)){
91
+				$mid = !empty($_GET['mid']) ? sanitize_text_field($_GET['mid']) : '';
92
+				if (!empty($mid)) {
93 93
 					$action = 'edit';
94 94
 				}
95 95
 			break;
96 96
 			default:{
97
-				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ - 4));
97
+				$pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ -4));
98 98
 				$pageAddButton = false;
99 99
 			}
100 100
 			break;
101 101
 		}
102 102
 
103
-		if($objectType != ''){
104
-			if(($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))){
103
+		if ($objectType != '') {
104
+			if (($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))) {
105 105
 				$outputType = 'adding';
106 106
 			}
107 107
 			$objectType->elementAction();
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 			$pageIconTitle = self::getPageIconInformation('title', $objectType);
111 111
 			$pageIconAlt = self::getPageIconInformation('alt', $objectType);
112 112
 
113
-			if($outputType == 'listing'){
113
+			if ($outputType == 'listing') {
114 114
 				$pageContent = $objectType->elementList();
115 115
 			}
116
-			elseif($outputType == 'adding'){
116
+			elseif ($outputType == 'adding') {
117 117
 				$pageAddButton = false;
118 118
 
119 119
 				$pageFormButton = $objectType->getPageFormButton($objectToEdit);
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
 			$pageTitle = $objectType->pageTitle();
125 125
 			$pageMessage = $objectType->pageMessage;
126
-			if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) {
126
+			if (in_array($objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING))) {
127 127
 				$addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&amp;action=add');
128 128
 			}
129 129
 			else {
130
-				$addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
130
+				$addButtonLink = admin_url('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '&amp;page=' . $objectType->getEditionSlug() . '&amp;action=add');
131 131
 			}
132 132
 		}
133 133
 
@@ -149,37 +149,37 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string The output builded from selected type
151 151
 	 */
152
-	public static function custom_page_output_builder($content, $output_type='tab') {
152
+	public static function custom_page_output_builder($content, $output_type = 'tab') {
153 153
 		$output_custom_layout = '';
154 154
 
155
-		switch ( $output_type ) {
155
+		switch ($output_type) {
156 156
 			case 'separated_bloc':
157
-				foreach ( $content as $element_type => $element_type_details ) {
158
-					$output_custom_layout.='
159
-	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type.'" >';
160
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
161
-						$output_custom_layout.='
162
-		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >
157
+				foreach ($content as $element_type => $element_type_details) {
158
+					$output_custom_layout .= '
159
+	<div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type . '" >';
160
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
161
+						$output_custom_layout .= '
162
+		<div class="wpshop_admin_box wpshop_admin_box_'.$element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >
163 163
 			<h3>' . $element_type_content['title'] . '</h3>' . $element_type_content['content'] . '
164 164
 		</div>';
165 165
 					}
166
-					$output_custom_layout.='
166
+					$output_custom_layout .= '
167 167
 	</div>';
168 168
 				}
169 169
 			break;
170 170
 			case 'tab':
171
-				$tab_list=$tab_content_list='';
172
-				foreach ( $content as $element_type => $element_type_details ) {
173
-					foreach ( $element_type_details as $element_type_key => $element_type_content ) {
174
-						$tab_list.='
175
-		<li><a href="#wpshop_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['title'].'</a></li>';
176
-						$tab_content_list.='
177
-		<div id="wpshop_'.$element_type.'_'.$element_type_key.'" class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['content'].'
171
+				$tab_list = $tab_content_list = '';
172
+				foreach ($content as $element_type => $element_type_details) {
173
+					foreach ($element_type_details as $element_type_key => $element_type_content) {
174
+						$tab_list .= '
175
+		<li><a href="#wpshop_'.$element_type . '_' . $element_type_key . '" >' . $element_type_content['title'] . '</a></li>';
176
+						$tab_content_list .= '
177
+		<div id="wpshop_'.$element_type . '_' . $element_type_key . '" class="wpshop_admin_box wpshop_admin_box_' . $element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >' . $element_type_content['content'] . '
178 178
 		</div>';
179 179
 					}
180 180
 				}
181
-				$output_custom_layout.='
182
-	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type.'_tabs" >
181
+				$output_custom_layout .= '
182
+	<div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type . '_tabs" >
183 183
 		<ul>' . $tab_list . '</ul>' . $tab_content_list . '
184 184
 	</div>';
185 185
 					break;
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 *	@return string $table The html code of the table to output
203 203
 	 */
204
-	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true){
204
+	public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true) {
205 205
 		$tableTitleBar = $tableBody = '';
206 206
 
207 207
 		/*	Create the header and footer row	*/
208
-		for($i=0; $i<count($tableTitles); $i++){
208
+		for ($i = 0; $i < count($tableTitles); $i++) {
209 209
 			$tableTitleBar .= '
210 210
 				<th class="' . $tableClasses[$i] . '" scope="col" >' . $tableTitles[$i] . '</th>';
211 211
 		}
212 212
 
213 213
 		/*	Create each table row	*/
214
-		for($lineNumber=0; $lineNumber<count($tableRows); $lineNumber++){
214
+		for ($lineNumber = 0; $lineNumber < count($tableRows); $lineNumber++) {
215 215
 			$tableRow = $tableRows[$lineNumber];
216 216
 			$tableBody .= '
217 217
 		<tr id="' . $tableRowsId[$lineNumber] . '" class="tableRow" >';
218
-			for($i=0; $i<count($tableRow); $i++){
218
+			for ($i = 0; $i < count($tableRow); $i++) {
219 219
 				$tableBody .= '
220 220
 			<td class="' . $tableClasses[$i] . ' ' . $tableRow[$i]['class'] . '" >' . $tableRow[$i]['value'] . '</td>';
221 221
 			}
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
 		/*	Create the table output	*/
227 227
 		$table = '
228 228
 <table id="' . $tableId . '" cellspacing="0" cellpadding="0" class="widefat post fixed" >';
229
-		if($tableTitleBar != ''){
229
+		if ($tableTitleBar != '') {
230 230
 			$table .= '
231 231
 	<thead>
232 232
 			<tr class="tableTitleHeader" >' . $tableTitleBar . '
233 233
 			</tr>
234 234
 	</thead>';
235
-			if($withFooter){
235
+			if ($withFooter) {
236 236
 				$table .= '
237 237
 	<tfoot>
238 238
 			<tr class="tableTitleFooter" >' . $tableTitleBar . '
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return string $pageIconInformation The information to output in the page
257 257
 	 */
258
-	public static function getPageIconInformation($infoType, $object){
259
-		switch($infoType){
258
+	public static function getPageIconInformation($infoType, $object) {
259
+		switch ($infoType) {
260 260
 			case 'path':
261 261
 				$pageIconInformation = $object->pageIcon;
262 262
 			break;
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return string $file_path The good filepath to include
280 280
 	 */
281
-	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false){
281
+	public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false) {
282 282
 		$file_path = '';
283 283
 		$the_file = $dir_name . '/' . $file_name;
284 284
 
285 285
 		if (is_file(get_stylesheet_directory() . '/' . $the_file)) {
286 286
 			$default_dir = str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, get_stylesheet_directory());
287
-			if($usage_type == 'include'){
287
+			if ($usage_type == 'include') {
288 288
 				$default_dir = get_stylesheet_directory();
289 289
 			}
290 290
 			$file_path = $default_dir . '/' . $the_file;
291 291
 		}
292
-		else if ( !$check_only_custom ) {
292
+		else if (!$check_only_custom) {
293 293
 			$file_path = $default_dir . $the_file;
294 294
 		}
295 295
 
@@ -312,124 +312,124 @@  discard block
 block discarded – undo
312 312
 		$custom_template_part = get_stylesheet_directory() . '/' . $default_template_dir . '/';
313 313
 
314 314
 		/** Let support the old way of template managing	*/
315
-		switch ( $template_part ) {
315
+		switch ($template_part) {
316 316
 			case 'category_mini_list':
317 317
 					$old_file_to_take_care_url = 'category-mini-list.tpl.php';
318
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
318
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
319 319
 						$old_file_to_take_care = true;
320 320
 					endif;
321 321
 				break;
322 322
 			case 'category_mini_grid':
323 323
 					$old_file_to_take_care_url = 'category-mini-grid.tpl.php';
324
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
324
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
325 325
 						$old_file_to_take_care = true;
326 326
 					endif;
327 327
 				break;
328 328
 			case 'product_complete_tpl':
329 329
 					$old_file_to_take_care_url = 'product.tpl.php';
330
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
330
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
331 331
 						$old_file_to_take_care = true;
332 332
 					endif;
333 333
 				break;
334 334
 			case 'product_mini_list':
335 335
 					$old_file_to_take_care_url = 'product-mini-list.tpl.php';
336
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
336
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
337 337
 						$old_file_to_take_care = true;
338 338
 					endif;
339 339
 				break;
340 340
 			case 'product_mini_grid':
341 341
 					$old_file_to_take_care_url = 'product-mini-grid.tpl.php';
342
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
342
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
343 343
 						$old_file_to_take_care = true;
344 344
 					endif;
345 345
 				break;
346 346
 			case 'product_listing_sorting':
347 347
 					$old_file_to_take_care_url = 'product_listing_sorting.tpl.php';
348
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
348
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
349 349
 						$old_file_to_take_care = true;
350 350
 					endif;
351 351
 				break;
352 352
 			case 'unavailable_product_button':
353 353
 					$old_file_to_take_care_url = 'not_available_product_button.tpl.php';
354
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
354
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
355 355
 						$old_file_to_take_care = true;
356 356
 					endif;
357 357
 				break;
358 358
 			case 'add_to_cart_button':
359 359
 					$old_file_to_take_care_url = 'available_product_button.tpl.php';
360
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
360
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
361 361
 						$old_file_to_take_care = true;
362 362
 					endif;
363 363
 				break;
364 364
 			case 'ask_quotation_button':
365 365
 					$old_file_to_take_care_url = 'quotation_button.tpl.php';
366
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
366
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
367 367
 						$old_file_to_take_care = true;
368 368
 					endif;
369 369
 				break;
370 370
 			case 'mini_cart_content':
371 371
 					$old_file_to_take_care_url = 'wpshop_mini_cart.tpl.php';
372
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
372
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
373 373
 						$old_file_to_take_care = true;
374 374
 					endif;
375 375
 				break;
376 376
 			case 'product_is_new_sticker':
377 377
 					$old_file_to_take_care_url = 'product-is-new.tpl.php';
378
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
378
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
379 379
 						$old_file_to_take_care = true;
380 380
 					endif;
381 381
 				break;
382 382
 			case 'product_is_featured_sticker':
383 383
 					$old_file_to_take_care_url = 'product-is-featured.tpl.php';
384
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
384
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
385 385
 						$old_file_to_take_care = true;
386 386
 					endif;
387 387
 				break;
388 388
 			case 'product_attribute_container':
389 389
 					$old_file_to_take_care_url = 'product-attribute-front-display-main-container.tpl.php';
390
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
390
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
391 391
 						$old_file_to_take_care = true;
392 392
 					endif;
393 393
 				break;
394 394
 			case 'product_attribute_tabs':
395 395
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs.tpl.php';
396
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
396
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
397 397
 						$old_file_to_take_care = true;
398 398
 					endif;
399 399
 				break;
400 400
 			case 'product_attribute_tabs_detail':
401 401
 					$old_file_to_take_care_url = 'product-attribute-front-display-tabs-content.tpl.php';
402
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
402
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
403 403
 						$old_file_to_take_care = true;
404 404
 					endif;
405 405
 				break;
406 406
 			case 'product_attachment_picture_galery':
407 407
 					$old_file_to_take_care_url = 'product_picture_galery.tpl.php';
408
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
408
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
409 409
 						$old_file_to_take_care = true;
410 410
 					endif;
411 411
 				break;
412 412
 			case 'product_attachment_galery':
413 413
 					$old_file_to_take_care_url = 'product_document_library.tpl.php';
414
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
414
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
415 415
 						$old_file_to_take_care = true;
416 416
 					endif;
417 417
 				break;
418 418
 			case 'product_attachment_item_picture':
419 419
 					$old_file_to_take_care_url = 'product_attachment_picture_line.tpl.php';
420
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
420
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
421 421
 						$old_file_to_take_care = true;
422 422
 					endif;
423 423
 				break;
424 424
 			case 'product_attachment_item_document':
425 425
 					$old_file_to_take_care_url = 'product_attachment_document_line.tpl.php';
426
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
426
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
427 427
 						$old_file_to_take_care = true;
428 428
 					endif;
429 429
 				break;
430 430
 			case 'product_added_to_cart_message':
431 431
 					$old_file_to_take_care_url = 'product_added_to_cart_message.tpl.php';
432
-					if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) :
432
+					if (is_file($custom_template_part . $old_file_to_take_care_url)) :
433 433
 						$old_file_to_take_care = true;
434 434
 					endif;
435 435
 				break;
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public static function display_template_element($template_part, $template_part_component, $extras_args = array(), $default_template_dir = 'wpshop') {
461 461
 		/**	Set the template element to return by default before checking if custom exists in order to be sure to return something	*/
462
-		$default_template_element = wpshop_display::check_template_to_display( 'default', $template_part, $extras_args, $default_template_dir );
462
+		$default_template_element = wpshop_display::check_template_to_display('default', $template_part, $extras_args, $default_template_dir);
463 463
 
464 464
 		/**	Check in custom template if there is not a custom element to display for current 	*/
465
-		$custom_template_element = wpshop_display::check_template_to_display( 'custom', $template_part, $extras_args, $default_template_dir );
465
+		$custom_template_element = wpshop_display::check_template_to_display('custom', $template_part, $extras_args, $default_template_dir);
466 466
 		$tpl_element_to_return = !empty($custom_template_element) ? $custom_template_element : $default_template_element;
467 467
 
468
-		$template_part_component = apply_filters( 'wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir );
468
+		$template_part_component = apply_filters('wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir);
469 469
 
470 470
 		return self::feed_template($tpl_element_to_return, $template_part_component);
471 471
 	}
@@ -477,44 +477,44 @@  discard block
 block discarded – undo
477 477
 		/*	Load template component	*/
478 478
 		/*	Get default admin template	*/
479 479
 		require_once(WPSHOP_TEMPLATES_DIR . 'admin/main_elements.tpl.php');
480
-		$wpshop_template['admin']['default'] = ($tpl_element);unset($tpl_element);
480
+		$wpshop_template['admin']['default'] = ($tpl_element); unset($tpl_element);
481 481
 		/*	Get custom admin template	*/
482
-		if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) {
482
+		if (is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php')) {
483 483
 			require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php');
484 484
 			if (!empty($tpl_element))
485
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
485
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
486 486
 		}
487
-		if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) {
487
+		if (is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php')) {
488 488
 			require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php');
489 489
 			if (!empty($tpl_element))
490
-				$wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element);
490
+				$wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element);
491 491
 		}
492 492
 		/*	Get default frontend template	*/
493 493
 		require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php');
494
-		$wpshop_template['wpshop']['default'] = ($tpl_element);unset($tpl_element);
494
+		$wpshop_template['wpshop']['default'] = ($tpl_element); unset($tpl_element);
495 495
 		/*	Get custom frontend template	*/
496
-		if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) {
496
+		if (is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php')) {
497 497
 			require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php');
498 498
 			if (!empty($tpl_element))
499
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
499
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
500 500
 		}
501
-		if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) {
501
+		if (is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php')) {
502 502
 			require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php');
503 503
 			if (!empty($tpl_element))
504
-				$wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element);
504
+				$wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element);
505 505
 		}
506
-		foreach ( $wpshop_template as $site_side => $types ) {
507
-			foreach ( $types as $type => $tpl_component ) {
508
-				foreach ( $tpl_component as $tpl_key => $tpl_content ) {
506
+		foreach ($wpshop_template as $site_side => $types) {
507
+			foreach ($types as $type => $tpl_component) {
508
+				foreach ($tpl_component as $tpl_key => $tpl_content) {
509 509
 					$wpshop_template[$site_side][$type][$tpl_key] = str_replace("
510 510
 ", '', $tpl_content);
511 511
 				}
512 512
 			}
513 513
 		}
514 514
 
515
-		$wpshop_template = apply_filters( 'wpshop_custom_template', $wpshop_template);
515
+		$wpshop_template = apply_filters('wpshop_custom_template', $wpshop_template);
516 516
 
517
-		DEFINE( 'WPSHOP_TEMPLATE', serialize($wpshop_template) );
517
+		DEFINE('WPSHOP_TEMPLATE', serialize($wpshop_template));
518 518
 	}
519 519
 
520 520
 	/**
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return array The new array with all elment, internal and module templates
527 527
 	 */
528
-	public static function add_modules_template_to_internal( $tpl_element, $templates ) {
529
-		if ( !empty($tpl_element) ) {
530
-			foreach ( $tpl_element as $template_part => $template_part_content) {
531
-				if ( !empty($template_part_content) && is_array($template_part_content) ) {
532
-					foreach ( $template_part_content as $template_type => $template_type_content) {
533
-						foreach ( $template_type_content as $template_key => $template) {
528
+	public static function add_modules_template_to_internal($tpl_element, $templates) {
529
+		if (!empty($tpl_element)) {
530
+			foreach ($tpl_element as $template_part => $template_part_content) {
531
+				if (!empty($template_part_content) && is_array($template_part_content)) {
532
+					foreach ($template_part_content as $template_type => $template_type_content) {
533
+						foreach ($template_type_content as $template_key => $template) {
534 534
 							$templates[$template_part][$template_type][$template_key] = $template;
535 535
 						}
536 536
 					}
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
 	 *
551 551
 	 * @return string The good template to take in care, regarding on the given parameters
552 552
 	 */
553
-	public static function check_template_to_display( $part, $template_part, $extras_args, $default_template_dir  ) {
553
+	public static function check_template_to_display($part, $template_part, $extras_args, $default_template_dir) {
554 554
 		$tpl_element_to_return = '';
555 555
 
556 556
 		/**	Get the defined template	*/
557 557
 		$template = defined("WPSHOP_TEMPLATE") ? unserialize(WPSHOP_TEMPLATE) : array();
558 558
 
559
-		if ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty( $template[$default_template_dir][$part][$extras_args['page']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
559
+		if (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty($template[$default_template_dir][$part][$extras_args['page']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part])) {
560 560
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part];
561 561
 		}
562
-		elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) {
562
+		elseif (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part])) {
563 563
 			$tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part];
564 564
 		}
565 565
 		/**	Check if the file have been duplicated into theme directory for customization	*/
566
-		elseif ( !empty( $template[$default_template_dir][$part] ) && !empty( $template[$default_template_dir][$part][$template_part] ) ) {
566
+		elseif (!empty($template[$default_template_dir][$part]) && !empty($template[$default_template_dir][$part][$template_part])) {
567 567
 			$tpl_element_to_return = $template[$default_template_dir][$part][$template_part];
568 568
 		}
569 569
 
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 		$feed['CURRENCY'] = wpshop_tools::wpshop_get_currency();
584 584
 		$feed['CURRENCY_CHOOSEN'] = wpshop_tools::wpshop_get_currency();
585 585
 		$feed['CURRENCY_SELECTOR'] = wpshop_attributes_unit::wpshop_shop_currency_list_field();
586
-		$feed['CART_LINK'] = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_cart_page_id') ) );
586
+		$feed['CART_LINK'] = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')));
587 587
 
588 588
 		$available_key = array();
589 589
 		foreach ($feed as $element => $value) {
590
-			$available_key[] = '{WPSHOP_'.$element.'}';
591
-			if ( !is_array($value) ) {
592
-				$template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill);
590
+			$available_key[] = '{WPSHOP_' . $element . '}';
591
+			if (!is_array($value)) {
592
+				$template_to_fill = str_replace('{WPSHOP_' . $element . '}', $value, $template_to_fill);
593 593
 			}
594 594
 		}
595 595
 		if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill;
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
 	 *
603 603
 	 * @param boolean $force_replacement Define if we overwrite in all case or just if it not exist
604 604
 	 */
605
-	public static function check_template_file( $force_replacement = false ) {
605
+	public static function check_template_file($force_replacement = false) {
606 606
 		$wpshop_directory = get_stylesheet_directory() . '/wpshop';
607 607
 
608 608
 		/*	Add different file template	*/
609
-		if(!is_dir($wpshop_directory)){
609
+		if (!is_dir($wpshop_directory)) {
610 610
 			@mkdir($wpshop_directory, 0755, true);
611 611
 		}
612 612
 		/* On s'assure que le dossier principal est bien en 0755	*/
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		$upload_dir = wp_upload_dir();
615 615
 
616 616
 		/*	Add the category template	*/
617
-		if(!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)){
617
+		if (!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)) {
618 618
 			@copy(WPSHOP_TEMPLATES_DIR . 'taxonomy-wpshop_product_category.php', get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php');
619 619
 		}
620 620
 	}
@@ -632,31 +632,31 @@  discard block
 block discarded – undo
632 632
 		/*	Check if user is on taxonomy edition page	*/
633 633
 		if ($pagenow == 'edit-tags.php') {
634 634
 
635
-			if(!user_can_richedit()) { return; }
635
+			if (!user_can_richedit()) { return; }
636 636
 
637 637
 			$taxonomies = get_taxonomies();
638 638
 
639 639
 			foreach ($taxonomies as $tax) {
640
-				if ( in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES)) ) {
641
-					add_action($tax . '_edit_form_fields', array('wpshop_display','wpshop_add_form'));
642
-					add_action($tax . '_add_form_fields', array('wpshop_display','wpshop_add_form'));
640
+				if (in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES))) {
641
+					add_action($tax . '_edit_form_fields', array('wpshop_display', 'wpshop_add_form'));
642
+					add_action($tax . '_add_form_fields', array('wpshop_display', 'wpshop_add_form'));
643 643
 				}
644 644
 			}
645
-			$action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
646
-			$taxonomy = !empty( $_REQUEST['taxonomy'] ) ? sanitize_text_field( $_REQUEST['taxonomy'] ) : '';
645
+			$action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
646
+			$taxonomy = !empty($_REQUEST['taxonomy']) ? sanitize_text_field($_REQUEST['taxonomy']) : '';
647 647
 
648 648
 			if ($pagenow == 'edit-tags.php' && isset($action) && $action == 'edit' && empty($taxonomy)) {
649
-				add_action('edit_term',array('wpshop_display','wpshop_rt_taxonomy_save'));
649
+				add_action('edit_term', array('wpshop_display', 'wpshop_rt_taxonomy_save'));
650 650
 			}
651 651
 
652
-			foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
653
-				remove_filter( $filter, 'wp_filter_kses' );
652
+			foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) {
653
+				remove_filter($filter, 'wp_filter_kses');
654 654
 			}
655 655
 
656 656
 		}
657 657
 
658 658
 		/*	Enable shortcodes in category, taxonomy, tag descriptions */
659
-		if(function_exists('term_description')) {
659
+		if (function_exists('term_description')) {
660 660
 			add_filter('term_description', 'do_shortcode');
661 661
 		}
662 662
 		else {
@@ -672,8 +672,8 @@  discard block
 block discarded – undo
672 672
 
673 673
 		$a = array('description');
674 674
 		foreach ($a as $v) {
675
-			$term = (array) $_POST[$v];
676
-			wp_update_term($tag_ID,$v,$term);
675
+			$term = (array)$_POST[$v];
676
+			wp_update_term($tag_ID, $v, $term);
677 677
 		}
678 678
 	}
679 679
 
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 	public static function wpshop_add_form($object = '') {
686 686
 		global $pagenow;
687 687
 
688
-		$content = is_object($object) && isset($object->description) ? ( html_entity_decode( $object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ) : '';
688
+		$content = is_object($object) && isset($object->description) ? (html_entity_decode($object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8')) : '';
689 689
 
690
-		if( in_array($pagenow, array('edit-tags.php')) ) {
690
+		if (in_array($pagenow, array('edit-tags.php'))) {
691 691
 			$editor_id = 'tag_description';
692 692
 			$editor_selector = 'description';
693 693
 		}
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
 
718 718
 	public static function wps_hide_admin_bar_for_customers() {
719 719
 		$wpshop_hide_admin_bar_option = get_option('wpshop_display_option');
720
-		if ( !empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && ! current_user_can( 'manage_options' ) ) {
721
-			show_admin_bar( false );
720
+		if (!empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && !current_user_can('manage_options')) {
721
+			show_admin_bar(false);
722 722
 		}
723 723
 	}
724 724
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 * @param string $content The content of a post
733 733
 	 * @return Ambigous <mixed, string>|unknown
734 734
 	 */
735
-	public static function products_page( $content = '' ) {
735
+	public static function products_page($content = '') {
736 736
 		global $wp_query;
737 737
 
738 738
 		if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) {
@@ -751,15 +751,15 @@  discard block
 block discarded – undo
751 751
 	 *
752 752
 	 * @return string The formated value
753 753
 	 */
754
-	public static function format_field_output( $output_type, $value ) {
754
+	public static function format_field_output($output_type, $value) {
755 755
 		$formated_value = $value;
756 756
 
757
-		if ( !empty($value) ) {
758
-			switch ( $output_type ) {
757
+		if (!empty($value)) {
758
+			switch ($output_type) {
759 759
 				case 'wpshop_product_price':
760
-					$formated_value = (is_numeric($value) ) ? number_format($value, 2, ',', '') : $value;
760
+					$formated_value = (is_numeric($value)) ? number_format($value, 2, ',', '') : $value;
761 761
 					$formated_value_content = explode(',', $formated_value);
762
-					if ( !empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0 ) {
762
+					if (!empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0) {
763 763
 						$formated_value = $formated_value_content[0];
764 764
 					}
765 765
 				break;
Please login to merge, or discard this patch.