Completed
Pull Request — master (#2)
by Jimmy
1003:35 queued 970:52
created
modules/wps_customer_quick_add/controller/wps_customer_quick_add.ctr.php 2 patches
Spacing   +46 added lines, -46 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
  * Fichier du controlleur principal du module de création de client rapide / Controller file for quick customer creation
4 4
  *
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public function __construct() {
21 21
 		/**	Affiche un formulaire permettant de créer un client / Display a form allowing to add a new customer	*/
22
-		add_action( 'wp_ajax_wps-customer-quick-creation', array( $this, 'customer_creation' ) );
23
-		add_action( 'wp_ajax_wps-customer-quick-add', array( $this, 'create_customer' ) );
22
+		add_action('wp_ajax_wps-customer-quick-creation', array($this, 'customer_creation'));
23
+		add_action('wp_ajax_wps-customer-quick-add', array($this, 'create_customer'));
24 24
 	}
25 25
 
26 26
 
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 	 * AJAX - Charge le fomulaire d'ajout rapide d'un client / Load the form for new customer quick add
29 29
 	 */
30 30
 	function customer_creation() {
31
-		$_wpnonce = sanitize_key( $_REQUEST['wps-nonce'] );
32
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) )
31
+		$_wpnonce = sanitize_key($_REQUEST['wps-nonce']);
32
+		if (!wp_verify_nonce($_wpnonce, 'wps-customer-quick-nonce'))
33 33
 			wp_die();
34 34
 		global $wpdb;
35 35
 
36
-		$customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
37
-		$query = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id() );
38
-		$cid = $wpdb->get_var( $query );
36
+		$customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
37
+		$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, get_current_user_id());
38
+		$cid = $wpdb->get_var($query);
39 39
 
40
-		$customer_attribute_set = !empty( $_GET ) && !empty( $_GET[ 'customer_set_id' ] ) ? (int)$_GET[ 'customer_set_id' ] : null;
40
+		$customer_attribute_set = !empty($_GET) && !empty($_GET['customer_set_id']) ? (int)$_GET['customer_set_id'] : null;
41 41
 
42
-		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails( $customer_attribute_set, "'valid'");
42
+		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails($customer_attribute_set, "'valid'");
43 43
 
44
-		require_once( wpshop_tools::get_template_part( WPSCLTQUICK_DIR, WPSCLTQUICK_TEMPLATES_MAIN_DIR, "backend", "customer", "creation" ) );
44
+		require_once(wpshop_tools::get_template_part(WPSCLTQUICK_DIR, WPSCLTQUICK_TEMPLATES_MAIN_DIR, "backend", "customer", "creation"));
45 45
 		wp_die( );
46 46
 	}
47 47
 
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 	 * AJAX - Création d'un nouveau client / Create a new customer
51 51
 	 */
52 52
 	function create_customer() {
53
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
53
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
54 54
 
55
-		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) )
55
+		if (!wp_verify_nonce($_wpnonce, 'create_customer'))
56 56
 			wp_die();
57 57
 
58 58
 
59 59
 		global $wpdb;
60 60
 		$response = array(
61 61
 			'status' => false,
62
-			'output' => __( 'An error occured while saving customer', 'wpshop' ),
62
+			'output' => __('An error occured while saving customer', 'wpshop'),
63 63
 			'customer_id' => -1,
64 64
 		);
65 65
 
66 66
 		/**	Check if a attribute set id have been sended in order to check if therer are some check to do on sended input	*/
67
-		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails( (int)$_POST[ 'wps-customer-account-set-id' ], "'valid'");
68
-		$attribute = !empty( $_POST['attribute'] ) ? (array)$_POST['attribute'] : array();
67
+		$customer_attributes = wpshop_attributes_set::getAttributeSetDetails((int)$_POST['wps-customer-account-set-id'], "'valid'");
68
+		$attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array();
69 69
 		/**	Read sended values for checking	*/
70 70
 		$email_founded = false;
71 71
 		$email_field = $last_name_field = $first_name_field = '';
72 72
 
73
-		foreach ( $attribute as $attribute_type => $attributes ) {
74
-			foreach ( $attributes as $attribute_code => $attribute_value ) {
75
-				$query = $wpdb->prepare( "SELECT frontend_verification FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code );
76
-				$current_attribute = $wpdb->get_var( $query );
73
+		foreach ($attribute as $attribute_type => $attributes) {
74
+			foreach ($attributes as $attribute_code => $attribute_value) {
75
+				$query = $wpdb->prepare("SELECT frontend_verification FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code);
76
+				$current_attribute = $wpdb->get_var($query);
77 77
 
78
-				if ( 'email' == $current_attribute ) {
78
+				if ('email' == $current_attribute) {
79 79
 					$email_founded = true;
80 80
 					$email_field = $attribute_code;
81 81
 					$email_field_type = $attribute_type;
82 82
 				}
83
-				else if ( strpos( $attribute_code, 'last_name')) {
83
+				else if (strpos($attribute_code, 'last_name')) {
84 84
 					$last_name_field = $attribute_code;
85 85
 					$last_name_field_type = $attribute_type;
86 86
 				}
87
-				else if ( strpos( $attribute_code, 'first_name')) {
87
+				else if (strpos($attribute_code, 'first_name')) {
88 88
 					$first_name_field = $attribute_code;
89 89
 					$first_name_field_type = $attribute_type;
90 90
 				}
@@ -92,57 +92,57 @@  discard block
 block discarded – undo
92 92
 		}
93 93
 
94 94
 		/**	Define customer email field value	*/
95
-		$customer_email = sanitize_email( $attribute[ $email_field_type ][ $email_field ] );
96
-		$customer_last_name = !empty( $attribute ) && !empty( $attribute[ $last_name_field_type ] ) && !empty( $attribute[ $last_name_field_type ][ $last_name_field ] ) ? sanitize_text_field( $attribute[ $last_name_field_type ][ $last_name_field ] ) : '';
97
-		$customer_first_name = !empty( $attribute ) && !empty( $attribute[ $first_name_field_type ] ) && !empty( $attribute[ $first_name_field_type ][ $first_name_field ] ) ? sanitize_text_field( $attribute[ $first_name_field_type ][ $first_name_field ] ) : '';
95
+		$customer_email = sanitize_email($attribute[$email_field_type][$email_field]);
96
+		$customer_last_name = !empty($attribute) && !empty($attribute[$last_name_field_type]) && !empty($attribute[$last_name_field_type][$last_name_field]) ? sanitize_text_field($attribute[$last_name_field_type][$last_name_field]) : '';
97
+		$customer_first_name = !empty($attribute) && !empty($attribute[$first_name_field_type]) && !empty($attribute[$first_name_field_type][$first_name_field]) ? sanitize_text_field($attribute[$first_name_field_type][$first_name_field]) : '';
98 98
 
99
-		if ( $email_founded && is_email( $customer_email ) ) {
99
+		if ($email_founded && is_email($customer_email)) {
100 100
 			/**	Check if current e-mail address does not already exists	*/
101
-			$user_id = username_exists( $customer_email );
102
-			if ( empty( $user_id ) ) {
101
+			$user_id = username_exists($customer_email);
102
+			if (empty($user_id)) {
103 103
 
104 104
 				/**	Create the user with a random password	*/
105
-				$random_password = wp_generate_password( 12, false );
106
-				$user_id = wp_create_user( $customer_email, $random_password, $customer_email );
105
+				$random_password = wp_generate_password(12, false);
106
+				$user_id = wp_create_user($customer_email, $random_password, $customer_email);
107 107
 
108
-				if ( !is_wp_error( $user_id ) ) {
109
-					update_user_meta( $user_id, 'last_name', $customer_last_name );
110
-					update_user_meta( $user_id, 'first_name', $customer_first_name );
108
+				if (!is_wp_error($user_id)) {
109
+					update_user_meta($user_id, 'last_name', $customer_last_name);
110
+					update_user_meta($user_id, 'first_name', $customer_first_name);
111 111
 
112 112
 					/**	Build a response for customer first letter - Specific action (POS)	*/
113
-					if ( !empty($customer_last_name) ) {
113
+					if (!empty($customer_last_name)) {
114 114
 						$field_for_letter = $customer_last_name;
115 115
 					}
116
-					elseif( !empty($customer_first_name)  ) {
116
+					elseif (!empty($customer_first_name)) {
117 117
 						$field_for_letter = $customer_first_name;
118 118
 					}
119 119
 					else {
120 120
 						$field_for_letter = $customer_email;
121 121
 					}
122
-					$response[ 'letter' ] = substr( $field_for_letter, 0, 1);
122
+					$response['letter'] = substr($field_for_letter, 0, 1);
123 123
 
124 124
 					/**	Build response	*/
125
-					$response[ 'status' ] = true;
126
-					$response[ 'output' ] = __('Customer created succesfully', 'wpshop');
125
+					$response['status'] = true;
126
+					$response['output'] = __('Customer created succesfully', 'wpshop');
127 127
 
128 128
 					/** Create customer address from sended data **/
129 129
 					// $_REQUEST['user']['customer_id'] = (int)$user_id;
130 130
 					$attribute_to_save = $attribute;
131
-					$wps_customer_account_set_id = !empty( $_POST[ 'wps-customer-account-set-id' ] ) ? (int) $_POST[ 'wps-customer-account-set-id' ] : 0;
132
-					$attribute[ $wps_customer_account_set_id ] = $attribute_to_save;
133
-					wps_address::save_address_infos( $wps_customer_account_set_id );
131
+					$wps_customer_account_set_id = !empty($_POST['wps-customer-account-set-id']) ? (int)$_POST['wps-customer-account-set-id'] : 0;
132
+					$attribute[$wps_customer_account_set_id] = $attribute_to_save;
133
+					wps_address::save_address_infos($wps_customer_account_set_id);
134 134
 				}
135 135
 			}
136 136
 			else {
137
-				$response[ 'output' ] = __('An account is already created with this e-mail address', 'wpshop');
137
+				$response['output'] = __('An account is already created with this e-mail address', 'wpshop');
138 138
 			}
139
-			$response[ 'customer_id' ] = $user_id;
139
+			$response['customer_id'] = $user_id;
140 140
 		}
141 141
 		else {
142
-			$response[ 'output' ] = __('An email address is required', 'wpshop');
142
+			$response['output'] = __('An email address is required', 'wpshop');
143 143
 		}
144 144
 
145
-		wp_die( json_encode( $response ) );
145
+		wp_die(json_encode($response));
146 146
 	}
147 147
 
148 148
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier du controlleur principal du module de création de client rapide / Controller file for quick customer creation
4 6
  *
@@ -29,8 +31,9 @@  discard block
 block discarded – undo
29 31
 	 */
30 32
 	function customer_creation() {
31 33
 		$_wpnonce = sanitize_key( $_REQUEST['wps-nonce'] );
32
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) )
33
-			wp_die();
34
+		if ( !wp_verify_nonce( $_wpnonce, 'wps-customer-quick-nonce' ) ) {
35
+					wp_die();
36
+		}
34 37
 		global $wpdb;
35 38
 
36 39
 		$customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
@@ -52,8 +55,9 @@  discard block
 block discarded – undo
52 55
 	function create_customer() {
53 56
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
54 57
 
55
-		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) )
56
-			wp_die();
58
+		if ( !wp_verify_nonce( $_wpnonce, 'create_customer' ) ) {
59
+					wp_die();
60
+		}
57 61
 
58 62
 
59 63
 		global $wpdb;
@@ -79,12 +83,10 @@  discard block
 block discarded – undo
79 83
 					$email_founded = true;
80 84
 					$email_field = $attribute_code;
81 85
 					$email_field_type = $attribute_type;
82
-				}
83
-				else if ( strpos( $attribute_code, 'last_name')) {
86
+				} else if ( strpos( $attribute_code, 'last_name')) {
84 87
 					$last_name_field = $attribute_code;
85 88
 					$last_name_field_type = $attribute_type;
86
-				}
87
-				else if ( strpos( $attribute_code, 'first_name')) {
89
+				} else if ( strpos( $attribute_code, 'first_name')) {
88 90
 					$first_name_field = $attribute_code;
89 91
 					$first_name_field_type = $attribute_type;
90 92
 				}
@@ -112,11 +114,9 @@  discard block
 block discarded – undo
112 114
 					/**	Build a response for customer first letter - Specific action (POS)	*/
113 115
 					if ( !empty($customer_last_name) ) {
114 116
 						$field_for_letter = $customer_last_name;
115
-					}
116
-					elseif( !empty($customer_first_name)  ) {
117
+					} elseif( !empty($customer_first_name)  ) {
117 118
 						$field_for_letter = $customer_first_name;
118
-					}
119
-					else {
119
+					} else {
120 120
 						$field_for_letter = $customer_email;
121 121
 					}
122 122
 					$response[ 'letter' ] = substr( $field_for_letter, 0, 1);
@@ -132,13 +132,11 @@  discard block
 block discarded – undo
132 132
 					$attribute[ $wps_customer_account_set_id ] = $attribute_to_save;
133 133
 					wps_address::save_address_infos( $wps_customer_account_set_id );
134 134
 				}
135
-			}
136
-			else {
135
+			} else {
137 136
 				$response[ 'output' ] = __('An account is already created with this e-mail address', 'wpshop');
138 137
 			}
139 138
 			$response[ 'customer_id' ] = $user_id;
140
-		}
141
-		else {
139
+		} else {
142 140
 			$response[ 'output' ] = __('An email address is required', 'wpshop');
143 141
 		}
144 142
 
Please login to merge, or discard this patch.
includes/modules/wps_address/templates/frontend/address-first.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1
-<div class="wps-<?php echo $address_type; ?>-address" <?php if ( !empty( $first_address_checking ) && !$is_from_admin && $type == 'billing' ) { echo 'style="display: none;"'; } ?> data-nonce="<?php echo wp_create_nonce( 'wps_reload_address_interface' ); ?>" id="wps-address-container-<?php echo $address_type_id; ?>">
1
+<div class="wps-<?php echo $address_type; ?>-address" <?php if (!empty($first_address_checking) && !$is_from_admin && $type == 'billing') { echo 'style="display: none;"'; } ?> data-nonce="<?php echo wp_create_nonce('wps_reload_address_interface'); ?>" id="wps-address-container-<?php echo $address_type_id; ?>">
2 2
 	<div id="wps_address_error_container" ></div>
3
-	<form id="wps_address_form_save_first_address" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" method="post">
3
+	<form id="wps_address_form_save_first_address" action="<?php echo admin_url('admin-ajax.php'); ?>" method="post">
4 4
 <?php
5
-		echo self::display_form_fields( $address_type_id, '', '', '', array(), array(), array(), get_current_user_id() );
5
+		echo self::display_form_fields($address_type_id, '', '', '', array(), array(), array(), get_current_user_id());
6 6
 
7 7
 	/** Check if a billing address is already save **/
8
-	if ( $address_type_id != $billing_option['choice'] ) :
8
+	if ($address_type_id != $billing_option['choice']) :
9 9
 ?>
10 10
 		<label class="wps-form" >
11 11
 			<input name="wps-shipping-to-billing" id="wps-shipping_to_billing" checked="checked" type="checkbox" />
12
-			<?php _e( 'Use the same address for billing', 'wpshop' ); ?>
12
+			<?php _e('Use the same address for billing', 'wpshop'); ?>
13 13
 		</label>
14 14
 <?php endif; ?>
15 15
 
Please login to merge, or discard this patch.
modules/wps_product_quick_add/controller/wps_product_quick_add.ctr.php 2 patches
Spacing   +40 added lines, -40 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
  * Fichier du controlleur principal du module de création de produit rapide / Controller file for quick product creation
4 4
  *
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	public function __construct() {
22 22
 		/**	Affiche un formulaire permettant de créer un produit / Display a form allowing to add a new product	*/
23
-		add_action( 'wp_ajax_wps-product-quick-creation', array( $this, 'product_creation' ) );
24
-		add_action( 'wp_ajax_wps-product-quick-add-reload-attribute-list', array( $this, 'attribute_list_reload' ) );
25
-		add_action( 'wp_ajax_wps-product-quick-add', array( $this, 'create_product' ) );
23
+		add_action('wp_ajax_wps-product-quick-creation', array($this, 'product_creation'));
24
+		add_action('wp_ajax_wps-product-quick-add-reload-attribute-list', array($this, 'attribute_list_reload'));
25
+		add_action('wp_ajax_wps-product-quick-add', array($this, 'create_product'));
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param integer $chosen_set Le groupe d'attribut dont on veut afficher les champs / Attribute set we want display input for
32 32
 	 */
33
-	function display_attribute( $chosen_set = 0 ) {
34
-		require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list" ) );
33
+	function display_attribute($chosen_set = 0) {
34
+		require_once(wpshop_tools::get_template_part(WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list"));
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * AJAX - Charge le fomulaire d'ajout rapide d'un produit / Load the form for new product quick add
39 39
 	 */
40 40
 	function product_creation() {
41
-		$_wpnonce = !empty( $_POST['wps-nonce'] ) ? sanitize_text_field( $_POST['wps-nonce'] ) : '';
42
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) )
41
+		$_wpnonce = !empty($_POST['wps-nonce']) ? sanitize_text_field($_POST['wps-nonce']) : '';
42
+		if (!wp_verify_nonce($_wpnonce, 'wps-product-quick-nonce'))
43 43
 			wp_die();
44 44
 
45
-		require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) );
45
+		require_once(wpshop_tools::get_template_part(WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation"));
46 46
 		wp_die( );
47 47
 	}
48 48
 
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 	 * AJAX - Recharge la liste des attributs du groupe sélectionné par l'administratuer pour la création du nouveau produit / Reload attribute list for the selected attribute set, choosen by administrator for new product creation
51 51
 	 */
52 52
 	function attribute_list_reload() {
53
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
53
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
54 54
 
55
-		if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) )
55
+		if (!wp_verify_nonce($_wpnonce, 'attribute_list_reload'))
56 56
 			wp_die();
57 57
 
58
-		$attribute_set = !empty( $_POST['attribute_set'] ) ? (int) $_POST['attribute_set'] : 0;
59
-		$this->display_attribute( $attribute_set );
58
+		$attribute_set = !empty($_POST['attribute_set']) ? (int)$_POST['attribute_set'] : 0;
59
+		$this->display_attribute($attribute_set);
60 60
 		wp_die( );
61 61
 	}
62 62
 
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * AJAX - Création d'un nouveau produit / Create a new product
65 65
 	 */
66 66
 	function create_product() {
67
-		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
67
+		$_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : '';
68 68
 
69
-		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) )
69
+		if (!wp_verify_nonce($_wpnonce, 'create_product'))
70 70
 			wp_die();
71 71
 
72 72
 		global $wpdb;
@@ -76,51 +76,51 @@  discard block
 block discarded – undo
76 76
 			'pid' => -1,
77 77
 		);
78 78
 
79
-		$post_title = ( !empty($_POST['post_title']) ) ? sanitize_text_field( $_POST['post_title'] ) : -1;
80
-		$post_content = ( !empty($_POST['post_content']) ) ? sanitize_text_field( $_POST['post_content'] ) : '';
81
-		$attributes = ( !empty($_POST['attribute']) ) ? (array)$_POST['attribute'] : array();
82
-		$id_attribute_set = ( !empty($_POST['wps-product-attribute-set']) ) ? (int) $_POST['wps-product-attribute-set'] : -1;
79
+		$post_title = (!empty($_POST['post_title'])) ? sanitize_text_field($_POST['post_title']) : -1;
80
+		$post_content = (!empty($_POST['post_content'])) ? sanitize_text_field($_POST['post_content']) : '';
81
+		$attributes = (!empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array();
82
+		$id_attribute_set = (!empty($_POST['wps-product-attribute-set'])) ? (int)$_POST['wps-product-attribute-set'] : -1;
83 83
 
84 84
 		$post_type = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
85
-		$attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity( wpshop_entities::get_entity_identifier_from_code( 'wpshop_product' ) );
86
-		foreach( $attribute_set_list as $attribute_set ) {
87
-			if( $id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product' ) {
85
+		$attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code('wpshop_product'));
86
+		foreach ($attribute_set_list as $attribute_set) {
87
+			if ($id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product') {
88 88
 				$post_type = 'free_product';
89 89
 			}
90 90
 		}
91 91
 
92
-		if( ( -1 != $post_title ) && ( -1 != $id_attribute_set ) ) {
93
-			$new_product_id = wp_insert_post( array(
92
+		if (( -1 != $post_title ) && ( -1 != $id_attribute_set )) {
93
+			$new_product_id = wp_insert_post(array(
94 94
 				'post_type' => $post_type,
95 95
 				'post_status' => 'publish',
96 96
 				'post_title' => $post_title,
97 97
 				'post_content' => $post_content,
98
-			) );
98
+			));
99 99
 
100
-			if( !is_wp_error( $new_product_id ) ) {
101
-				update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set );
102
-				$data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $new_product_id );
103
-				$data_to_save['wpshop_product_attribute'] = ( !empty($attributes) ) ? $attributes : array();
100
+			if (!is_wp_error($new_product_id)) {
101
+				update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set);
102
+				$data_to_save['post_ID'] = $data_to_save['product_id'] = intval($new_product_id);
103
+				$data_to_save['wpshop_product_attribute'] = (!empty($attributes)) ? $attributes : array();
104 104
 				$data_to_save['user_ID'] = get_current_user_id();
105 105
 				$data_to_save['action'] = 'editpost';
106
-				$response[ 'pid' ] = $new_product_id;
107
-				$response[ 'status' ] = false;
108
-				$response[ 'output' ] = __('Product created partially!', 'wpshop');
109
-				if( !empty( $new_product_id ) && !empty( $data_to_save['user_ID'] ) ) {
106
+				$response['pid'] = $new_product_id;
107
+				$response['status'] = false;
108
+				$response['output'] = __('Product created partially!', 'wpshop');
109
+				if (!empty($new_product_id) && !empty($data_to_save['user_ID'])) {
110 110
 					$product_class = new wpshop_products();
111
-					$product_class->save_product_custom_informations( $new_product_id, $data_to_save );
112
-					$response[ 'status' ] = true;
113
-					$response[ 'output' ] = __('Product created successfully.', 'wpshop');
111
+					$product_class->save_product_custom_informations($new_product_id, $data_to_save);
112
+					$response['status'] = true;
113
+					$response['output'] = __('Product created successfully.', 'wpshop');
114 114
 				}
115 115
 
116
-				$wps_quick_creation_hook = do_action( 'wps-new-product-quick-created', $new_product_id );
117
-				if ( !empty( $wps_quick_creation_hook ) ) {
118
-					$response[ '' ] = $wps_quick_creation_hook;
116
+				$wps_quick_creation_hook = do_action('wps-new-product-quick-created', $new_product_id);
117
+				if (!empty($wps_quick_creation_hook)) {
118
+					$response[''] = $wps_quick_creation_hook;
119 119
 				}
120 120
 			}
121 121
 		}
122 122
 
123
-		wp_die( json_encode( $response ) );
123
+		wp_die(json_encode($response));
124 124
 	}
125 125
 
126 126
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier du controlleur principal du module de création de produit rapide / Controller file for quick product creation
4 6
  *
@@ -39,8 +41,9 @@  discard block
 block discarded – undo
39 41
 	 */
40 42
 	function product_creation() {
41 43
 		$_wpnonce = !empty( $_POST['wps-nonce'] ) ? sanitize_text_field( $_POST['wps-nonce'] ) : '';
42
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) )
43
-			wp_die();
44
+		if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) ) {
45
+					wp_die();
46
+		}
44 47
 
45 48
 		require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) );
46 49
 		wp_die( );
@@ -52,8 +55,9 @@  discard block
 block discarded – undo
52 55
 	function attribute_list_reload() {
53 56
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
54 57
 
55
-		if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) )
56
-			wp_die();
58
+		if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) ) {
59
+					wp_die();
60
+		}
57 61
 
58 62
 		$attribute_set = !empty( $_POST['attribute_set'] ) ? (int) $_POST['attribute_set'] : 0;
59 63
 		$this->display_attribute( $attribute_set );
@@ -66,8 +70,9 @@  discard block
 block discarded – undo
66 70
 	function create_product() {
67 71
 		$_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : '';
68 72
 
69
-		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) )
70
-			wp_die();
73
+		if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) ) {
74
+					wp_die();
75
+		}
71 76
 
72 77
 		global $wpdb;
73 78
 		$response = array(
Please login to merge, or discard this patch.
templates/backend/quick_add_interface-product_list.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- if( !empty($products) ) : ?>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ if (!empty($products)) : ?>
3 3
 	<?php $tab_def = array(); ?>
4 4
 	<?php
5
-		foreach( $quick_add_form_attributes as $id_att => $att ) {
5
+		foreach ($quick_add_form_attributes as $id_att => $att) {
6 6
 			$tab_def[$id_att]['name'] = $att['frontend_label'];
7 7
 		}
8 8
 	?>
9 9
 
10
-	<form method="post" id="wps_mass_edit_product_form" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
10
+	<form method="post" id="wps_mass_edit_product_form" action="<?php echo admin_url('admin-ajax.php'); ?>">
11 11
 		<input type="hidden" name="action" value="wps_mass_edit_product_save_action" />
12
-    <?php wp_nonce_field( 'wps_save_product_quick_interface' ); ?>
12
+    <?php wp_nonce_field('wps_save_product_quick_interface'); ?>
13 13
 		<table class="wp-list-table widefat wps-product-mass-interface-table">
14 14
 			<thead>
15 15
 				<tr>
16 16
 					<th class="check-column manage-column column-cb check-column">
17 17
 						<input type="checkbox" class="wps-save-product-checkbox" name="wps_product_quick_save_checkbox_column" />
18 18
 					</th>
19
-					<th><?php _e( 'Picture', 'wpshop'); ?></th>
20
-					<th class="title"><?php _e( 'Title', 'wpshop'); ?></th>
21
-					<th class="description"><?php _e( 'Description', 'wpshop'); ?></th>
19
+					<th><?php _e('Picture', 'wpshop'); ?></th>
20
+					<th class="title"><?php _e('Title', 'wpshop'); ?></th>
21
+					<th class="description"><?php _e('Description', 'wpshop'); ?></th>
22 22
 					<?php /*<th width="80"><?php _e( 'Files', 'wpshop'); ?></th>*/ ?>
23
-					<?php if( !empty($tab_def) ) : ?>
24
-					<?php foreach( $tab_def as $col ) : ?>
23
+					<?php if (!empty($tab_def)) : ?>
24
+					<?php foreach ($tab_def as $col) : ?>
25 25
 						<th ><?php echo $col['name']; ?></th>
26 26
 					<?php endforeach; ?>
27 27
 					<?php endif; ?>
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 
32 32
 			<?php
33 33
 				$i = 1;
34
-				foreach( $products as $product ) :
35
-					$product_attribute_set_id = get_post_meta( $product['post_datas']->ID, '_wpshop_product_attribute_set_id', true );
34
+				foreach ($products as $product) :
35
+					$product_attribute_set_id = get_post_meta($product['post_datas']->ID, '_wpshop_product_attribute_set_id', true);
36 36
 					$class = ($i % 2) ? 'alternate' : '';
37 37
 			?>
38 38
 
39
-			<?php require( wpshop_tools::get_template_part( WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "product_line" ) ); ?>
39
+			<?php require(wpshop_tools::get_template_part(WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "product_line")); ?>
40 40
 
41 41
 			<?php
42 42
 				$i++;
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 					<th class="check-column manage-column column-cb check-column">
48 48
 						<input type="checkbox" class="wps-save-product-checkbox" name="wps_product_quick_save_checkbox_column" />
49 49
 					</th>
50
-					<th><?php _e( 'Picture', 'wpshop'); ?></th>
51
-					<th><?php _e( 'Title', 'wpshop'); ?></th>
52
-					<th><?php _e( 'Description', 'wpshop'); ?></th>
50
+					<th><?php _e('Picture', 'wpshop'); ?></th>
51
+					<th><?php _e('Title', 'wpshop'); ?></th>
52
+					<th><?php _e('Description', 'wpshop'); ?></th>
53 53
 					<?php /*<th width="80"><?php _e( 'Files', 'wpshop'); ?></th>*/ ?>
54
-					<?php if( !empty($tab_def) ) : ?>
55
-					<?php foreach( $tab_def as $col ) : ?>
54
+					<?php if (!empty($tab_def)) : ?>
55
+					<?php foreach ($tab_def as $col) : ?>
56 56
 						<th><?php echo $col['name']; ?></th>
57 57
 					<?php endforeach; ?>
58 58
 					<?php endif; ?>
@@ -64,5 +64,5 @@  discard block
 block discarded – undo
64 64
 		jQuery("select.chosen_select").chosen( WPSHOP_CHOSEN_ATTRS );
65 65
 	} );</script>
66 66
 <?php else: ?>
67
-	<div class="wps-alert-info"><?php _e( 'You don\'t have any product for the moment', 'wpshop' ); ?></div>
67
+	<div class="wps-alert-info"><?php _e('You don\'t have any product for the moment', 'wpshop'); ?></div>
68 68
 <?php endif; ?>
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
  if( !empty($products) ) : ?>
3 5
 	<?php $tab_def = array(); ?>
4 6
 	<?php
@@ -63,6 +65,9 @@  discard block
 block discarded – undo
63 65
 	<script type="text/javascript" >jQuery( document ).ready( function(){
64 66
 		jQuery("select.chosen_select").chosen( WPSHOP_CHOSEN_ATTRS );
65 67
 	} );</script>
66
-<?php else: ?>
67
-	<div class="wps-alert-info"><?php _e( 'You don\'t have any product for the moment', 'wpshop' ); ?></div>
68
+<?php else {
69
+	: ?>
70
+	<div class="wps-alert-info"><?php _e( 'You don\'t have any product for the moment', 'wpshop' );
71
+}
72
+?></div>
68 73
 <?php endif; ?>
Please login to merge, or discard this patch.
includes/modules/wps_cart/templates/frontend/cart/cart-total.php 2 patches
Spacing   +75 added lines, -75 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"><?php _e( 'Make this order again', 'wpshop'); ?></button>
13
+					<button id="<?php echo $oid; ?>" class="wps-bton-first-mini-rounded make_order_again"><?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,99 +31,99 @@  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' ) : ?>
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 46
 							<span class="wps-form-group">
47 47
 								<span class="wps-form">
48
-									<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" />
48
+									<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" />
49 49
 								</span>
50 50
 							</span>
51 51
 						<?php else : ?>
52
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
52
+							<strong><?php echo wpshop_tools::formate_number($shipping_cost_et); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
53 53
 						<?php endif; ?>
54 54
 					<?php endif; ?>
55 55
 				</span>
56 56
 			</p>
57 57
 		<?php endif; ?>
58 58
 
59
-		<?php if( $cart_option == 'full_cart' ) : ?>
59
+		<?php if ($cart_option == 'full_cart') : ?>
60 60
 			<p>
61
-				<?php _e( 'VAT on Shipping cost', 'wpshop'); ?>
61
+				<?php _e('VAT on Shipping cost', 'wpshop'); ?>
62 62
 				<span class="wps-alignRight">
63
-					<strong><?php echo wpshop_tools::formate_number( $shipping_cost_vat ); ?></strong> <?php echo $currency; ?>
63
+					<strong><?php echo wpshop_tools::formate_number($shipping_cost_vat); ?></strong> <?php echo $currency; ?>
64 64
 				</span>
65 65
 			</p>
66 66
 		<?php endif; ?>
67 67
 
68
-		<?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' || $price_piloting == 'TTC' ) : ?>
68
+		<?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati' || $price_piloting == 'TTC') : ?>
69 69
 			<p>
70
-				<?php _e( 'Shipping cost', 'wpshop'); ?> <?php echo ( ( !empty($shipping_price_from) && empty( $_SESSION['shipping_address'] ) ) ? '<br/><i>('.__( 'From', 'wpshop').')</i>' : '' ); ?>
70
+				<?php _e('Shipping cost', 'wpshop'); ?> <?php echo ((!empty($shipping_price_from) && empty($_SESSION['shipping_address'])) ? '<br/><i>(' . __('From', 'wpshop') . ')</i>' : ''); ?>
71 71
 				<span class="wps-alignRight">
72
-					<?php if( $cart_type != 'admin-panel' ) : ?>
73
-						<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?></strong> <?php echo $currency; ?>
72
+					<?php if ($cart_type != 'admin-panel') : ?>
73
+						<strong><?php echo wpshop_tools::formate_number($shipping_cost_ati); ?></strong> <?php echo $currency; ?>
74 74
 					<?php else : ?>
75
-						<?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' ) : ?>
75
+						<?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') : ?>
76 76
 							<span class="wps-form-group">
77 77
 								<span class="wps-form">
78
-									<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" />
78
+									<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" />
79 79
 								</span>
80 80
 							</span>
81 81
 						<?php else : ?>
82
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
82
+							<strong><?php echo wpshop_tools::formate_number($shipping_cost_ati); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
83 83
 						<?php endif; ?>
84 84
 					<?php endif; ?>
85 85
 				</span>
86 86
 			</p>
87 87
 		<?php endif; ?>
88 88
 
89
-		<?php if( $cart_option == 'full_cart' && !empty($cart_content['order_tva']) ) : ?>
90
-		<?php foreach( $cart_content['order_tva'] as $order_vat_rate => $order_vat_value ) :
91
-				if( $order_vat_rate != 'VAT_shipping_cost') :
89
+		<?php if ($cart_option == 'full_cart' && !empty($cart_content['order_tva'])) : ?>
90
+		<?php foreach ($cart_content['order_tva'] as $order_vat_rate => $order_vat_value) :
91
+				if ($order_vat_rate != 'VAT_shipping_cost') :
92 92
 					?>
93 93
 					<p>
94
-						<?php printf( __( 'VAT (%s %%)', 'wpshop'), $order_vat_rate); ?>
94
+						<?php printf(__('VAT (%s %%)', 'wpshop'), $order_vat_rate); ?>
95 95
 						<span class="wps-alignRight">
96
-							<strong><?php echo wpshop_tools::formate_number( $order_vat_value ); ?></strong> <?php echo $currency; ?>
96
+							<strong><?php echo wpshop_tools::formate_number($order_vat_value); ?></strong> <?php echo $currency; ?>
97 97
 						</span>
98 98
 					</p>
99 99
 					<?php
100 100
 				endif;
101 101
 		endforeach; ?>
102 102
 		<?php endif; ?>
103
-			<?php if( $cart_type == 'admin-panel' ) : ?>
103
+			<?php if ($cart_type == 'admin-panel') : ?>
104 104
 				<p>
105
-					<?php _e( 'Discount', 'wpshop'); ?>
105
+					<?php _e('Discount', 'wpshop'); ?>
106 106
 					<span class="wps-alignRight">
107
-						<?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' ) ) : ?>
108
-							<span class="wps-form-group"><span class="wps-form"><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'] : ''; ?>"/></span></span>
107
+						<?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')) : ?>
108
+							<span class="wps-form-group"><span class="wps-form"><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'] : ''; ?>"/></span></span>
109 109
 						<?php else : ?>
110
-							<?php if( !empty($cart_content['order_discount_value']) ) : ?>
111
-								<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>
110
+							<?php if (!empty($cart_content['order_discount_value'])) : ?>
111
+								<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>
112 112
 							<?php else : ?>
113 113
 								0 <?php echo wpshop_tools::wpshop_get_currency(); ?>
114 114
 							<?php endif; ?>
115 115
 						<?php endif; ?>
116 116
 					</span>
117 117
 				</p>
118
-				<?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' ) ) : ?>
118
+				<?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')) : ?>
119 119
 					<p>
120
-						<?php _e( 'Discount type', 'wpshop'); ?>
120
+						<?php _e('Discount type', 'wpshop'); ?>
121 121
 						<span class="wps-alignRight">
122 122
 							<span class="wps-form-group">
123 123
 								<span class="wps-form">
124 124
 									<select id="wps-orders-discount-type">
125
-										<option value="percent" <?php echo ( !empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent' ) ? 'selected="selected"' : ''; ?>>%</option>
126
-										<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>
125
+										<option value="percent" <?php echo (!empty($cart_content) && !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent') ? 'selected="selected"' : ''; ?>>%</option>
126
+										<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>
127 127
 									</select>
128 128
 								</span>
129 129
 							</span>
@@ -132,52 +132,52 @@  discard block
 block discarded – undo
132 132
 				<?php endif; ?>
133 133
 			<?php endif; ?>
134 134
 
135
-			<?php if ( !empty( $cart_content['coupon_id']) ) : ?>
136
-			<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>
137
-			<p><?php _e( 'Discount', 'wpshop'); ?> (<?php echo $coupon_title; ?>) <span class="wps-alignRight"><strong><?php echo $coupon_value; ?></strong><?php echo $currency; ?></span></p>
135
+			<?php if (!empty($cart_content['coupon_id'])) : ?>
136
+			<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>
137
+			<p><?php _e('Discount', 'wpshop'); ?> (<?php echo $coupon_title; ?>) <span class="wps-alignRight"><strong><?php echo $coupon_value; ?></strong><?php echo $currency; ?></span></p>
138 138
 			<?php endif; ?>
139 139
 
140
-			<?php if( !empty($_SESSION['cart']['order_partial_payment']) ) :
141
-				$wps_partial_payment_data = get_option( 'wpshop_payment_partial' );
142
-				if( !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) {
140
+			<?php if (!empty($_SESSION['cart']['order_partial_payment'])) :
141
+				$wps_partial_payment_data = get_option('wpshop_payment_partial');
142
+				if (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') {
143 143
 					$partial_payment_informations = $wps_partial_payment_data['for_quotation'];
144 144
 				} else {
145 145
 					$partial_payment_informations = $wps_partial_payment_data['for_all'];
146 146
 				}
147
-				$partial_payment_amount =  $_SESSION['cart']['order_partial_payment'];
147
+				$partial_payment_amount = $_SESSION['cart']['order_partial_payment'];
148 148
 			?>
149
-				<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>
149
+				<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>
150 150
 				<p class="wps-hightlight">
151
-				<?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 ) ) . ')'); ?>
152
-				<span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $partial_payment_amount ); ?></strong> <?php echo $currency; ?>
151
+				<?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)) . ')'); ?>
152
+				<span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($partial_payment_amount); ?></strong> <?php echo $currency; ?>
153 153
 				</span></p>
154
-			<?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' ] ) ) : ?>
155
-				<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>
154
+			<?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'])) : ?>
155
+				<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>
156 156
 				<?php $allready_received_amount = 0; ?>
157
-				<?php foreach ( $cart_content[ 'order_payment' ][ 'received' ] as $payment ) : ?>
158
-					<?php if ( 'payment_received' == $payment[ 'status' ] ) : ?>
159
-						<?php $allready_received_amount += $payment[ 'received_amount' ]; ?>
157
+				<?php foreach ($cart_content['order_payment']['received'] as $payment) : ?>
158
+					<?php if ('payment_received' == $payment['status']) : ?>
159
+						<?php $allready_received_amount += $payment['received_amount']; ?>
160 160
 					<?php endif; ?>
161 161
 				<?php endforeach; ?>
162
-				<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>
163
-				<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>
162
+				<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>
163
+				<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>
164 164
 			<?php else : ?>
165
-				<?php if ( isset( $_SESSION[ 'cart' ][ 'order_product_partial_payment' ]) ) : ?>
166
-				<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>
165
+				<?php if (isset($_SESSION['cart']['order_product_partial_payment'])) : ?>
166
+				<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>
167 167
 				<?php else: ?>
168
-				<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>
168
+				<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>
169 169
 				<?php endif; ?>
170 170
 			<?php endif; ?>
171 171
 	</div><!-- wps-cart-total -->
172 172
 </div><!-- wps-cart-cartouche -->
173 173
 
174
-<?php if ( empty($cart_type) || ( !empty($cart_type) && $cart_type != 'summary' && $cart_type != 'admin-panel')  ) : ?>
174
+<?php if (empty($cart_type) || (!empty($cart_type) && $cart_type != 'summary' && $cart_type != 'admin-panel')) : ?>
175 175
 <div class="wps-checkout-actions">
176
-	<button data-nonce="<?php echo wp_create_nonce( 'wps_empty_cart' ); ?>" class="wps-bton-second emptyCart"><?php _e( 'Empty the cart', 'wpshop' ); ?></button>
177
-	<?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?>
178
-		<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>
176
+	<button data-nonce="<?php echo wp_create_nonce('wps_empty_cart'); ?>" class="wps-bton-second emptyCart"><?php _e('Empty the cart', 'wpshop'); ?></button>
177
+	<?php if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') : ?>
178
+		<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>
179 179
 	<?php else : ?>
180
-		<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>
180
+		<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>
181 181
 	<?php endif; ?>
182 182
 </div>
183 183
 <div class="wps-cart-notices">
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 </div>
188 188
 <?php endif; ?>
189 189
 
190
-<?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' ) ) ) : ?>
191
-	<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">
190
+<?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'))) : ?>
191
+	<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">
192 192
 		<i class="dashicons dashicons-update"></i>
193
-		<?php _e( 'Update order informations', 'wpshop'); ?>
193
+		<?php _e('Update order informations', 'wpshop'); ?>
194 194
 	</button>
195 195
 <?php endif; ?>
196 196
 <?php $wps_payment_mode = get_option('wps_payment_mode'); ?>
197
-<?php if( isset( $wps_payment_mode['mode']['paypal']['active'] ) ): ?>
197
+<?php if (isset($wps_payment_mode['mode']['paypal']['active'])): ?>
198 198
 	<div class="wps-secured-logos">
199 199
 		<span class="wps-logo-paypal"></span>
200 200
 		<span class="wps-logo-visa"></span>
Please login to merge, or discard this patch.
Braces   +59 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 ?>
3 5
 <div class="wps-cart-cartouche">
4 6
 	<div class="wps-cart-message">
@@ -6,11 +8,16 @@  discard block
 block discarded – undo
6 8
 			<?php if ( !empty($cart_type) && $cart_type == 'summary' && !$account_origin ) : ?>
7 9
 				<?php $url_step_one = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ); ?>
8 10
 				<?php printf( __( 'You have forget an item ? <a href="%s">Modify your cart !</a>', 'wpshop'), $url_step_one ); ?>
9
-			<?php else : ?>
11
+			<?php else {
12
+	: ?>
10 13
 				<?php if( !$account_origin ) :
11 14
 							echo do_shortcode('[wps_apply_coupon]');
12
-						else : ?>
13
-					<button id="<?php echo $oid; ?>" class="wps-bton-first-mini-rounded make_order_again"><?php _e( 'Make this order again', 'wpshop'); ?></button>
15
+}
16
+						else {
17
+							: ?>
18
+					<button id="<?php echo $oid;
19
+						}
20
+						?>" class="wps-bton-first-mini-rounded make_order_again"><?php _e( 'Make this order again', 'wpshop'); ?></button>
14 21
 				<?php endif; ?>
15 22
 				<?php if( !empty($tracking) ) : ?>
16 23
 					<p><br />
@@ -20,8 +27,9 @@  discard block
 block discarded – undo
20 27
 					<?php if( !empty($tracking['link']) ) : ?>
21 28
 						<?php /** Check if http:// it's found in the link */
22 29
 						$url = $tracking['link'];
23
-						if('http://' != substr($url, 0, 7))
24
-							$url = 'http://' . $url;
30
+						if('http://' != substr($url, 0, 7)) {
31
+													$url = 'http://' . $url;
32
+						}
25 33
 						?>
26 34
 						<a class="wps-bton-fourth-mini-rounded" href="<?php echo $url; ?>" target="_blank"><?php _e('Tracking link','wpshop'); ?></a>
27 35
 					<?php endif; ?>
@@ -41,15 +49,21 @@  discard block
 block discarded – undo
41 49
 				<span class="wps-alignRight">
42 50
 					<?php if( $cart_type != 'admin-panel' ) : ?>
43 51
 						<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et ); ?></strong> <?php echo $currency; ?>
44
-					<?php else : ?>
52
+					<?php else {
53
+	: ?>
45 54
 						<?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 55
 							<span class="wps-form-group">
47 56
 								<span class="wps-form">
48
-									<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" />
57
+									<input type="text" size="5" value="<?php echo number_format( $shipping_cost_et, 2 );
58
+}
59
+?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
49 60
 								</span>
50 61
 							</span>
51
-						<?php else : ?>
52
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
62
+						<?php else {
63
+	: ?>
64
+							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_et );
65
+}
66
+?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
53 67
 						<?php endif; ?>
54 68
 					<?php endif; ?>
55 69
 				</span>
@@ -71,15 +85,21 @@  discard block
 block discarded – undo
71 85
 				<span class="wps-alignRight">
72 86
 					<?php if( $cart_type != 'admin-panel' ) : ?>
73 87
 						<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?></strong> <?php echo $currency; ?>
74
-					<?php else : ?>
88
+					<?php else {
89
+	: ?>
75 90
 						<?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' ) : ?>
76 91
 							<span class="wps-form-group">
77 92
 								<span class="wps-form">
78
-									<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" />
93
+									<input type="text" size="5" value="<?php echo number_format( $shipping_cost_ati, 2 );
94
+}
95
+?>" id="wps-orders-shipping-cost" class="wps-error" style="text-align : right" />
79 96
 								</span>
80 97
 							</span>
81
-						<?php else : ?>
82
-							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati ); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
98
+						<?php else {
99
+	: ?>
100
+							<strong><?php echo wpshop_tools::formate_number( $shipping_cost_ati );
101
+}
102
+?> <?php echo wpshop_tools::wpshop_get_currency(); ?></strong>
83 103
 						<?php endif; ?>
84 104
 					<?php endif; ?>
85 105
 				</span>
@@ -106,11 +126,17 @@  discard block
 block discarded – undo
106 126
 					<span class="wps-alignRight">
107 127
 						<?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' ) ) : ?>
108 128
 							<span class="wps-form-group"><span class="wps-form"><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'] : ''; ?>"/></span></span>
109
-						<?php else : ?>
129
+						<?php else {
130
+	: ?>
110 131
 							<?php if( !empty($cart_content['order_discount_value']) ) : ?>
111
-								<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>
112
-							<?php else : ?>
113
-								0 <?php echo wpshop_tools::wpshop_get_currency(); ?>
132
+								<strong><?php echo $cart_content['order_discount_value'];
133
+}
134
+?> <?php echo ( !empty($cart_content['order_discount_type']) && $cart_content['order_discount_type'] == 'percent' ) ? '%' : wpshop_tools::wpshop_get_currency(); ?></strong>
135
+							<?php else {
136
+	: ?>
137
+								0 <?php echo wpshop_tools::wpshop_get_currency();
138
+}
139
+?>
114 140
 							<?php endif; ?>
115 141
 						<?php endif; ?>
116 142
 					</span>
@@ -161,11 +187,17 @@  discard block
 block discarded – undo
161 187
 				<?php endforeach; ?>
162 188
 				<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>
163 189
 				<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>
164
-			<?php else : ?>
190
+			<?php else {
191
+	: ?>
165 192
 				<?php if ( isset( $_SESSION[ 'cart' ][ 'order_product_partial_payment' ]) ) : ?>
166
-				<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>
167
-				<?php else: ?>
168
-				<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>
193
+				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop');
194
+}
195
+?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $_SESSION['cart']['order_amount_to_pay_now'] ); ?></strong> <?php echo $currency; ?></span></p>
196
+				<?php else {
197
+	: ?>
198
+				<p class="wps-hightlight"><?php _e( 'Total ATI', 'wpshop');
199
+}
200
+?><span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number( $total_ati ); ?></strong> <?php echo $currency; ?></span></p>
169 201
 				<?php endif; ?>
170 202
 			<?php endif; ?>
171 203
 	</div><!-- wps-cart-total -->
@@ -176,8 +208,11 @@  discard block
 block discarded – undo
176 208
 	<button data-nonce="<?php echo wp_create_nonce( 'wps_empty_cart' ); ?>" class="wps-bton-second emptyCart"><?php _e( 'Empty the cart', 'wpshop' ); ?></button>
177 209
 	<?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?>
178 210
 		<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>
179
-	<?php else : ?>
180
-		<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>
211
+	<?php else {
212
+	: ?>
213
+		<button class="wps-bton-first" data-nonce="<?php echo wp_create_nonce( 'wps_cart_pass_to_step_two' );
214
+}
215
+?>" id="wps-cart-order-action"><?php _e( 'Order', 'wpshop' ); ?></button>
181 216
 	<?php endif; ?>
182 217
 </div>
183 218
 <div class="wps-cart-notices">
Please login to merge, or discard this patch.
includes/modules/wps_cart/controller/wps_cart_ctr.php 2 patches
Spacing   +299 added lines, -299 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"');
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 ) {
680
+		if (!$from_admin) {
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,48 +695,48 @@  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'] ) {
724
+		$cart_rule = wpshop_cart_rules::get_cart_rule($cart_infos['order_grand_total']);
725
+		if ($cart_rule['cart_rule_exist']) {
726 726
 			$cart_infos['order_discount_type'] = $cart_rule['cart_rule_info']['discount_type'];
727 727
 			$cart_infos['order_discount_value'] = $cart_rule['cart_rule_info']['discount_value'];
728 728
 		}
729 729
 
730 730
 		// Apply coupons
731
-		if( !empty( $_SESSION['cart']) && !$from_admin ) {
732
-			if( !empty($_SESSION['cart']['coupon_id']) ) {
731
+		if (!empty($_SESSION['cart']) && !$from_admin) {
732
+			if (!empty($_SESSION['cart']['coupon_id'])) {
733 733
 				$wps_coupon_mdl = new wps_coupon_model();
734
-				$coupon = $wps_coupon_mdl->get_coupon_data( $_SESSION['cart']['coupon_id'] );
735
-				if( !empty($coupon) && !empty($coupon['wpshop_coupon_code']) ) {
734
+				$coupon = $wps_coupon_mdl->get_coupon_data($_SESSION['cart']['coupon_id']);
735
+				if (!empty($coupon) && !empty($coupon['wpshop_coupon_code'])) {
736 736
 					$wps_coupon = new wps_coupon_ctr();
737
-					$coupon_checking = $wps_coupon->applyCoupon( $coupon['wpshop_coupon_code'] );
737
+					$coupon_checking = $wps_coupon->applyCoupon($coupon['wpshop_coupon_code']);
738 738
 					// If Coupon conditions are Ok
739
-					if( !empty($coupon_checking) && !empty($coupon_checking['status']) && $coupon_checking['status'] ) {
739
+					if (!empty($coupon_checking) && !empty($coupon_checking['status']) && $coupon_checking['status']) {
740 740
 						$cart_infos['order_discount_type'] = $coupon['wpshop_coupon_discount_type'];
741 741
 						$cart_infos['order_discount_value'] = $coupon['wpshop_coupon_discount_value'];
742 742
 					}
@@ -745,37 +745,37 @@  discard block
 block discarded – undo
745 745
 		}
746 746
 
747 747
 		// Checking Discounts
748
-		if( !empty($cart_infos['order_discount_type']) && $cart_infos['order_discount_value'] ) {
748
+		if (!empty($cart_infos['order_discount_type']) && $cart_infos['order_discount_value']) {
749 749
 			// Calcul discount on Order
750 750
 			switch ($cart_infos['order_discount_type']) {
751 751
 				case 'amount':
752 752
 				case 'absolute_discount':
753
-					$cart_infos['order_discount_amount_total_cart'] = number_format( str_replace( ',', '.', $cart_infos['order_discount_value'] ), 2, '.', '');
753
+					$cart_infos['order_discount_amount_total_cart'] = number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '');
754 754
 				break;
755 755
 				case 'percent':
756 756
 				case 'percent_discount':
757
-					$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);
757
+					$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);
758 758
 				break;
759 759
 			}
760
-			$cart_infos['order_grand_total'] -= number_format( $cart_infos['order_discount_amount_total_cart'], 2, '.', '');
761
-			$cart_infos['order_amount_to_pay_now'] = number_format( $cart_infos['order_grand_total'], 2, '.', '');
760
+			$cart_infos['order_grand_total'] -= number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '');
761
+			$cart_infos['order_amount_to_pay_now'] = number_format($cart_infos['order_grand_total'], 2, '.', '');
762 762
 		}
763 763
 
764 764
 		// Apply Partial Payments
765 765
 		$wpshop_payment = new wpshop_payment();
766
-		if( !empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation' ) {
767
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'], 'for_quotation' );
766
+		if (!empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation') {
767
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total'], 'for_quotation');
768 768
 		}
769 769
 		else {
770
-			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'] );
770
+			$partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total']);
771 771
 		}
772
-		if ( !empty($partial_payment['amount_to_pay']) && ( empty( $cart_infos['order_status'] ) || $cart_infos['order_status'] == 'awaiting_payment' ) && ( empty( $product_partial_payment_amount ) ) ) {
772
+		if (!empty($partial_payment['amount_to_pay']) && (empty($cart_infos['order_status']) || $cart_infos['order_status'] == 'awaiting_payment') && (empty($product_partial_payment_amount))) {
773 773
 			unset($partial_payment['display']);
774
-			$cart_infos['order_partial_payment'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
775
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
774
+			$cart_infos['order_partial_payment'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
775
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
776 776
 		}
777
-		else if( !empty( $cart_has_special_product ) ) {
778
-			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $cart_infos['order_amount_to_pay_now'] ), 2, '.', '');
777
+		else if (!empty($cart_has_special_product)) {
778
+			$cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $cart_infos['order_amount_to_pay_now']), 2, '.', '');
779 779
 			$cart_infos['order_product_partial_payment'] = 'subscription';
780 780
 		}
781 781
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 		}
786 786
 
787 787
 		// Apply Extra actions on cart infos
788
-		$cart_infos = apply_filters( 'wps_extra_calcul_in_cart', $cart_infos, $_SESSION );
788
+		$cart_infos = apply_filters('wps_extra_calcul_in_cart', $cart_infos, $_SESSION);
789 789
 
790 790
 		return $cart_infos;
791 791
 	}
@@ -795,18 +795,18 @@  discard block
 block discarded – undo
795 795
 	 * @param array $cart_items
796 796
 	 * @return array
797 797
 	 */
798
-	function add_automaticaly_product_to_cart( $cart_items ) {
798
+	function add_automaticaly_product_to_cart($cart_items) {
799 799
 		global $wpdb;
800 800
 		// Recovery all products with options
801 801
 		$query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
802 802
 		$post_list_with_options = $wpdb->get_results($query);
803 803
 		$wps_orders = new wps_orders_ctr();
804
-		if ( !empty($post_list_with_options) && !empty($cart_items) ) {
805
-			foreach ( $post_list_with_options as $product_info) {
804
+		if (!empty($post_list_with_options) && !empty($cart_items)) {
805
+			foreach ($post_list_with_options as $product_info) {
806 806
 				$product_meta = unserialize($product_info->meta_value);
807
-				if ( !empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id]) ) {
807
+				if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') && empty($cart_items[$product_info->post_id])) {
808 808
 					$product = wpshop_products::get_product_data($product_info->post_id, true, '"draft", "publish"');
809
-					$the_product = array_merge( array(
809
+					$the_product = array_merge(array(
810 810
 							'product_id'	=> $product_info->post_id,
811 811
 							'product_qty' 	=> 1
812 812
 					), $product);
@@ -820,31 +820,31 @@  discard block
 block discarded – undo
820 820
 
821 821
 	/** Ajax action to reload cart **/
822 822
 	public static function wps_reload_cart() {
823
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
823
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
824 824
 
825
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_cart' ) )
825
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_cart'))
826 826
 			wp_die();
827 827
 
828 828
 		$wps_cart = new wps_cart();
829 829
 		$result = $wps_cart->cart_content();
830
-		echo json_encode( array( 'response' => $result) );
830
+		echo json_encode(array('response' => $result));
831 831
 		die();
832 832
 	}
833 833
 
834 834
 
835 835
 	/** Ajax action to reload mini cart */
836 836
 	public static function wps_reload_mini_cart() {
837
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
837
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
838 838
 
839
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) )
839
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_mini_cart'))
840 840
 			wp_die();
841 841
 
842 842
 		$wps_cart = new wps_cart();
843
-		$result = $wps_cart->mini_cart_content( sanitize_title( $_POST['type']) );
844
-		$count_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])  ) ? $wps_cart->total_cart_items( $_SESSION['cart']['order_items'] ) : 0;
843
+		$result = $wps_cart->mini_cart_content(sanitize_title($_POST['type']));
844
+		$count_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $wps_cart->total_cart_items($_SESSION['cart']['order_items']) : 0;
845 845
 		$free_shipping_alert = wpshop_tools::create_custom_hook('wpshop_free_shipping_cost_alert');
846 846
 
847
-		echo json_encode( array( 'response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert) );
847
+		echo json_encode(array('response' => $result, 'count_items' => $count_items, 'free_shipping_alert' => $free_shipping_alert));
848 848
 		die();
849 849
 	}
850 850
 
@@ -854,35 +854,35 @@  discard block
 block discarded – undo
854 854
 	 * @return string
855 855
 	 */
856 856
 	function display_wps_numeration_cart() {
857
-		$cart_items = ( !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) ? $_SESSION['cart']['order_items'] : array();
858
-		$total_cart_item = self::total_cart_items( $cart_items );
857
+		$cart_items = (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) ? $_SESSION['cart']['order_items'] : array();
858
+		$total_cart_item = self::total_cart_items($cart_items);
859 859
 
860 860
 		ob_start();
861
-		require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart") );
861
+		require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/numeration-cart"));
862 862
 		$output = ob_get_contents();
863 863
 		ob_end_clean();
864 864
 		return $output;
865 865
 	}
866 866
 
867
-	public function display_button_add_to_cart( $args ) {
868
-		$button_text = __( 'Add to cart', 'wpshop' );
867
+	public function display_button_add_to_cart($args) {
868
+		$button_text = __('Add to cart', 'wpshop');
869 869
 		$use_button = true;
870
-		$output = __( 'No product has been found.', 'wpshop' );
870
+		$output = __('No product has been found.', 'wpshop');
871 871
 
872
-		if ( !empty( $args ) && !empty( $args['pid'] ) ) {
872
+		if (!empty($args) && !empty($args['pid'])) {
873 873
 
874 874
 			/** The user send the text in argument */
875
-			if ( !empty( $args['text' ] ) ) {
875
+			if (!empty($args['text'])) {
876 876
 				$button_text = $args['text'];
877 877
 			}
878 878
 
879 879
 			/** The user send use input */
880
-			if ( !empty( $args['use_button'] ) && 'false' == $args['use_button'] ) {
880
+			if (!empty($args['use_button']) && 'false' == $args['use_button']) {
881 881
 				$use_button = false;
882 882
 			}
883 883
 
884 884
 			ob_start();
885
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart' ) );
885
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, 'frontend/cart', 'button', 'add-to-cart'));
886 886
 			$output = ob_get_clean();
887 887
 		}
888 888
 
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 
892 892
 	/** Ajax action to reload summary cart */
893 893
 	public static function wps_reload_summary_cart() {
894
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
894
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
895 895
 
896
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_summary_cart' ) )
896
+		if (!wp_verify_nonce($_wpnonce, 'wps_reload_summary_cart'))
897 897
 			wp_die();
898 898
 
899 899
 		$wps_cart = new wps_cart();
900 900
 		$result = $wps_cart->resume_cart_content();
901
-		echo json_encode( array( 'response' => $result) );
901
+		echo json_encode(array('response' => $result));
902 902
 		die();
903 903
 	}
904 904
 
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
 	/** Display Apply Coupon Interface **/
907 907
 	function display_apply_coupon_interface() {
908 908
 		$output = '';
909
-		if ( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ) {
909
+		if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) {
910 910
 			ob_start();
911
-			require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon") );
911
+			require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "coupon/apply_coupon"));
912 912
 			$output = ob_get_contents();
913 913
 			ob_end_clean();
914 914
 		}
@@ -918,30 +918,30 @@  discard block
 block discarded – undo
918 918
 
919 919
 	/** AJAX - action to apply coupon **/
920 920
 	function wps_apply_coupon() {
921
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
921
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
922 922
 
923
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) )
923
+		if (!wp_verify_nonce($_wpnonce, 'wps_apply_coupon'))
924 924
 			wp_die();
925 925
 
926 926
 		$status = false; $response = '';
927
-		$coupon = ( !empty($_POST['coupon_code']) ) ? wpshop_tools::varSanitizer( $_POST['coupon_code']) : null;
928
-		if( !empty($coupon) ) {
927
+		$coupon = (!empty($_POST['coupon_code'])) ? wpshop_tools::varSanitizer($_POST['coupon_code']) : null;
928
+		if (!empty($coupon)) {
929 929
 			$wps_coupon_ctr = new wps_coupon_ctr();
930 930
 			$result = $wps_coupon_ctr->applyCoupon($coupon);
931
-			if ($result['status']===true) {
931
+			if ($result['status'] === true) {
932 932
 				$order = $this->calcul_cart_information(array());
933 933
 				$this->store_cart_in_session($order);
934 934
 				$status = true;
935
-				$response = '<div class="wps-alert-success">' .__( 'The coupon has been applied', 'wpshop' ). '</div>';
935
+				$response = '<div class="wps-alert-success">' . __('The coupon has been applied', 'wpshop') . '</div>';
936 936
 			}
937 937
 			else {
938
-				$response = '<div class="wps-alert-error">' .$result['message']. '</div>';
938
+				$response = '<div class="wps-alert-error">' . $result['message'] . '</div>';
939 939
 			}
940 940
 		}
941 941
 		else {
942
-			$response = '<div class="wps-alert-error">'.__( 'A coupon code is required', 'wpshop'). '</div>';
942
+			$response = '<div class="wps-alert-error">' . __('A coupon code is required', 'wpshop') . '</div>';
943 943
 		}
944
-		echo json_encode( array( 'status' => $status, 'response' => $response ) );
944
+		echo json_encode(array('status' => $status, 'response' => $response));
945 945
 		die();
946 946
 	}
947 947
 
@@ -950,24 +950,24 @@  discard block
 block discarded – undo
950 950
 	 * AJAX - Pass to step two in the Checkout tunnel
951 951
 	 */
952 952
 	public static function wps_cart_pass_to_step_two() {
953
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
953
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
954 954
 
955
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) )
955
+		if (!wp_verify_nonce($_wpnonce, 'wps_cart_pass_to_step_two'))
956 956
 			wp_die();
957 957
 
958 958
 		$status = false; $response = '';
959
-		$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
960
-		if( !empty($checkout_page_id) ) {
961
-			$permalink_option = get_option( 'permalink_structure' );
962
-			$step = ( get_current_user_id() != 0 ) ?  3 : 2;
963
-			$response = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step;
959
+		$checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'));
960
+		if (!empty($checkout_page_id)) {
961
+			$permalink_option = get_option('permalink_structure');
962
+			$step = (get_current_user_id() != 0) ? 3 : 2;
963
+			$response = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=' . $step;
964 964
 			$response = apply_filters('wps_extra_signup_actions', $response);
965 965
 			$status = true;
966 966
 		}
967 967
 		else {
968
-			$response = '<div class="wps-alert-error">' .__( 'An error was occured, please retry later or contact the website administrator', 'wpshop' ). '</div>';
968
+			$response = '<div class="wps-alert-error">' . __('An error was occured, please retry later or contact the website administrator', 'wpshop') . '</div>';
969 969
 		}
970
-		echo json_encode( array( 'status' => $status, 'response' => $response));
970
+		echo json_encode(array('status' => $status, 'response' => $response));
971 971
 		die();
972 972
 	}
973 973
 
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
 	 * AJAX - Empty the cart
977 977
 	 */
978 978
 	function wps_empty_cart() {
979
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
979
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
980 980
 
981
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) )
981
+		if (!wp_verify_nonce($_wpnonce, 'wps_empty_cart'))
982 982
 			wp_die();
983 983
 
984 984
 
985 985
 		$this->empty_cart();
986
-		echo json_encode( array( 'status' => true) );
986
+		echo json_encode(array('status' => true));
987 987
 		die();
988 988
 	}
989 989
 }
Please login to merge, or discard this patch.
Braces   +60 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 class wps_cart {
3 5
 
4 6
 	function __construct() {
@@ -151,12 +153,10 @@  discard block
 block discarded – undo
151 153
 				require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart") );
152 154
 				$output = ob_get_contents();
153 155
 				ob_end_clean();
154
-			}
155
-			else {
156
+			} else {
156 157
 				return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
157 158
 			}
158
-		}
159
-		else {
159
+		} else {
160 160
 			return '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';;
161 161
 		}
162 162
 		return $output;
@@ -174,15 +174,13 @@  discard block
 block discarded – undo
174 174
 			/** Count items **/
175 175
 			$total_cart_item = self::total_cart_items( $cart_items );
176 176
 			$mini_cart_body = self::mini_cart_content( $type );
177
-		}
178
-		else {
177
+		} else {
179 178
 			$mini_cart_body = __( 'Your cart is empty', 'wpshop' );
180 179
 		}
181 180
 		ob_start();
182 181
 		if( !empty($type) && $type == 'fixed' ) {
183 182
 			require(wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart") );
184
-		}
185
-		else {
183
+		} else {
186 184
 			require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart") );
187 185
 		}
188 186
 
@@ -210,18 +208,15 @@  discard block
 block discarded – undo
210 208
 				ob_start();
211 209
 				if( !empty($type) && $type == 'fixed' ) {
212 210
 					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/fixed-mini-cart", "content") );
213
-				}
214
-				else {
211
+				} else {
215 212
 					require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "mini-cart/mini-cart", "content") );
216 213
 				}
217 214
 				$output = ob_get_contents();
218 215
 				ob_end_clean();
219
-			}
220
-			else {
216
+			} else {
221 217
 				$output = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
222 218
 			}
223
-		}
224
-		else {
219
+		} else {
225 220
 			$output = '<div class="wps-alert-info">' . __( 'Your cart is empty', 'wpshop' ).'</div>';
226 221
 		}
227 222
 		return $output;
@@ -256,12 +251,10 @@  discard block
 block discarded – undo
256 251
 				require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content") );
257 252
 				$output = ob_get_contents();
258 253
 				ob_end_clean();
259
-			}
260
-			else {
254
+			} else {
261 255
 				$resume_cart_body = '<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
262 256
 			}
263
-		}
264
-		else {
257
+		} else {
265 258
 			$resume_cart_body ='<div class="wps-alert-info">' .__( 'Your cart is empty', 'wpshop' ).'</div>';
266 259
 		}
267 260
 		return $output;
@@ -298,8 +291,9 @@  discard block
 block discarded – undo
298 291
 	 * @return array()
299 292
 	 */
300 293
 	function get_persistent_cart() {
301
-		if(get_current_user_id())
302
-			$cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true);
294
+		if(get_current_user_id()) {
295
+					$cart = get_user_meta(get_current_user_id(), '_wpshop_persistent_cart', true);
296
+		}
303 297
 		return empty($cart) ? array() : $cart;
304 298
 	}
305 299
 
@@ -314,10 +308,11 @@  discard block
 block discarded – undo
314 308
 	 * Save the persistent cart when updated
315 309
 	 */
316 310
 	function persistent_cart_update() {
317
-		if(get_current_user_id())
318
-			update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array(
311
+		if(get_current_user_id()) {
312
+					update_user_meta( get_current_user_id(), '_wpshop_persistent_cart', array(
319 313
 					'cart' => $_SESSION['cart'],
320 314
 			));
315
+		}
321 316
 	}
322 317
 
323 318
 	/**
@@ -372,8 +367,7 @@  discard block
 block discarded – undo
372 367
 				// Check Parent ID
373 368
 				if( get_post_type($cart['order_items'][ $product_id ]['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
374 369
 					$parent_product_id = $cart['order_items'][ $product_id ]['item_id'];
375
-				}
376
-				else {
370
+				} else {
377 371
 					$parent_data = wpshop_products::get_parent_variation( $cart['order_items'][ $product_id ]['item_id'] );
378 372
 					$parent_post = $parent_data['parent_post'];
379 373
 					$parent_product_id = $parent_post->ID;
@@ -388,8 +382,7 @@  discard block
 block discarded – undo
388 382
 							}
389 383
 						}
390 384
 					}
391
-				}
392
-				else {
385
+				} else {
393 386
 					$selected_variations = get_post_meta( $product_id, '_wpshop_variations_attribute_def', true );
394 387
 				}
395 388
 			}
@@ -399,8 +392,7 @@  discard block
 block discarded – undo
399 392
 			$new_pid = $product_id;
400 393
 			$return = $this->add_to_cart( $product_to_add_to_cart, array( $new_pid => $quantity ), $wpshop_cart_type, array(), $from_admin, $cart, $order_id );
401 394
 			return $return;
402
-		}
403
-		else {
395
+		} else {
404 396
 			return __('This product does not exist in the cart.', 'wpshop');
405 397
 		}
406 398
 	}
@@ -416,8 +408,7 @@  discard block
 block discarded – undo
416 408
 		if ( empty( $from_admin ) ){
417 409
 			if(isset($_SESSION['cart']['cart_type']) && $type != $_SESSION['cart']['cart_type'] ) {
418 410
 				return __('You have another element type into your cart. Please finalize it by going to cart page.', 'wpshop');
419
-			}
420
-			else {
411
+			} else {
421 412
 				$_SESSION['cart']['cart_type'] = $type;
422 413
 			}
423 414
 			$order_meta = $_SESSION['cart'];
@@ -428,22 +419,27 @@  discard block
 block discarded – undo
428 419
 
429 420
 		foreach ($product_list as $pid => $product_more_content) {
430 421
 			if ( count($product_list) == 1 ) {
431
-				if ( !isset( $quantity[$pid] ) ) $quantity[$pid] = 1;
422
+				if ( !isset( $quantity[$pid] ) ) {
423
+					$quantity[$pid] = 1;
424
+				}
432 425
 				$product = wpshop_products::get_product_data($product_more_content['id'], false, '"publish"');
433 426
 				/** Check if the selected product exist	*/
434
-				if ( $product === false ) return __('This product does not exist', 'wpshop');
427
+				if ( $product === false ) {
428
+					return __('This product does not exist', 'wpshop');
429
+				}
435 430
 
436 431
 				/** Get information about the product price	*/
437 432
 				$product_price_check = wpshop_prices::get_product_price($product, 'check_only');
438
-				if ( $product_price_check !== true ) return $product_price_check;
433
+				if ( $product_price_check !== true ) {
434
+					return $product_price_check;
435
+				}
439 436
 
440 437
 				$the_quantity = 1;
441 438
 
442 439
 				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 440
 					/** Get the asked quantity for each product and check if there is enough stock	*/
444 441
 					$the_quantity = $quantity[$pid];
445
-				}
446
-				else {
442
+				} else {
447 443
 					/** Get the asked quantity for each product and check if there is enough stock	*/
448 444
 					$the_quantity = $quantity[$pid];
449 445
 				}
@@ -486,8 +482,7 @@  discard block
 block discarded – undo
486 482
 			if ( get_current_user_id() ) {
487 483
 				$this->persistent_cart_update();
488 484
 			}
489
-		}
490
-		else {
485
+		} else {
491 486
 			update_post_meta($order_id, '_order_postmeta', $order );
492 487
 
493 488
 		}
@@ -631,8 +626,7 @@  discard block
 block discarded – undo
631 626
 					if( empty( $d['product_qty'] ) ) {
632 627
 						unset( $cart_items[$product_key] );
633 628
 						unset( $cart_infos['order_items'][$product_key] );
634
-					}
635
-					else {
629
+					} else {
636 630
 						$wps_orders = new wps_orders_ctr();
637 631
 						$cart_items[$product_key] = $wps_orders->add_product_to_order($the_product);
638 632
 					}
@@ -651,8 +645,7 @@  discard block
 block discarded – undo
651 645
 				if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) {
652 646
 					$cart_has_special_product = true;
653 647
 					$cart_infos['order_amount_to_pay_now'] += ( $item[ 'item_amount_to_pay_now' ] * $item[ 'item_qty' ] );
654
-				}
655
-				else {
648
+				} else {
656 649
 					$cart_infos['order_amount_to_pay_now'] += $item['item_total_ttc'];
657 650
 				}
658 651
 
@@ -661,13 +654,11 @@  discard block
 block discarded – undo
661 654
 				// VAT
662 655
 				if( !empty($order_tva[ $item['item_tva_rate'] ]) ) {
663 656
 					$order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount'];
664
-				}
665
-				else {
657
+				} else {
666 658
 					$order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount'];
667 659
 				}
668 660
 			}
669
-		}
670
-		else {
661
+		} else {
671 662
 			return array();
672 663
 		}
673 664
 
@@ -765,16 +756,14 @@  discard block
 block discarded – undo
765 756
 		$wpshop_payment = new wpshop_payment();
766 757
 		if( !empty($cart_infos['cart_type']) && $cart_infos['cart_type'] == 'quotation' ) {
767 758
 			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'], 'for_quotation' );
768
-		}
769
-		else {
759
+		} else {
770 760
 			$partial_payment = $wpshop_payment->partial_payment_calcul( $cart_infos['order_grand_total'] );
771 761
 		}
772 762
 		if ( !empty($partial_payment['amount_to_pay']) && ( empty( $cart_infos['order_status'] ) || $cart_infos['order_status'] == 'awaiting_payment' ) && ( empty( $product_partial_payment_amount ) ) ) {
773 763
 			unset($partial_payment['display']);
774 764
 			$cart_infos['order_partial_payment'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
775 765
 			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $partial_payment['amount_to_pay'] ), 2, '.', '');
776
-		}
777
-		else if( !empty( $cart_has_special_product ) ) {
766
+		} else if( !empty( $cart_has_special_product ) ) {
778 767
 			$cart_infos['order_amount_to_pay_now'] = number_format( str_replace( ',', '.', $cart_infos['order_amount_to_pay_now'] ), 2, '.', '');
779 768
 			$cart_infos['order_product_partial_payment'] = 'subscription';
780 769
 		}
@@ -822,8 +811,9 @@  discard block
 block discarded – undo
822 811
 	public static function wps_reload_cart() {
823 812
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
824 813
 
825
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_cart' ) )
826
-			wp_die();
814
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_cart' ) ) {
815
+					wp_die();
816
+		}
827 817
 
828 818
 		$wps_cart = new wps_cart();
829 819
 		$result = $wps_cart->cart_content();
@@ -836,8 +826,9 @@  discard block
 block discarded – undo
836 826
 	public static function wps_reload_mini_cart() {
837 827
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
838 828
 
839
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) )
840
-			wp_die();
829
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_mini_cart' ) ) {
830
+					wp_die();
831
+		}
841 832
 
842 833
 		$wps_cart = new wps_cart();
843 834
 		$result = $wps_cart->mini_cart_content( sanitize_title( $_POST['type']) );
@@ -893,8 +884,9 @@  discard block
 block discarded – undo
893 884
 	public static function wps_reload_summary_cart() {
894 885
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
895 886
 
896
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_summary_cart' ) )
897
-			wp_die();
887
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_reload_summary_cart' ) ) {
888
+					wp_die();
889
+		}
898 890
 
899 891
 		$wps_cart = new wps_cart();
900 892
 		$result = $wps_cart->resume_cart_content();
@@ -920,8 +912,9 @@  discard block
 block discarded – undo
920 912
 	function wps_apply_coupon() {
921 913
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
922 914
 
923
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) )
924
-			wp_die();
915
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_apply_coupon' ) ) {
916
+					wp_die();
917
+		}
925 918
 
926 919
 		$status = false; $response = '';
927 920
 		$coupon = ( !empty($_POST['coupon_code']) ) ? wpshop_tools::varSanitizer( $_POST['coupon_code']) : null;
@@ -933,12 +926,10 @@  discard block
 block discarded – undo
933 926
 				$this->store_cart_in_session($order);
934 927
 				$status = true;
935 928
 				$response = '<div class="wps-alert-success">' .__( 'The coupon has been applied', 'wpshop' ). '</div>';
936
-			}
937
-			else {
929
+			} else {
938 930
 				$response = '<div class="wps-alert-error">' .$result['message']. '</div>';
939 931
 			}
940
-		}
941
-		else {
932
+		} else {
942 933
 			$response = '<div class="wps-alert-error">'.__( 'A coupon code is required', 'wpshop'). '</div>';
943 934
 		}
944 935
 		echo json_encode( array( 'status' => $status, 'response' => $response ) );
@@ -952,8 +943,9 @@  discard block
 block discarded – undo
952 943
 	public static function wps_cart_pass_to_step_two() {
953 944
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
954 945
 
955
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) )
956
-			wp_die();
946
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_cart_pass_to_step_two' ) ) {
947
+					wp_die();
948
+		}
957 949
 
958 950
 		$status = false; $response = '';
959 951
 		$checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) );
@@ -963,8 +955,7 @@  discard block
 block discarded – undo
963 955
 			$response = get_permalink( $checkout_page_id  ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step='.$step;
964 956
 			$response = apply_filters('wps_extra_signup_actions', $response);
965 957
 			$status = true;
966
-		}
967
-		else {
958
+		} else {
968 959
 			$response = '<div class="wps-alert-error">' .__( 'An error was occured, please retry later or contact the website administrator', 'wpshop' ). '</div>';
969 960
 		}
970 961
 		echo json_encode( array( 'status' => $status, 'response' => $response));
@@ -978,8 +969,9 @@  discard block
 block discarded – undo
978 969
 	function wps_empty_cart() {
979 970
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
980 971
 
981
-		if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) )
982
-			wp_die();
972
+		if ( !wp_verify_nonce( $_wpnonce, 'wps_empty_cart' ) ) {
973
+					wp_die();
974
+		}
983 975
 
984 976
 
985 977
 		$this->empty_cart();
Please login to merge, or discard this patch.
includes/modules/wps_installer/controller/wps_installer_ctr.php 2 patches
Spacing   +59 added lines, -59 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
  * File for installer control class definition
4 4
  *
@@ -25,63 +25,63 @@  discard block
 block discarded – undo
25 25
 	function __construct() {
26 26
 
27 27
 		/**	Call administration style definition	*/
28
-		add_action( 'admin_init', array( &$this, 'admin_css' ) );
28
+		add_action('admin_init', array(&$this, 'admin_css'));
29 29
 
30 30
 		/**	Call administration scripts	*/
31
-		add_action( 'admin_init', array( &$this, 'admin_js' ));
31
+		add_action('admin_init', array(&$this, 'admin_js'));
32 32
 
33
-		$current_step = ( !empty( $_GET['wps-installation-step'] ) ) ? sanitize_title( $_GET['wps-installation-step'] ) : $this->current_installation_step;
33
+		$current_step = (!empty($_GET['wps-installation-step'])) ? sanitize_title($_GET['wps-installation-step']) : $this->current_installation_step;
34 34
 
35 35
 		/**	Instanciate datas saver components */
36 36
 		$wps_installer_model = new wps_installer_model();
37 37
 
38
-		$action = !empty( $_POST[ 'action' ] ) ? sanitize_text_field( $_POST[ 'action' ] ) : '';
38
+		$action = !empty($_POST['action']) ? sanitize_text_field($_POST['action']) : '';
39 39
 		/**	Call datas saver	*/
40
-		if ( !empty( $current_step ) && !empty( $action ) && ( "wps-installation" == $action ) ) {
40
+		if (!empty($current_step) && !empty($action) && ("wps-installation" == $action)) {
41 41
 			$step_to_save = $current_step - 1;
42
-			$wps_installer_model->save_step( $step_to_save );
43
-			if ( WPSINSTALLER_STEPS_COUNT == $current_step ) {
44
-				add_action( 'init', array( &$this, 'go_to_wpshop_about' ) );
42
+			$wps_installer_model->save_step($step_to_save);
43
+			if (WPSINSTALLER_STEPS_COUNT == $current_step) {
44
+				add_action('init', array(&$this, 'go_to_wpshop_about'));
45 45
 			}
46 46
 		}
47 47
 
48 48
 		/**	Set the current installatino step	*/
49
-		$this->current_installation_step = get_option( 'wps-installation-current-step', 1 );
49
+		$this->current_installation_step = get_option('wps-installation-current-step', 1);
50 50
 
51 51
 		/**	Get current version for wpshop plugin	*/
52
-		$wps_current_db_version = get_option( 'wpshop_db_options', 0 );
52
+		$wps_current_db_version = get_option('wpshop_db_options', 0);
53 53
 
54 54
 		/**	Check the configuration state	*/
55
-		$installation_state = !empty( $_GET[ 'installation_state' ] ) ? sanitize_text_field( $_GET[ 'installation_state' ] ) : '';
56
-		if ( isset( $installation_state ) && !empty( $installation_state ) && !empty( $wps_current_db_version )
57
-		&& (empty( $wps_current_db_version[ 'installation_state' ] ) || ( $wps_current_db_version[ 'installation_state' ] != 'completed' ) ) ) {
58
-			$wps_current_db_version = $wps_installer_model->installer_state_saver( $installation_state, $wps_current_db_version );
55
+		$installation_state = !empty($_GET['installation_state']) ? sanitize_text_field($_GET['installation_state']) : '';
56
+		if (isset($installation_state) && !empty($installation_state) && !empty($wps_current_db_version)
57
+		&& (empty($wps_current_db_version['installation_state']) || ($wps_current_db_version['installation_state'] != 'completed'))) {
58
+			$wps_current_db_version = $wps_installer_model->installer_state_saver($installation_state, $wps_current_db_version);
59 59
 		}
60 60
 
61 61
 		/**	Do verification for shop who are configured for being sale shop	*/
62
-		$current_page = strstr( $_SERVER[ "REQUEST_URI" ], 'wps-about');
63
-		if ( isset( $wps_current_db_version['installation_state'] ) && ( $wps_current_db_version[ 'installation_state' ] == 'completed' ) && ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) && empty( $current_page ) ) {
64
-			add_action( 'admin_notices', array( 'wpshop_notices' , 'sale_shop_notice' ) );
62
+		$current_page = strstr($_SERVER["REQUEST_URI"], 'wps-about');
63
+		if (isset($wps_current_db_version['installation_state']) && ($wps_current_db_version['installation_state'] == 'completed') && (WPSHOP_DEFINED_SHOP_TYPE == 'sale') && empty($current_page)) {
64
+			add_action('admin_notices', array('wpshop_notices', 'sale_shop_notice'));
65 65
 		}
66 66
 
67 67
 		/**	Create an administration menu	*/
68
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
69
-		add_action( 'admin_head', array( $this, 'admin_head' ), 11 );
68
+		add_action('admin_menu', array($this, 'admin_menu'), 10);
69
+		add_action('admin_head', array($this, 'admin_head'), 11);
70 70
 
71 71
 		/**	In case that configuration have not been done and that instalation is not asked to be ignored	*/
72
-		if ( empty( $wps_current_db_version ) || empty( $wps_current_db_version[ 'installation_state' ] ) || ( !empty( $wps_current_db_version[ 'installation_state' ] ) && !in_array( $wps_current_db_version[ 'installation_state' ], array( 'completed', 'ignored' ) ) ) ) {
72
+		if (empty($wps_current_db_version) || empty($wps_current_db_version['installation_state']) || (!empty($wps_current_db_version['installation_state']) && !in_array($wps_current_db_version['installation_state'], array('completed', 'ignored')))) {
73 73
 			/*	Check the db installation state for admin message output	*/
74
-			$current_page = strstr( $_SERVER[ "REQUEST_URI" ], 'wps-installer');
75
-			if( ( WPSINSTALLER_STEPS_COUNT > $this->current_installation_step ) && ( empty( $current_page ) ) ) {
76
-				add_action( 'admin_notices', array( &$this, 'install_admin_notice' ) );
74
+			$current_page = strstr($_SERVER["REQUEST_URI"], 'wps-installer');
75
+			if ((WPSINSTALLER_STEPS_COUNT > $this->current_installation_step) && (empty($current_page))) {
76
+				add_action('admin_notices', array(&$this, 'install_admin_notice'));
77 77
 			}
78 78
 		}
79 79
 
80 80
 		/**	Hook wpshop dashboard in order to display the notice banner with quick links - wordpress like	*/
81
-		add_filter( 'wps-dashboard-notice', array( $this, 'wps_dashboard_notice' ), 10, 1 );
81
+		add_filter('wps-dashboard-notice', array($this, 'wps_dashboard_notice'), 10, 1);
82 82
 
83 83
 		/**	Hook ajax action when clicking on hide welcome banner on wpshop dashboard	*/
84
-		add_action( 'wp_ajax_wps-hide-welcome-panel', array( $this, 'wps_hide_welcome_panel' ) );
84
+		add_action('wp_ajax_wps-hide-welcome-panel', array($this, 'wps_hide_welcome_panel'));
85 85
 	}
86 86
 
87 87
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	function admin_head() {
100 100
 		// remove_menu_page( 'wps-about' );
101
-		remove_menu_page( 'wps-installer' );
101
+		remove_menu_page('wps-installer');
102 102
 	}
103 103
 
104 104
 	/**
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	function admin_menu() {
108 108
 		/**	Get current version for wpshop plugin	*/
109
-		$wps_current_db_version = get_option( 'wpshop_db_options', 0 );
109
+		$wps_current_db_version = get_option('wpshop_db_options', 0);
110 110
 
111 111
 		// About WPShop called in wps_help
112 112
 		// add_menu_page( __( 'About WPShop', 'wpshop' ), __( 'WPShop - about', 'wpshop' ), 'manage_options', 'wps-about', array( &$this, 'wps_about_page' ) );
113
-		add_menu_page( __( 'Install WPShop', 'wpshop' ), __( 'WPShop - install', 'wpshop' ), 'manage_options', 'wps-installer', array( &$this, 'installer_main_page' ) );
113
+		add_menu_page(__('Install WPShop', 'wpshop'), __('WPShop - install', 'wpshop'), 'manage_options', 'wps-installer', array(&$this, 'installer_main_page'));
114 114
 		/*if ( empty( $wps_current_db_version ) || empty( $wps_current_db_version[ 'installation_state' ] ) || ( !empty( $wps_current_db_version[ 'installation_state' ] ) && !in_array( $wps_current_db_version[ 'installation_state' ], array( 'completed', 'ignored' ) ) ) ) {
115 115
 			add_menu_page( __( 'Wpshop installer', 'wpshop'), __( 'Wpshop', 'wpshop'), 'wpshop_view_dashboard', 'wps-installer', array( &$this, 'installer_main_page'), WPSHOP_MEDIAS_URL . "icones/wpshop_menu_icons.png", 34 );
116 116
 		}*/
@@ -120,23 +120,23 @@  discard block
 block discarded – undo
120 120
 	 * Enqueue scripts definition
121 121
 	 */
122 122
 	function admin_js() {
123
-		wp_enqueue_script( 'wps-installer-admin-scripts', WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/js/backend-scripts.js', array( 'jquery' ), WPS_INSTALLER_VERSION);
123
+		wp_enqueue_script('wps-installer-admin-scripts', WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/js/backend-scripts.js', array('jquery'), WPS_INSTALLER_VERSION);
124 124
 	}
125 125
 
126 126
 	/**
127 127
 	 * Display the installer interface
128 128
 	 */
129 129
 	function installer_main_page() {
130
-		$current_step = ( !empty( $_GET['wps-installation-step'] ) ) ? wpshop_tools::varSanitizer( $_GET['wps-installation-step'] ) : $this->current_installation_step;
131
-		$steps = unserialize( WPSINSTALLER_STEPS );
130
+		$current_step = (!empty($_GET['wps-installation-step'])) ? wpshop_tools::varSanitizer($_GET['wps-installation-step']) : $this->current_installation_step;
131
+		$steps = unserialize(WPSINSTALLER_STEPS);
132 132
 
133 133
 		/**	Get the defined shop type in order to display the different element to	*/
134
-		$wps_shop_type = get_option( 'wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE );
134
+		$wps_shop_type = get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
135 135
 
136 136
 		/** Check the current step to display */
137 137
 		$current_step_output = '';
138 138
 		$the_step_file = '';
139
-		switch( $current_step ) {
139
+		switch ($current_step) {
140 140
 			case 2:
141 141
 				$the_step_file = 'step_two';
142 142
 				break;
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 
149 149
 		/**	Create display for current step	*/
150 150
 		ob_start();
151
-		require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", $the_step_file ) );
151
+		require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", $the_step_file));
152 152
 		$current_step_output = ob_get_contents();
153 153
 		ob_end_clean();
154 154
 
155
-		require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "installer" ) );
155
+		require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "installer"));
156 156
 	}
157 157
 
158 158
 	/**
159 159
 	 * Create a notice for admin user when plugin is activated and not yet configured
160 160
 	 */
161 161
 	function install_admin_notice() {
162
-		require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "notice" ) );
162
+		require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "notice"));
163 163
 	}
164 164
 
165 165
 	/**
166 166
 	 * Redirect the user automatically to the wpshop about page
167 167
 	 */
168 168
 	function go_to_wpshop_about() {
169
-		wp_redirect( admin_url( 'admin.php?page=wpshop_about' ) );
169
+		wp_redirect(admin_url('admin.php?page=wpshop_about'));
170 170
 		exit();
171 171
 	}
172 172
 
@@ -174,26 +174,26 @@  discard block
 block discarded – undo
174 174
 	 * DISPLAY - Output the about page for wpshop
175 175
 	 */
176 176
 	function wps_about_page() {
177
-		require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "about" ) );
177
+		require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "about"));
178 178
 	}
179 179
 
180 180
 	/**
181 181
 	 * DISPLAY - Display a banner on wpshop dashboard
182 182
 	 */
183 183
 	function wps_dashboard_notice() {
184
-		$user_pref = get_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', true );
184
+		$user_pref = get_user_meta(get_current_user_id(), '_wps_hide_notice_messages_indicator', true);
185 185
 
186
-		if ( empty( $user_pref ) || empty( $user_pref[ 'welcome-banner' ] ) ) {
186
+		if (empty($user_pref) || empty($user_pref['welcome-banner'])) {
187 187
 			/**	Get current shop type	*/
188
-			$shop_type = get_option( 'wpshop_shop_type' );
188
+			$shop_type = get_option('wpshop_shop_type');
189 189
 
190 190
 			/**	Get the current number of product created	*/
191 191
 			$nb_products = 0;
192
-			$created_products = wp_count_posts( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
193
-			if ( !empty( $created_products ) ) {
194
-				foreach ( $created_products as $created_product_type => $created_product_nb) {
192
+			$created_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
193
+			if (!empty($created_products)) {
194
+				foreach ($created_products as $created_product_type => $created_product_nb) {
195 195
 					/**	Don't count product that are automatically created and not accessible through amin interface	*/
196
-					if ( !in_array( $created_product_type, array( 'auto-draft', 'inherit' ) ) ) {
196
+					if (!in_array($created_product_type, array('auto-draft', 'inherit'))) {
197 197
 						$nb_products += $created_product_nb;
198 198
 					}
199 199
 				}
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
 
202 202
 			/**	Get configuration about payment method 	*/
203 203
 			$no_payment_mode_configurated = true;
204
-			if ( !empty($paymentMethod ) && !empty($paymentMethod['mode']) ) {
205
-				foreach( $paymentMethod['mode'] as $k => $pm ) {
206
-					if ( !empty($pm['active'] ) ) {
204
+			if (!empty($paymentMethod) && !empty($paymentMethod['mode'])) {
205
+				foreach ($paymentMethod['mode'] as $k => $pm) {
206
+					if (!empty($pm['active'])) {
207 207
 						$no_payment_mode_configurated = false;
208 208
 					}
209 209
 				}
210 210
 			}
211 211
 
212 212
 			/**	Get configuration about emails 	*/
213
-			$emails = get_option('wpshop_emails', array() );
213
+			$emails = get_option('wpshop_emails', array());
214 214
 
215
-			require_once( wpshop_tools::get_template_part( WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "welcome" ) );
215
+			require_once(wpshop_tools::get_template_part(WPS_INSTALLER_DIR, WPSINSTALLER_TPL_DIR, "backend", "welcome"));
216 216
 		}
217 217
 	}
218 218
 
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 	 * AJAX - Launch ajax action allowing to hide welcome panel for current user
221 221
 	 */
222 222
 	function wps_hide_welcome_panel() {
223
-		$wpshop_ajax_nonce = !empty( $_REQUEST['wpshop_ajax_nonce'] ) ? sanitize_text_field( $_REQUEST['wpshop_ajax_nonce'] ) : '';
223
+		$wpshop_ajax_nonce = !empty($_REQUEST['wpshop_ajax_nonce']) ? sanitize_text_field($_REQUEST['wpshop_ajax_nonce']) : '';
224 224
 
225
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-installer-welcome-panel-close' ) )
225
+		if (!wp_verify_nonce($_wpnonce, 'wps-installer-welcome-panel-close'))
226 226
 			wp_die();
227 227
 
228
-		$user_pref = get_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', true );
229
-		$user_pref[ 'welcome-banner' ] = true;
228
+		$user_pref = get_user_meta(get_current_user_id(), '_wps_hide_notice_messages_indicator', true);
229
+		$user_pref['welcome-banner'] = true;
230 230
 
231 231
 		$response = array(
232 232
 			'status' => false,
233 233
 		);
234 234
 
235
-		$user_pref = update_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', $user_pref );
236
-		if ( false !== $user_pref ) {
237
-			$response[ 'status' ] = true;
235
+		$user_pref = update_user_meta(get_current_user_id(), '_wps_hide_notice_messages_indicator', $user_pref);
236
+		if (false !== $user_pref) {
237
+			$response['status'] = true;
238 238
 		}
239 239
 
240
-		wp_die( json_encode( $response ) );
240
+		wp_die(json_encode($response));
241 241
 	}
242 242
 }
243 243
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * File for installer control class definition
4 6
  *
@@ -222,8 +224,9 @@  discard block
 block discarded – undo
222 224
 	function wps_hide_welcome_panel() {
223 225
 		$wpshop_ajax_nonce = !empty( $_REQUEST['wpshop_ajax_nonce'] ) ? sanitize_text_field( $_REQUEST['wpshop_ajax_nonce'] ) : '';
224 226
 
225
-		if ( !wp_verify_nonce( $_wpnonce, 'wps-installer-welcome-panel-close' ) )
226
-			wp_die();
227
+		if ( !wp_verify_nonce( $_wpnonce, 'wps-installer-welcome-panel-close' ) ) {
228
+					wp_die();
229
+		}
227 230
 
228 231
 		$user_pref = get_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', true );
229 232
 		$user_pref[ 'welcome-banner' ] = true;
Please login to merge, or discard this patch.
includes/modules/wpshop_cart_rules/wpshop_cart_rules.php 2 patches
Spacing   +113 added lines, -113 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
 /**
4 4
  * Cart rules bootstrap file
@@ -9,29 +9,29 @@  discard block
 block discarded – undo
9 9
  *
10 10
  */
11 11
 
12
-if ( !defined( 'WPSHOP_VERSION' ) ) {
13
-	die( __("You are not allowed to use this service.", 'wpshop') );
12
+if (!defined('WPSHOP_VERSION')) {
13
+	die(__("You are not allowed to use this service.", 'wpshop'));
14 14
 }
15
-if ( !class_exists("wpshop_cart_rules") ) {
15
+if (!class_exists("wpshop_cart_rules")) {
16 16
 	class wpshop_cart_rules {
17 17
 
18
-		function __construct () {
18
+		function __construct() {
19 19
 			/**	Add module option to wpshop general options	*/
20 20
 			add_filter('wpshop_options', array(&$this, 'add_options'), 9);
21 21
 			add_action('wsphop_options', array(&$this, 'declare_options'));
22 22
 
23
-			add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) );
23
+			add_filter('wpshop_custom_template', array(&$this, 'custom_template_load'));
24 24
 
25 25
 			/**	Call style for administration	*/
26
-			add_action( 'admin_enqueue_scripts', array( &$this, 'admin_css' ) );
26
+			add_action('admin_enqueue_scripts', array(&$this, 'admin_css'));
27 27
 
28 28
 			/**	Include the different javascript	*/
29
-			add_action( 'init', array(&$this, 'frontend_js') );
30
-			add_action( 'admin_init', array(&$this, 'admin_js') );
29
+			add_action('init', array(&$this, 'frontend_js'));
30
+			add_action('admin_init', array(&$this, 'admin_js'));
31 31
 
32 32
 			/** AJAX actions **/
33
-			add_action('wp_ajax_save_cart_rule',array( $this, 'wpshop_ajax_save_cart_rule'));
34
-			add_action('wp_ajax_delete_cart_rule',array( $this, 'wpshop_ajax_delete_cart_rule'));
33
+			add_action('wp_ajax_save_cart_rule', array($this, 'wpshop_ajax_save_cart_rule'));
34
+			add_action('wp_ajax_delete_cart_rule', array($this, 'wpshop_ajax_delete_cart_rule'));
35 35
 		}
36 36
 
37 37
 		/**
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		 */
40 40
 		function admin_css() {
41 41
 			/** CSS Include **/
42
-			if ( is_admin() ) {
43
-				wp_register_style( 'wpshop_cart_rules_css', plugins_url('templates/backend/css/wpshop_cart_rules.css', __FILE__) );
44
-				wp_enqueue_style( 'wpshop_cart_rules_css' );
42
+			if (is_admin()) {
43
+				wp_register_style('wpshop_cart_rules_css', plugins_url('templates/backend/css/wpshop_cart_rules.css', __FILE__));
44
+				wp_enqueue_style('wpshop_cart_rules_css');
45 45
 			}
46 46
 		}
47 47
 
@@ -58,18 +58,18 @@  discard block
 block discarded – undo
58 58
 		function admin_js() {
59 59
 			/** JS Include **/
60 60
 			wp_enqueue_script("jquery");
61
-			if ( is_admin() ) {
62
-				wp_enqueue_script( 'wpshop_cart_rules', plugins_url('templates/backend/js/wpshop_cart_rules.js', __FILE__) );
61
+			if (is_admin()) {
62
+				wp_enqueue_script('wpshop_cart_rules', plugins_url('templates/backend/js/wpshop_cart_rules.js', __FILE__));
63 63
 			}
64 64
 		}
65 65
 
66 66
 		/** Load the module template **/
67
-		function custom_template_load( $templates ) {
67
+		function custom_template_load($templates) {
68 68
 			include('templates/backend/main_elements.tpl.php');
69 69
 
70
-			foreach ( $tpl_element as $template_part => $template_part_content) {
71
-				foreach ( $template_part_content as $template_type => $template_type_content) {
72
-					foreach ( $template_type_content as $template_key => $template) {
70
+			foreach ($tpl_element as $template_part => $template_part_content) {
71
+				foreach ($template_part_content as $template_type => $template_type_content) {
72
+					foreach ($template_type_content as $template_key => $template) {
73 73
 						$templates[$template_part][$template_type][$template_key] = $template;
74 74
 					}
75 75
 				}
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 		}
81 81
 
82 82
 		/** Declare options for this module **/
83
-		function declare_options () {
84
-			if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
85
-				$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
86
-				$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : '';
87
-
88
-				if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' )
89
-					&& ( $old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation' ) ) {
90
-						add_settings_section('wpshop_cart_rules_option', '<span class="dashicons dashicons-cart"></span>'.__('Cart Rules', 'wpshop'), array(&$this, 'cart_rules_section_text'), 'wpshop_cart_rules_option');
83
+		function declare_options() {
84
+			if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
85
+				$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
86
+				$old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : '';
87
+
88
+				if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation')
89
+					&& ($old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation')) {
90
+						add_settings_section('wpshop_cart_rules_option', '<span class="dashicons dashicons-cart"></span>' . __('Cart Rules', 'wpshop'), array(&$this, 'cart_rules_section_text'), 'wpshop_cart_rules_option');
91 91
 						register_setting('wpshop_options', 'wpshop_cart_rules_option', array(&$this, 'validate_cart_rules_options'));
92 92
 						add_settings_field('wpshop_cart_rules_option', __('Activate cart rules', 'wpshop'), array(&$this, 'wpshop_cart_rules_field'), 'wpshop_cart_rules_option', 'wpshop_cart_rules_option');
93 93
 
@@ -96,63 +96,63 @@  discard block
 block discarded – undo
96 96
 		}
97 97
 
98 98
 		/** Add a section for option display **/
99
-		function add_options( $option_group ) {
99
+		function add_options($option_group) {
100 100
 			$option_group['wpshop_cart_option']['subgroups']['wpshop_cart_rules_option']['class'] = ' wpshop_admin_box_options_cart_rules';
101 101
 			return $option_group;
102 102
 		}
103 103
 
104
-		function cart_rules_section_text () {
104
+		function cart_rules_section_text() {
105 105
 
106 106
 		}
107 107
 
108 108
 		/** Option cart rules configuuration interface **/
109
-		function wpshop_cart_rules_field () {
109
+		function wpshop_cart_rules_field() {
110 110
 			global $wpdb;
111 111
 			$cart_rules_options = get_option('wpshop_cart_rules_option');
112
-			$cart_rules = ( !empty($cart_rules_options) ) ? $cart_rules_options['rules'] : '';
112
+			$cart_rules = (!empty($cart_rules_options)) ? $cart_rules_options['rules'] : '';
113 113
 
114 114
 			$wpshop_customer_groups = get_option('wp_user_roles');
115 115
 
116
-			$tpl_component['CART_RULES_CUSTOMERS_GROUPS'] = '<option value="">' .__('All customers groups' , 'wpshop'). '</option>';
117
-			if ( !empty($wpshop_customer_groups) ) {
118
-				foreach ( $wpshop_customer_groups as $k =>  $wpshop_customer_group) {
119
-					$tpl_component['CART_RULES_CUSTOMERS_GROUPS'] .= '<option value="' .$k. '">' .$wpshop_customer_group['name']. '</option>';
116
+			$tpl_component['CART_RULES_CUSTOMERS_GROUPS'] = '<option value="">' . __('All customers groups', 'wpshop') . '</option>';
117
+			if (!empty($wpshop_customer_groups)) {
118
+				foreach ($wpshop_customer_groups as $k =>  $wpshop_customer_group) {
119
+					$tpl_component['CART_RULES_CUSTOMERS_GROUPS'] .= '<option value="' . $k . '">' . $wpshop_customer_group['name'] . '</option>';
120 120
 				}
121 121
 			}
122 122
 
123
-			$tpl_component['CART_RULES_DATA'] = ( !empty($cart_rules) ) ? $cart_rules : '';
124
-			$tpl_component['ACTIVE_CART_RULES'] = ( (!empty($cart_rules_options) && !empty($cart_rules_options['activate']) ) ? 'checked="checked"' : '');
123
+			$tpl_component['CART_RULES_DATA'] = (!empty($cart_rules)) ? $cart_rules : '';
124
+			$tpl_component['ACTIVE_CART_RULES'] = ((!empty($cart_rules_options) && !empty($cart_rules_options['activate'])) ? 'checked="checked"' : '');
125 125
 
126
-			$tpl_component['ALL_CART_RULES'] = (!empty($cart_rules) ) ? wpshop_cart_rules::display_cart_rules( $cart_rules ) : '';
126
+			$tpl_component['ALL_CART_RULES'] = (!empty($cart_rules)) ? wpshop_cart_rules::display_cart_rules($cart_rules) : '';
127 127
 			$tpl_component['MEDIAS_ICON_URL'] = WPSHOP_MEDIAS_ICON_URL;
128 128
 			/** Product list **/
129
-			$query = $wpdb->prepare('SELECT ID, post_title, post_type FROM '.$wpdb->posts.' WHERE (post_type = %s OR post_type = %s) AND (post_status = %s OR post_status = %s)', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'draft', 'publish');
129
+			$query = $wpdb->prepare('SELECT ID, post_title, post_type FROM ' . $wpdb->posts . ' WHERE (post_type = %s OR post_type = %s) AND (post_status = %s OR post_status = %s)', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'draft', 'publish');
130 130
 			$products = $wpdb->get_results($query);
131 131
 			$tpl_component['PRODUCTS_LIST_FOR_GIFT'] = '';
132
-			if ( !empty($products) ) {
133
-				foreach($products as $product) {
134
-					if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
135
-						$parent_product_infos = wpshop_products::get_parent_variation ( $product->ID );
136
-						if ( !empty($parent_product_infos) && !empty($parent_product_infos['parent_post']) ) {
132
+			if (!empty($products)) {
133
+				foreach ($products as $product) {
134
+					if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
135
+						$parent_product_infos = wpshop_products::get_parent_variation($product->ID);
136
+						if (!empty($parent_product_infos) && !empty($parent_product_infos['parent_post'])) {
137 137
 							$parent_post_infos = $parent_product_infos['parent_post'];
138 138
 							$product_title = $parent_post_infos->post_title;
139 139
 
140 140
 							$product_options = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true);
141
-							if ( !empty($product_options) && is_array($product_options) ) {
141
+							if (!empty($product_options) && is_array($product_options)) {
142 142
 								$option_name = '';
143
-								foreach( $product_options as $k=>$product_option) {
144
-									$query = $wpdb->prepare('SELECT frontend_label FROM '.WPSHOP_DBT_ATTRIBUTE.' WHERE code = %s', $k);
145
-									$option_name .= $wpdb->get_var($query).' ';
146
-									$query = $wpdb->prepare('SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id= %d', $product_option);
147
-									$option_name .=  $wpdb->get_var($query).' ';
143
+								foreach ($product_options as $k=>$product_option) {
144
+									$query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $k);
145
+									$option_name .= $wpdb->get_var($query) . ' ';
146
+									$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $product_option);
147
+									$option_name .= $wpdb->get_var($query) . ' ';
148 148
 								}
149
-								$tpl_component['PRODUCTS_LIST_FOR_GIFT'] .= '<option value="'.$product->ID. '" >'. $product_title .' (' .$option_name. ')</option>';
149
+								$tpl_component['PRODUCTS_LIST_FOR_GIFT'] .= '<option value="' . $product->ID . '" >' . $product_title . ' (' . $option_name . ')</option>';
150 150
 							}
151 151
 
152 152
 						}
153 153
 					}
154 154
 					else {
155
-						$tpl_component['PRODUCTS_LIST_FOR_GIFT'] .= '<option value="'.$product->ID. '" >' .$product->post_title. '</option>';
155
+						$tpl_component['PRODUCTS_LIST_FOR_GIFT'] .= '<option value="' . $product->ID . '" >' . $product->post_title . '</option>';
156 156
 					}
157 157
 				}
158 158
 			}
@@ -162,28 +162,28 @@  discard block
 block discarded – undo
162 162
 			echo $output;
163 163
 		}
164 164
 
165
-		function validate_cart_rules_options ($input) {
165
+		function validate_cart_rules_options($input) {
166 166
 			return $input;
167 167
 		}
168 168
 
169 169
 		/** Save the cart rule **/
170
-		function wpshop_ajax_save_cart_rule () {
171
-			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
170
+		function wpshop_ajax_save_cart_rule() {
171
+			$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
172 172
 
173
-			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_cart_rule' ) )
173
+			if (!wp_verify_nonce($_wpnonce, 'wpshop_ajax_save_cart_rule'))
174 174
 				wp_die();
175 175
 
176
-			$cart_limen = ( !empty($_POST['cart_limen']) ) ? wpshop_tools::varSanitizer($_POST['cart_limen']) : null;
177
-			$discount_type = ( !empty($_POST['discount_type']) ) ? wpshop_tools::varSanitizer($_POST['discount_type']) : null;
178
-			$discount_value = ( !empty($_POST['discount_value']) ) ? wpshop_tools::varSanitizer($_POST['discount_value']) : null;
176
+			$cart_limen = (!empty($_POST['cart_limen'])) ? wpshop_tools::varSanitizer($_POST['cart_limen']) : null;
177
+			$discount_type = (!empty($_POST['discount_type'])) ? wpshop_tools::varSanitizer($_POST['discount_type']) : null;
178
+			$discount_value = (!empty($_POST['discount_value'])) ? wpshop_tools::varSanitizer($_POST['discount_value']) : null;
179 179
 			$customer_groups = wpshop_tools::varSanitizer($_POST['customer_groups']);
180 180
 
181 181
 			$status = false;
182 182
 			$response = array();
183
-			$cart_rules = ( !empty($_POST['cart_rules']) ) ? sanitize_text_field( $_POST['cart_rules'] ) : null;
183
+			$cart_rules = (!empty($_POST['cart_rules'])) ? sanitize_text_field($_POST['cart_rules']) : null;
184 184
 
185
-			if ( !empty($cart_limen) && !empty($discount_type) && !empty($discount_value) ) {
186
-				if ( !empty($cart_rules) ) {
185
+			if (!empty($cart_limen) && !empty($discount_type) && !empty($discount_value)) {
186
+				if (!empty($cart_rules)) {
187 187
 					$cart_rules = unserialize(stripslashes($cart_rules));
188 188
 					$cart_rules[$cart_limen] = array('discount_type' => $discount_type, 'discount_value' => $discount_value, 'customer_group' => $customer_groups);
189 189
 
@@ -203,21 +203,21 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		/** Save the cart rule **/
206
-		function wpshop_ajax_delete_cart_rule () {
207
-			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
206
+		function wpshop_ajax_delete_cart_rule() {
207
+			$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
208 208
 
209
-			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_cart_rule' ) )
209
+			if (!wp_verify_nonce($_wpnonce, 'wpshop_ajax_delete_cart_rule'))
210 210
 				wp_die();
211 211
 
212
-			$cart_rule_id = ( !empty($_POST['cart_rule_id']) ) ? wpshop_tools::varSanitizer($_POST['cart_rule_id']) : null;
212
+			$cart_rule_id = (!empty($_POST['cart_rule_id'])) ? wpshop_tools::varSanitizer($_POST['cart_rule_id']) : null;
213 213
 
214 214
 			$status = false;
215 215
 			$response = array();
216
-			$cart_rules = ( !empty($_POST['cart_rules']) ) ? sanitize_text_field( $_POST['cart_rules'] ) : null;
216
+			$cart_rules = (!empty($_POST['cart_rules'])) ? sanitize_text_field($_POST['cart_rules']) : null;
217 217
 
218 218
 			$cart_rule_id = str_replace('_', '.', $cart_rule_id);
219 219
 
220
-			if ( !empty($cart_rule_id) ) {
220
+			if (!empty($cart_rule_id)) {
221 221
 				$cart_rules = unserialize(stripslashes($cart_rules));
222 222
 				unset($cart_rules[$cart_rule_id]);
223 223
 				$cart_rules = serialize($cart_rules);
@@ -232,42 +232,42 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 
234 234
 		/** Display all cart rules **/
235
-		function display_cart_rules( $rules ) {
235
+		function display_cart_rules($rules) {
236 236
 			global $wpdb;
237 237
 			$output = '';
238
-			if ( !empty($rules) ) {
238
+			if (!empty($rules)) {
239 239
 				$tpl_component['MEDIAS_ICON_URL'] = WPSHOP_MEDIAS_ICON_URL;
240 240
 				$tpl_component['CART_RULES_LINE'] = '';
241
-				foreach( unserialize($rules) as $k => $rule ) {
241
+				foreach (unserialize($rules) as $k => $rule) {
242 242
 					$sub_tpl_component['CART_RULE_LINE_CART_LIMEN'] = $k;
243 243
 					switch ($rule['discount_type']) {
244 244
 						case 'absolute_discount' :
245 245
 							$discount_type = __('Absolute discount', 'wpshop');
246
-							$discount_value = $rule['discount_value'].' '.wpshop_tools::wpshop_get_currency();
246
+							$discount_value = $rule['discount_value'] . ' ' . wpshop_tools::wpshop_get_currency();
247 247
 						break;
248 248
 						case 'percent_discount' :
249 249
 							$discount_type = __('Percent discount', 'wpshop');
250
-							$discount_value = $rule['discount_value'].' %';
250
+							$discount_value = $rule['discount_value'] . ' %';
251 251
 						break;
252 252
 						case 'gift_product' :
253 253
 							$discount_type = __('Product gift', 'wpshop');
254
-							$product = get_post( $rule['discount_value'] );
255
-							if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
256
-								$parent_product_infos = wpshop_products::get_parent_variation ( $product->ID );
257
-								if ( !empty($parent_product_infos) && !empty($parent_product_infos['parent_post']) ) {
254
+							$product = get_post($rule['discount_value']);
255
+							if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
256
+								$parent_product_infos = wpshop_products::get_parent_variation($product->ID);
257
+								if (!empty($parent_product_infos) && !empty($parent_product_infos['parent_post'])) {
258 258
 									$parent_post_infos = $parent_product_infos['parent_post'];
259 259
 									$product_title = $parent_post_infos->post_title;
260 260
 
261 261
 									$product_options = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true);
262
-									if ( !empty($product_options) && is_array($product_options) ) {
262
+									if (!empty($product_options) && is_array($product_options)) {
263 263
 										$option_name = '';
264
-										foreach( $product_options as $k=>$product_option) {
265
-											$query = $wpdb->prepare('SELECT frontend_label FROM '.WPSHOP_DBT_ATTRIBUTE.' WHERE code = %s', $k);
266
-											$option_name .= $wpdb->get_var($query).' ';
267
-											$query = $wpdb->prepare('SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id= %d', $product_option);
268
-											$option_name .=  $wpdb->get_var($query).' ';
264
+										foreach ($product_options as $k=>$product_option) {
265
+											$query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $k);
266
+											$option_name .= $wpdb->get_var($query) . ' ';
267
+											$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $product_option);
268
+											$option_name .= $wpdb->get_var($query) . ' ';
269 269
 										}
270
-										$discount_value = $product_title .' (' .$option_name. ')';
270
+										$discount_value = $product_title . ' (' . $option_name . ')';
271 271
 									}
272 272
 
273 273
 								}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 					}
284 284
 					$sub_tpl_component['CART_RULE_LINE_DISCOUNT_TYPE'] = $discount_type;
285 285
 					$sub_tpl_component['CART_RULE_LINE_DISCOUNT_VALUE'] = $discount_value;
286
-					$sub_tpl_component['CART_RULE_LINE_CUSTOMER_GROUP'] = (!empty($rule['customer_group']) ) ? $rule['customer_group'] : __('All customers groups', 'wpshop');
286
+					$sub_tpl_component['CART_RULE_LINE_CUSTOMER_GROUP'] = (!empty($rule['customer_group'])) ? $rule['customer_group'] : __('All customers groups', 'wpshop');
287 287
 					$sub_tpl_component['CART_RULE_ID'] = str_replace('.', '_', $sub_tpl_component['CART_RULE_LINE_CART_LIMEN']);
288 288
 					$sub_tpl_component['MEDIAS_ICON_URL'] = WPSHOP_MEDIAS_ICON_URL;
289 289
 					$tpl_component['CART_RULES_LINE'] .= wpshop_display::display_template_element('cart_rules_line', $sub_tpl_component, array(), 'admin');
@@ -299,31 +299,31 @@  discard block
 block discarded – undo
299 299
 		 * @param integer_type $cart_amount
300 300
 		 * @return array
301 301
 		 */
302
-		function get_cart_rule ($cart_amount) {
302
+		function get_cart_rule($cart_amount) {
303 303
 			$cart_rule_info = array();
304 304
 			$cart_rule_exist = false;
305
-			if ( !empty($cart_amount) ) {
305
+			if (!empty($cart_amount)) {
306 306
 				$cart_rules_option = get_option('wpshop_cart_rules_option');
307
-				if ( !empty($cart_rules_option) && !empty($cart_rules_option['activate']) && !empty($cart_rules_option['rules']) ) {
307
+				if (!empty($cart_rules_option) && !empty($cart_rules_option['activate']) && !empty($cart_rules_option['rules'])) {
308 308
 					$cart_rules = unserialize($cart_rules_option['rules']);
309
-					if ( is_array($cart_rules) ) {
309
+					if (is_array($cart_rules)) {
310 310
 						$cart_rule_id = 0;
311
-						foreach( $cart_rules as $k => $cart_rule ) {
312
-							if ( $cart_amount >= $k ) {
311
+						foreach ($cart_rules as $k => $cart_rule) {
312
+							if ($cart_amount >= $k) {
313 313
 								$cart_rule_id = $k;
314
-								if ( $cart_rule_id != 0 ) {
314
+								if ($cart_rule_id != 0) {
315 315
 									/** Check if there is a customer group limit **/
316
-									if ( empty($cart_rules[$cart_rule_id]['customer_group']) ) {
316
+									if (empty($cart_rules[$cart_rule_id]['customer_group'])) {
317 317
 										$cart_rule_exist = true;
318 318
 										$cart_rule_info['discount_type'] = $cart_rules[$cart_rule_id]['discount_type'];
319 319
 										$cart_rule_info['discount_value'] = $cart_rules[$cart_rule_id]['discount_value'];
320 320
 									}
321 321
 									else {
322
-										if ( get_current_user_id() != 0 ) {
323
-											$user_meta = get_user_meta( get_current_user_id(), 'wp_capabilities', true );
324
-											if ( !empty($user_meta)  ) {
322
+										if (get_current_user_id() != 0) {
323
+											$user_meta = get_user_meta(get_current_user_id(), 'wp_capabilities', true);
324
+											if (!empty($user_meta)) {
325 325
 												foreach ($user_meta as $k => $user) {
326
-													if ( $k == $cart_rules[$cart_rule_id]['customer_group'] ) {
326
+													if ($k == $cart_rules[$cart_rule_id]['customer_group']) {
327 327
 														$cart_rule_exist = true;
328 328
 														$cart_rule_info['discount_type'] = $cart_rules[$cart_rule_id]['discount_type'];
329 329
 														$cart_rule_info['discount_value'] = $cart_rules[$cart_rule_id]['discount_value'];
@@ -342,27 +342,27 @@  discard block
 block discarded – undo
342 342
 			return array('cart_rule_exist' => $cart_rule_exist, 'cart_rule_info' => $cart_rule_info);
343 343
 		}
344 344
 
345
-		function add_gift_product_to_cart ( $cartContent, $order ) {
345
+		function add_gift_product_to_cart($cartContent, $order) {
346 346
 			global $wpdb;
347
-			if ( !empty($order['cart_rule']) && !empty($order['cart_rule']['discount_value']) && !empty($order['cart_rule']['discount_type']) &&  $order['cart_rule']['discount_type'] == 'gift_product') {
348
-				$product = get_post( $order['cart_rule']['discount_value'] );
347
+			if (!empty($order['cart_rule']) && !empty($order['cart_rule']['discount_value']) && !empty($order['cart_rule']['discount_type']) && $order['cart_rule']['discount_type'] == 'gift_product') {
348
+				$product = get_post($order['cart_rule']['discount_value']);
349 349
 				$option_name = '';
350
-				if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
351
-					$parent_product_infos = wpshop_products::get_parent_variation ( $product->ID );
352
-					if ( !empty($parent_product_infos) && !empty($parent_product_infos['parent_post']) ) {
350
+				if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
351
+					$parent_product_infos = wpshop_products::get_parent_variation($product->ID);
352
+					if (!empty($parent_product_infos) && !empty($parent_product_infos['parent_post'])) {
353 353
 						$parent_post_infos = $parent_product_infos['parent_post'];
354 354
 						$product_title = $parent_post_infos->post_title;
355 355
 
356 356
 						$product_options = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true);
357
-						if ( !empty($product_options) && is_array($product_options) ) {
357
+						if (!empty($product_options) && is_array($product_options)) {
358 358
 							$option_name = '';
359
-							foreach( $product_options as $k=>$product_option) {
360
-								$query = $wpdb->prepare('SELECT frontend_label FROM '.WPSHOP_DBT_ATTRIBUTE.' WHERE code = %s', $k);
361
-								$option_name .= $wpdb->get_var($query).' ';
362
-								$query = $wpdb->prepare('SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id= %d', $product_option);
363
-								$option_name .=  $wpdb->get_var($query).' ';
359
+							foreach ($product_options as $k=>$product_option) {
360
+								$query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $k);
361
+								$option_name .= $wpdb->get_var($query) . ' ';
362
+								$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $product_option);
363
+								$option_name .= $wpdb->get_var($query) . ' ';
364 364
 							}
365
-							$discount_value = $product_title ;
365
+							$discount_value = $product_title;
366 366
 						}
367 367
 
368 368
 					}
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
 				$tpl_component['CART_LINE_ITEM_QTY_'] = 1;
382 382
 				$tpl_component['CART_LINE_ITEM_REMOVER'] = '';
383
-				$tpl_component['CART_PRODUCT_NAME'] = $discount_value .' ('.__('Gift product', 'wpshop').')';
383
+				$tpl_component['CART_PRODUCT_NAME'] = $discount_value . ' (' . __('Gift product', 'wpshop') . ')';
384 384
 
385 385
 
386 386
 				$cartContent .= wpshop_display::display_template_element('cart_line', $tpl_component);
@@ -391,6 +391,6 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 }
393 393
 /**	Instanciate the module utilities if not	*/
394
-if ( class_exists("wpshop_cart_rules") ) {
394
+if (class_exists("wpshop_cart_rules")) {
395 395
 	$wpshop_cart_rules = new wpshop_cart_rules();
396 396
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /**
4 6
  * Cart rules bootstrap file
@@ -150,8 +152,7 @@  discard block
 block discarded – undo
150 152
 							}
151 153
 
152 154
 						}
153
-					}
154
-					else {
155
+					} else {
155 156
 						$tpl_component['PRODUCTS_LIST_FOR_GIFT'] .= '<option value="'.$product->ID. '" >' .$product->post_title. '</option>';
156 157
 					}
157 158
 				}
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
 		function wpshop_ajax_save_cart_rule () {
171 172
 			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
172 173
 
173
-			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_cart_rule' ) )
174
-				wp_die();
174
+			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_save_cart_rule' ) ) {
175
+							wp_die();
176
+			}
175 177
 
176 178
 			$cart_limen = ( !empty($_POST['cart_limen']) ) ? wpshop_tools::varSanitizer($_POST['cart_limen']) : null;
177 179
 			$discount_type = ( !empty($_POST['discount_type']) ) ? wpshop_tools::varSanitizer($_POST['discount_type']) : null;
@@ -187,8 +189,7 @@  discard block
 block discarded – undo
187 189
 					$cart_rules = unserialize(stripslashes($cart_rules));
188 190
 					$cart_rules[$cart_limen] = array('discount_type' => $discount_type, 'discount_value' => $discount_value, 'customer_group' => $customer_groups);
189 191
 
190
-				}
191
-				else {
192
+				} else {
192 193
 					$cart_rules = array();
193 194
 					$cart_rules[$cart_limen] = array('discount_type' => $discount_type, 'discount_value' => $discount_value, 'customer_group' => $customer_groups);
194 195
 				}
@@ -206,8 +207,9 @@  discard block
 block discarded – undo
206 207
 		function wpshop_ajax_delete_cart_rule () {
207 208
 			$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
208 209
 
209
-			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_cart_rule' ) )
210
-				wp_die();
210
+			if ( !wp_verify_nonce( $_wpnonce, 'wpshop_ajax_delete_cart_rule' ) ) {
211
+							wp_die();
212
+			}
211 213
 
212 214
 			$cart_rule_id = ( !empty($_POST['cart_rule_id']) ) ? wpshop_tools::varSanitizer($_POST['cart_rule_id']) : null;
213 215
 
@@ -271,8 +273,7 @@  discard block
 block discarded – undo
271 273
 									}
272 274
 
273 275
 								}
274
-							}
275
-							else {
276
+							} else {
276 277
 								$discount_value = $product->post_title;
277 278
 							}
278 279
 						break;
@@ -317,8 +318,7 @@  discard block
 block discarded – undo
317 318
 										$cart_rule_exist = true;
318 319
 										$cart_rule_info['discount_type'] = $cart_rules[$cart_rule_id]['discount_type'];
319 320
 										$cart_rule_info['discount_value'] = $cart_rules[$cart_rule_id]['discount_value'];
320
-									}
321
-									else {
321
+									} else {
322 322
 										if ( get_current_user_id() != 0 ) {
323 323
 											$user_meta = get_user_meta( get_current_user_id(), 'wp_capabilities', true );
324 324
 											if ( !empty($user_meta)  ) {
@@ -366,8 +366,7 @@  discard block
 block discarded – undo
366 366
 						}
367 367
 
368 368
 					}
369
-				}
370
-				else {
369
+				} else {
371 370
 					$discount_value = $product->post_title;
372 371
 				}
373 372
 
Please login to merge, or discard this patch.
modules/wps_shipping/templates/frontend/shipping-mode-container.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
2
- do_action( 'wpshop_account_custom_hook'); ?>
1
+<?php if (!defined('ABSPATH')) exit;
2
+ do_action('wpshop_account_custom_hook'); ?>
3 3
 <div class="wps-gridwrapper">
4
-	<span class="wps-h3"><?php _e( 'Shipping method', 'wpshop'); ?></span>
4
+	<span class="wps-h3"><?php _e('Shipping method', 'wpshop'); ?></span>
5 5
 </div>
6 6
 <div>
7
-	<?php if( $no_shipping_mode_for_area ) : ?>
8
-		<div class="wps-alert-error"><?php _e( 'Sorry ! You can\'t order on this shop, because we don\'t ship in your area', 'wpshop' ); ?>	</div>
7
+	<?php if ($no_shipping_mode_for_area) : ?>
8
+		<div class="wps-alert-error"><?php _e('Sorry ! You can\'t order on this shop, because we don\'t ship in your area', 'wpshop'); ?>	</div>
9 9
 	<?php else : ?>
10
-		<?php if( !empty($shipping_modes) && !empty($shipping_modes['modes']) ) : ?>
11
-		<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce( 'wps_load_shipping_methods' ); ?>">
10
+		<?php if (!empty($shipping_modes) && !empty($shipping_modes['modes'])) : ?>
11
+		<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce('wps_load_shipping_methods'); ?>">
12 12
 			<?php
13 13
 			$i = 0;
14
-			foreach( $shipping_modes['modes'] as $shipping_mode_id => $shipping_mode ) :
15
-				require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-mode", "element") );
14
+			foreach ($shipping_modes['modes'] as $shipping_mode_id => $shipping_mode) :
15
+				require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-mode", "element"));
16 16
 			endforeach;
17 17
 
18 18
 			?>
19 19
 		</ul>
20 20
 		<?php else : ?>
21
-		<div class="wps-alert-info"><?php _e( 'No shipping mode available', 'wpshop' ); ?>	</div>
21
+		<div class="wps-alert-info"><?php _e('No shipping mode available', 'wpshop'); ?>	</div>
22 22
 		<?php endif; ?>
23 23
 	<?php endif; ?>
24 24
 </div>
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
  do_action( 'wpshop_account_custom_hook'); ?>
3 5
 <div class="wps-gridwrapper">
4 6
 	<span class="wps-h3"><?php _e( 'Shipping method', 'wpshop'); ?></span>
@@ -6,9 +8,12 @@  discard block
 block discarded – undo
6 8
 <div>
7 9
 	<?php if( $no_shipping_mode_for_area ) : ?>
8 10
 		<div class="wps-alert-error"><?php _e( 'Sorry ! You can\'t order on this shop, because we don\'t ship in your area', 'wpshop' ); ?>	</div>
9
-	<?php else : ?>
11
+	<?php else {
12
+	: ?>
10 13
 		<?php if( !empty($shipping_modes) && !empty($shipping_modes['modes']) ) : ?>
11
-		<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce( 'wps_load_shipping_methods' ); ?>">
14
+		<ul class="wps-itemList" id="wps-shipping-method-list-container" data-nonce="<?php echo wp_create_nonce( 'wps_load_shipping_methods' );
15
+}
16
+?>">
12 17
 			<?php
13 18
 			$i = 0;
14 19
 			foreach( $shipping_modes['modes'] as $shipping_mode_id => $shipping_mode ) :
@@ -17,8 +22,11 @@  discard block
 block discarded – undo
17 22
 
18 23
 			?>
19 24
 		</ul>
20
-		<?php else : ?>
21
-		<div class="wps-alert-info"><?php _e( 'No shipping mode available', 'wpshop' ); ?>	</div>
25
+		<?php else {
26
+	: ?>
27
+		<div class="wps-alert-info"><?php _e( 'No shipping mode available', 'wpshop' );
28
+}
29
+?>	</div>
22 30
 		<?php endif; ?>
23 31
 	<?php endif; ?>
24 32
 </div>
Please login to merge, or discard this patch.