@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * Return a variable with some basic treatment |
96 | 96 | * |
97 | 97 | * @param mixed $varToSanitize The variable we want to treat for future use |
98 | - * @param mixed $varDefaultValue The default value to set to the variable if the different test are not successfull |
|
98 | + * @param string $varDefaultValue The default value to set to the variable if the different test are not successfull |
|
99 | 99 | * @param string $varType optionnal The type of the var for better verification |
100 | 100 | * |
101 | 101 | * @return mixed $sanitizedVar The var after treatment |
@@ -223,6 +223,7 @@ discard block |
||
223 | 223 | * Return unit sigle |
224 | 224 | * @param unknown_type $code |
225 | 225 | * @param unknown_type $column_to_return |
226 | + * @return string |
|
226 | 227 | */ |
227 | 228 | public static function wpshop_get_sigle($code, $column_to_return = "unit") { |
228 | 229 | $tmp_code = (int)$code; |
@@ -253,7 +254,7 @@ discard block |
||
253 | 254 | /** |
254 | 255 | * Check if string have phone number structure |
255 | 256 | * @param string phone number |
256 | - * @return boolean |
|
257 | + * @return integer |
|
257 | 258 | */ |
258 | 259 | public static function is_phone( $phone ) { |
259 | 260 | return preg_match( '/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone ); |
@@ -262,7 +263,7 @@ discard block |
||
262 | 263 | /** |
263 | 264 | * Check if string have postcode valid structure |
264 | 265 | * @param string postcode |
265 | - * @return boolean |
|
266 | + * @return integer |
|
266 | 267 | */ |
267 | 268 | public static function is_postcode( $postcode ) { |
268 | 269 | return preg_match( '/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode ); |
@@ -321,7 +322,7 @@ discard block |
||
321 | 322 | * Transform a given text with a specific pattern, send by the second parameter |
322 | 323 | * |
323 | 324 | * @param string $toSlugify The string we want to "clean" for future use |
324 | - * @param array|string $slugifyType The type of cleaning we are going to do on the input text |
|
325 | + * @param string[] $slugifyType The type of cleaning we are going to do on the input text |
|
325 | 326 | * |
326 | 327 | * @return string $slugified The input string that was slugified with the selected method |
327 | 328 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Main controller file for product mass modification module |
4 | 4 | * |
@@ -30,56 +30,56 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string The template file path to use |
32 | 32 | */ |
33 | - public static function get_template_part( $plugin_dir_name, $main_template_dir, $side, $slug, $name=null, $debug = null ) { |
|
33 | + public static function get_template_part($plugin_dir_name, $main_template_dir, $side, $slug, $name = null, $debug = null) { |
|
34 | 34 | $path = ''; |
35 | 35 | |
36 | 36 | $templates = array(); |
37 | 37 | $name = (string)$name; |
38 | - if ( '' !== $name ) |
|
38 | + if ('' !== $name) |
|
39 | 39 | $templates[] = "{$side}/{$slug}-{$name}.php"; |
40 | 40 | $templates[] = "{$side}/{$slug}.php"; |
41 | 41 | |
42 | 42 | /** Check if required template exists into current theme */ |
43 | 43 | $check_theme_template = array(); |
44 | - foreach ( $templates as $template ) { |
|
44 | + foreach ($templates as $template) { |
|
45 | 45 | $check_theme_template = $plugin_dir_name . "/" . $template; |
46 | - $path = locate_template( $check_theme_template, false ); |
|
47 | - if( !empty($path) ) { |
|
46 | + $path = locate_template($check_theme_template, false); |
|
47 | + if (!empty($path)) { |
|
48 | 48 | break; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** Allow debugging */ |
53 | - if ( !empty( $debug ) ) { |
|
53 | + if (!empty($debug)) { |
|
54 | 54 | echo '--- Debug mode ON - Start ---<br/>'; |
55 | 55 | echo __FILE__ . '<br/>'; |
56 | 56 | echo 'Debug for display method<br/>'; |
57 | 57 | echo 'Asked path ' . $path . '<br/>'; |
58 | 58 | } |
59 | 59 | |
60 | - if ( empty( $path ) ) { |
|
61 | - foreach ( (array) $templates as $template_name ) { |
|
62 | - if ( !$template_name ) |
|
60 | + if (empty($path)) { |
|
61 | + foreach ((array)$templates as $template_name) { |
|
62 | + if (!$template_name) |
|
63 | 63 | continue; |
64 | 64 | |
65 | - if ( !empty( $debug ) ) { |
|
65 | + if (!empty($debug)) { |
|
66 | 66 | echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>'; |
67 | 67 | } |
68 | 68 | |
69 | - $file_exists = file_exists( $main_template_dir . $template_name ); |
|
70 | - if ( $file_exists ) { |
|
69 | + $file_exists = file_exists($main_template_dir . $template_name); |
|
70 | + if ($file_exists) { |
|
71 | 71 | $path = $main_template_dir . $template_name; |
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | - if ( !empty( $debug ) ) { |
|
75 | + if (!empty($debug)) { |
|
76 | 76 | echo __LINE__ . ' - ' . (bool)$file_exists . '<hr/>'; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** Allow debugging */ |
82 | - if ( !empty( $debug ) ) { |
|
82 | + if (!empty($debug)) { |
|
83 | 83 | echo '--- Debug mode ON - END ---<br/><br/>'; |
84 | 84 | } |
85 | 85 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return mixed $sanitizedVar The var after treatment |
104 | 104 | */ |
105 | 105 | public static function varSanitizer($varToSanitize, $varDefaultValue = '', $varType = '') { |
106 | - $sanitizedVar = is_string( $varToSanitize ) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue ; |
|
106 | + $sanitizedVar = is_string($varToSanitize) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue; |
|
107 | 107 | |
108 | 108 | return $sanitizedVar; |
109 | 109 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | public static function forceDownload($Fichier_a_telecharger, $delete_after_download = false) { |
117 | 117 | |
118 | 118 | $nom_fichier = basename($Fichier_a_telecharger); |
119 | - switch(strrchr($nom_fichier, ".")) { |
|
119 | + switch (strrchr($nom_fichier, ".")) { |
|
120 | 120 | case ".gz": $type = "application/x-gzip"; break; |
121 | 121 | case ".tgz": $type = "application/x-gzip"; break; |
122 | 122 | case ".zip": $type = "application/zip"; break; |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | header("Content-disposition: attachment; filename=$nom_fichier"); |
134 | 134 | header("Content-Type: application/force-download"); |
135 | 135 | header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n |
136 | - header("Content-Length: ".filesize($Fichier_a_telecharger)); |
|
136 | + header("Content-Length: " . filesize($Fichier_a_telecharger)); |
|
137 | 137 | header("Pragma: no-cache"); |
138 | 138 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); |
139 | 139 | header("Expires: 0"); |
140 | 140 | ob_end_clean(); |
141 | 141 | readfile($Fichier_a_telecharger); |
142 | - if ( $delete_after_download ) { |
|
143 | - unlink( $Fichier_a_telecharger ); |
|
142 | + if ($delete_after_download) { |
|
143 | + unlink($Fichier_a_telecharger); |
|
144 | 144 | } |
145 | 145 | exit; |
146 | 146 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | 152 | public static function is_sendsms_actived() { |
153 | - if(is_plugin_active('wordpress-send-sms/Send-SMS.php')) { |
|
153 | + if (is_plugin_active('wordpress-send-sms/Send-SMS.php')) { |
|
154 | 154 | $configOption = get_option('sendsms_config', ''); |
155 | 155 | $ligne = unserialize($configOption); |
156 | 156 | $nicOVH = $ligne['nicOVH']; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param unknown_type $input |
168 | 168 | * @return Ambigous <multitype:, multitype:multitype:unknown > |
169 | 169 | */ |
170 | - public static function search_all_possibilities( $input ) { |
|
170 | + public static function search_all_possibilities($input) { |
|
171 | 171 | $result = array(); |
172 | 172 | |
173 | 173 | while (list($key, $values) = each($input)) { |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | if (empty($result)) { |
179 | - foreach($values as $value) { |
|
179 | + foreach ($values as $value) { |
|
180 | 180 | $result[] = array($key => $value); |
181 | 181 | } |
182 | 182 | } |
183 | 183 | else { |
184 | 184 | $append = array(); |
185 | - foreach($result as &$product) { |
|
185 | + foreach ($result as &$product) { |
|
186 | 186 | $product[$key] = array_shift($values); |
187 | 187 | $copy = $product; |
188 | 188 | |
189 | - foreach($values as $item) { |
|
189 | + foreach ($values as $item) { |
|
190 | 190 | $copy[$key] = $item; |
191 | 191 | $append[] = $copy; |
192 | 192 | } |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | * @param boolean $code : false return sigle, true return code (€ or EUR) |
207 | 207 | * @return string currency code or sigle |
208 | 208 | */ |
209 | - public static function wpshop_get_currency($code=false) { |
|
209 | + public static function wpshop_get_currency($code = false) { |
|
210 | 210 | // Currency |
211 | - if( is_null( self::$currency_cache ) ) { |
|
211 | + if (is_null(self::$currency_cache)) { |
|
212 | 212 | global $wpdb; |
213 | 213 | $current_currency = get_option('wpshop_shop_default_currency'); |
214 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency ); |
|
215 | - self::$currency_cache = $wpdb->get_row( $query ); |
|
214 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency); |
|
215 | + self::$currency_cache = $wpdb->get_row($query); |
|
216 | 216 | } |
217 | - if ( !empty(self::$currency_cache) ) { |
|
218 | - $code = ($code) ? self::$currency_cache->name : self::$currency_cache->unit; |
|
217 | + if (!empty(self::$currency_cache)) { |
|
218 | + $code = ($code) ? self::$currency_cache->name : self::$currency_cache->unit; |
|
219 | 219 | return $code; |
220 | 220 | } |
221 | 221 | else { |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | public static function wpshop_get_sigle($code, $column_to_return = "unit") { |
232 | 232 | $tmp_code = (int)$code; |
233 | 233 | $key_to_get = 'name'; |
234 | - if ( is_int($tmp_code) && !empty($tmp_code) ) { |
|
234 | + if (is_int($tmp_code) && !empty($tmp_code)) { |
|
235 | 235 | $key_to_get = 'id'; |
236 | 236 | } |
237 | 237 | $old_way_currencies = unserialize(WPSHOP_SHOP_CURRENCIES); |
238 | - if ( array_key_exists( $code, $old_way_currencies)) { |
|
238 | + if (array_key_exists($code, $old_way_currencies)) { |
|
239 | 239 | $code = $old_way_currencies[$code]; |
240 | 240 | $key_to_get = 'name'; |
241 | 241 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param string $var : variable to clean |
251 | 251 | * @return string |
252 | 252 | */ |
253 | - public static function wpshop_clean( $var ) { |
|
253 | + public static function wpshop_clean($var) { |
|
254 | 254 | return trim(strip_tags(stripslashes($var))); |
255 | 255 | } |
256 | 256 | |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @param string phone number |
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | - public static function is_phone( $phone ) { |
|
263 | - return preg_match( '/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone ); |
|
262 | + public static function is_phone($phone) { |
|
263 | + return preg_match('/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param string postcode |
269 | 269 | * @return boolean |
270 | 270 | */ |
271 | - public static function is_postcode( $postcode ) { |
|
272 | - return preg_match( '/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode ); |
|
271 | + public static function is_postcode($postcode) { |
|
272 | + return preg_match('/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -279,14 +279,14 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return string $type The form input type to use for the given field |
281 | 281 | */ |
282 | - public static function defineFieldType($dataFieldType, $input_type, $frontend_verification){ |
|
282 | + public static function defineFieldType($dataFieldType, $input_type, $frontend_verification) { |
|
283 | 283 | $type = 'text'; |
284 | 284 | |
285 | - if ( $dataFieldType == 'datetime' ) { |
|
285 | + if ($dataFieldType == 'datetime') { |
|
286 | 286 | $type = 'text'; |
287 | 287 | } |
288 | 288 | else { |
289 | - switch ( $frontend_verification ) { |
|
289 | + switch ($frontend_verification) { |
|
290 | 290 | case 'phone': |
291 | 291 | $type = 'tel'; |
292 | 292 | break; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return array The different element send by request method |
308 | 308 | */ |
309 | - public static function getMethode(){ |
|
309 | + public static function getMethode() { |
|
310 | 310 | $request_method = null; |
311 | 311 | if ($_SERVER["REQUEST_METHOD"] == "GET") { |
312 | 312 | $request_method = (array)$_GET; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $request_method = (array)$_POST; |
316 | 316 | } |
317 | 317 | |
318 | - if ( null === $request_method ) { |
|
318 | + if (null === $request_method) { |
|
319 | 319 | die ('Invalid REQUEST_METHOD (not GET, not POST).'); |
320 | 320 | } |
321 | 321 | else { |
@@ -331,36 +331,36 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return string $slugified The input string that was slugified with the selected method |
333 | 333 | */ |
334 | - public static function slugify($toSlugify, $slugifyType){ |
|
334 | + public static function slugify($toSlugify, $slugifyType) { |
|
335 | 335 | $slugified = ''; |
336 | 336 | |
337 | - if($toSlugify != '') |
|
337 | + if ($toSlugify != '') |
|
338 | 338 | { |
339 | 339 | $slugified = $toSlugify; |
340 | - foreach($slugifyType as $type) |
|
340 | + foreach ($slugifyType as $type) |
|
341 | 341 | { |
342 | - if($type == 'noAccent') |
|
342 | + if ($type == 'noAccent') |
|
343 | 343 | { |
344 | - $pattern = array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/û/", "/ô/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ö/", "/Ù/", "/Û/", "/Ü/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/"); |
|
345 | - $rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U"); |
|
344 | + $pattern = array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/û/", "/ô/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ö/", "/Ù/", "/Û/", "/Ü/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/"); |
|
345 | + $rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U", "e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U"); |
|
346 | 346 | } |
347 | - elseif($type == 'noSpaces') |
|
347 | + elseif ($type == 'noSpaces') |
|
348 | 348 | { |
349 | 349 | $pattern = array('/\s/'); |
350 | 350 | $rep_pat = array('_'); |
351 | 351 | $slugified = trim($slugified); |
352 | 352 | } |
353 | - elseif($type == 'lowerCase') |
|
353 | + elseif ($type == 'lowerCase') |
|
354 | 354 | { |
355 | 355 | $slugified = strtolower($slugified); |
356 | 356 | } |
357 | - elseif($type == 'noPunctuation') |
|
357 | + elseif ($type == 'noPunctuation') |
|
358 | 358 | { |
359 | 359 | $pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//"); |
360 | 360 | $rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_"); |
361 | 361 | } |
362 | 362 | |
363 | - if(is_array($pattern) && is_array($rep_pat)) |
|
363 | + if (is_array($pattern) && is_array($rep_pat)) |
|
364 | 364 | { |
365 | 365 | $slugified = preg_replace($pattern, $rep_pat, utf8_decode($slugified)); |
366 | 366 | } |
@@ -379,17 +379,17 @@ discard block |
||
379 | 379 | * @return string $string The output string that was trunk if necessary |
380 | 380 | */ |
381 | 381 | public static function trunk($string, $maxlength) { |
382 | - if(strlen($string)>$maxlength+3) |
|
383 | - return substr($string,0,$maxlength).'...'; |
|
382 | + if (strlen($string) > $maxlength + 3) |
|
383 | + return substr($string, 0, $maxlength) . '...'; |
|
384 | 384 | else return $string; |
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Run a safe redirect in javascript |
389 | 389 | */ |
390 | - public static function wpshop_safe_redirect($url='') { |
|
391 | - $url = empty($url) ? admin_url('admin.php?page='.WPSHOP_URL_SLUG_DASHBOARD) : $url; |
|
392 | - echo '<script type="text/javascript">window.top.location.href = "'.$url.'"</script>'; |
|
390 | + public static function wpshop_safe_redirect($url = '') { |
|
391 | + $url = empty($url) ? admin_url('admin.php?page=' . WPSHOP_URL_SLUG_DASHBOARD) : $url; |
|
392 | + echo '<script type="text/javascript">window.top.location.href = "' . $url . '"</script>'; |
|
393 | 393 | exit; |
394 | 394 | } |
395 | 395 | |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param array $args : Hook arguments |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public static function create_custom_hook ($hook_name, $args = '') { |
|
402 | + public static function create_custom_hook($hook_name, $args = '') { |
|
403 | 403 | ob_start(); |
404 | - if ( !empty($args) ) { |
|
404 | + if (!empty($args)) { |
|
405 | 405 | do_action($hook_name, $args); |
406 | 406 | } |
407 | 407 | else { |
@@ -420,16 +420,16 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) { |
422 | 422 | $code = ''; |
423 | - if ( !function_exists( 'get_plugin_data') ) |
|
424 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
425 | - $plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' ); |
|
423 | + if (!function_exists('get_plugin_data')) |
|
424 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
425 | + $plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php'); |
|
426 | 426 | $code_part = array(); |
427 | - $code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5); |
|
428 | - $code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5); |
|
429 | - $code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5); |
|
427 | + $code_part[] = substr(hash("sha256", $plugin_name), WPSHOP_ADDONS_KEY_IS, 5); |
|
428 | + $code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5); |
|
429 | + $code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5); |
|
430 | 430 | $code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0]; |
431 | 431 | $att = $encrypt_base_attribute; |
432 | - $code .= '-' . substr(hash ( "sha256" , $att ), WPSHOP_ADDONS_KEY_IS, 5); |
|
432 | + $code .= '-' . substr(hash("sha256", $att), WPSHOP_ADDONS_KEY_IS, 5); |
|
433 | 433 | |
434 | 434 | return $code; |
435 | 435 | } |
@@ -440,15 +440,15 @@ discard block |
||
440 | 440 | * @param string $encrypt_base_attribute |
441 | 441 | * @return boolean |
442 | 442 | */ |
443 | - public static function check_plugin_activation_code( $plugin_name, $encrypt_base_attribute, $from = 'file') { |
|
443 | + public static function check_plugin_activation_code($plugin_name, $encrypt_base_attribute, $from = 'file') { |
|
444 | 444 | $is_valid = false; |
445 | 445 | $valid_activation_code = self::get_plugin_validation_code($plugin_name, $encrypt_base_attribute); |
446 | - $activation_code_filename = WP_PLUGIN_DIR .'/'. $plugin_name.'/encoder.txt'; |
|
447 | - if ( is_file($activation_code_filename) ) { |
|
448 | - $activation_code_file = fopen($activation_code_filename, 'r' ); |
|
449 | - if ( $activation_code_file !== false) { |
|
450 | - $activation_code = fread( $activation_code_file, filesize($activation_code_filename)); |
|
451 | - if ( $activation_code == $valid_activation_code ) { |
|
446 | + $activation_code_filename = WP_PLUGIN_DIR . '/' . $plugin_name . '/encoder.txt'; |
|
447 | + if (is_file($activation_code_filename)) { |
|
448 | + $activation_code_file = fopen($activation_code_filename, 'r'); |
|
449 | + if ($activation_code_file !== false) { |
|
450 | + $activation_code = fread($activation_code_file, filesize($activation_code_filename)); |
|
451 | + if ($activation_code == $valid_activation_code) { |
|
452 | 452 | $is_valid = true; |
453 | 453 | } |
454 | 454 | } |
@@ -461,12 +461,12 @@ discard block |
||
461 | 461 | * @param unknown_type $number |
462 | 462 | * @return string |
463 | 463 | */ |
464 | - public static function formate_number( $number ) { |
|
465 | - $number = number_format( $number, 2, '.', '' ); |
|
466 | - $exploded_number = explode( '.', $number ); |
|
464 | + public static function formate_number($number) { |
|
465 | + $number = number_format($number, 2, '.', ''); |
|
466 | + $exploded_number = explode('.', $number); |
|
467 | 467 | $number = $exploded_number[0]; |
468 | - if( $exploded_number[1] != '00' ) { |
|
469 | - $number .= '<span class="wps_number_cents">,' . $exploded_number[1]. '</span>'; |
|
468 | + if ($exploded_number[1] != '00') { |
|
469 | + $number .= '<span class="wps_number_cents">,' . $exploded_number[1] . '</span>'; |
|
470 | 470 | } |
471 | 471 | return $number; |
472 | 472 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | * @param int $page_id |
477 | 477 | * @return int |
478 | 478 | */ |
479 | - public static function get_page_id( $page_id ) { |
|
480 | - if( !empty($page_id) ) { |
|
481 | - if ( function_exists( 'icl_object_id' ) && defined('ICL_LANGUAGE_CODE') ) { |
|
482 | - $element_post_type = get_post_type( $page_id ); |
|
483 | - $translated_element_id = icl_object_id( $page_id, $element_post_type, true, ICL_LANGUAGE_CODE ); |
|
484 | - if( !empty($translated_element_id) ) { |
|
479 | + public static function get_page_id($page_id) { |
|
480 | + if (!empty($page_id)) { |
|
481 | + if (function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE')) { |
|
482 | + $element_post_type = get_post_type($page_id); |
|
483 | + $translated_element_id = icl_object_id($page_id, $element_post_type, true, ICL_LANGUAGE_CODE); |
|
484 | + if (!empty($translated_element_id)) { |
|
485 | 485 | $page_id = $translated_element_id; |
486 | 486 | } |
487 | 487 | } |
@@ -489,65 +489,65 @@ discard block |
||
489 | 489 | return $page_id; |
490 | 490 | } |
491 | 491 | |
492 | - public static function minutes_to_time( $minutes, $format = '%hh %imin' ) { |
|
493 | - $dtF = new \DateTime( '@0' ); |
|
494 | - $dtT = new \DateTime( '@' . ( $minutes * 60 ) ); |
|
495 | - return $dtF->diff($dtT)->format( $format ); |
|
492 | + public static function minutes_to_time($minutes, $format = '%hh %imin') { |
|
493 | + $dtF = new \DateTime('@0'); |
|
494 | + $dtT = new \DateTime('@' . ($minutes * 60)); |
|
495 | + return $dtF->diff($dtT)->format($format); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | public static function number_format_hack($n) { |
499 | 499 | return number_format($n, 5, '.', ''); |
500 | 500 | } |
501 | - public static function is_serialized( $data, $strict = true ) { |
|
502 | - if ( ! is_string( $data ) ) { |
|
501 | + public static function is_serialized($data, $strict = true) { |
|
502 | + if (!is_string($data)) { |
|
503 | 503 | return false; |
504 | 504 | } |
505 | - $data = trim( $data ); |
|
506 | - if ( 'N;' == $data ) { |
|
505 | + $data = trim($data); |
|
506 | + if ('N;' == $data) { |
|
507 | 507 | return true; |
508 | 508 | } |
509 | - if ( strlen( $data ) < 4 ) { |
|
509 | + if (strlen($data) < 4) { |
|
510 | 510 | return false; |
511 | 511 | } |
512 | - if ( ':' !== $data[1] ) { |
|
512 | + if (':' !== $data[1]) { |
|
513 | 513 | return false; |
514 | 514 | } |
515 | - if ( $strict ) { |
|
516 | - $lastc = substr( $data, -1 ); |
|
517 | - if ( ';' !== $lastc && '}' !== $lastc ) { |
|
515 | + if ($strict) { |
|
516 | + $lastc = substr($data, -1); |
|
517 | + if (';' !== $lastc && '}' !== $lastc) { |
|
518 | 518 | return false; |
519 | 519 | } |
520 | 520 | } else { |
521 | - $semicolon = strpos( $data, ';' ); |
|
522 | - $brace = strpos( $data, '}' ); |
|
523 | - if ( false === $semicolon && false === $brace ) { |
|
521 | + $semicolon = strpos($data, ';'); |
|
522 | + $brace = strpos($data, '}'); |
|
523 | + if (false === $semicolon && false === $brace) { |
|
524 | 524 | return false; |
525 | 525 | } |
526 | - if ( false !== $semicolon && $semicolon < 3 ) { |
|
526 | + if (false !== $semicolon && $semicolon < 3) { |
|
527 | 527 | return false; |
528 | 528 | } |
529 | - if ( false !== $brace && $brace < 4 ) { |
|
529 | + if (false !== $brace && $brace < 4) { |
|
530 | 530 | return false; |
531 | 531 | } |
532 | 532 | } |
533 | 533 | $token = $data[0]; |
534 | - switch ( $token ) { |
|
534 | + switch ($token) { |
|
535 | 535 | case 's' : |
536 | - if ( $strict ) { |
|
537 | - if ( '"' !== substr( $data, -2, 1 ) ) { |
|
536 | + if ($strict) { |
|
537 | + if ('"' !== substr($data, -2, 1)) { |
|
538 | 538 | return false; |
539 | 539 | } |
540 | - } elseif ( false === strpos( $data, '"' ) ) { |
|
540 | + } elseif (false === strpos($data, '"')) { |
|
541 | 541 | return false; |
542 | 542 | } |
543 | 543 | case 'a' : |
544 | 544 | case 'O' : |
545 | - return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); |
|
545 | + return (bool)preg_match("/^{$token}:[0-9]+:/s", $data); |
|
546 | 546 | case 'b' : |
547 | 547 | case 'i' : |
548 | 548 | case 'd' : |
549 | 549 | $end = $strict ? '$' : ''; |
550 | - return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); |
|
550 | + return (bool)preg_match("/^{$token}:[0-9.E-]+;$end/", $data); |
|
551 | 551 | } |
552 | 552 | return false; |
553 | 553 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Main controller file for product mass modification module |
4 | 6 | * |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | |
36 | 38 | $templates = array(); |
37 | 39 | $name = (string)$name; |
38 | - if ( '' !== $name ) |
|
39 | - $templates[] = "{$side}/{$slug}-{$name}.php"; |
|
40 | + if ( '' !== $name ) { |
|
41 | + $templates[] = "{$side}/{$slug}-{$name}.php"; |
|
42 | + } |
|
40 | 43 | $templates[] = "{$side}/{$slug}.php"; |
41 | 44 | |
42 | 45 | /** Check if required template exists into current theme */ |
@@ -59,8 +62,9 @@ discard block |
||
59 | 62 | |
60 | 63 | if ( empty( $path ) ) { |
61 | 64 | foreach ( (array) $templates as $template_name ) { |
62 | - if ( !$template_name ) |
|
63 | - continue; |
|
65 | + if ( !$template_name ) { |
|
66 | + continue; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | if ( !empty( $debug ) ) { |
66 | 70 | echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>'; |
@@ -179,8 +183,7 @@ discard block |
||
179 | 183 | foreach($values as $value) { |
180 | 184 | $result[] = array($key => $value); |
181 | 185 | } |
182 | - } |
|
183 | - else { |
|
186 | + } else { |
|
184 | 187 | $append = array(); |
185 | 188 | foreach($result as &$product) { |
186 | 189 | $product[$key] = array_shift($values); |
@@ -217,8 +220,7 @@ discard block |
||
217 | 220 | if ( !empty(self::$currency_cache) ) { |
218 | 221 | $code = ($code) ? self::$currency_cache->name : self::$currency_cache->unit; |
219 | 222 | return $code; |
220 | - } |
|
221 | - else { |
|
223 | + } else { |
|
222 | 224 | return ''; |
223 | 225 | } |
224 | 226 | } |
@@ -284,8 +286,7 @@ discard block |
||
284 | 286 | |
285 | 287 | if ( $dataFieldType == 'datetime' ) { |
286 | 288 | $type = 'text'; |
287 | - } |
|
288 | - else { |
|
289 | + } else { |
|
289 | 290 | switch ( $frontend_verification ) { |
290 | 291 | case 'phone': |
291 | 292 | $type = 'tel'; |
@@ -317,8 +318,7 @@ discard block |
||
317 | 318 | |
318 | 319 | if ( null === $request_method ) { |
319 | 320 | die ('Invalid REQUEST_METHOD (not GET, not POST).'); |
320 | - } |
|
321 | - else { |
|
321 | + } else { |
|
322 | 322 | return $request_method; |
323 | 323 | } |
324 | 324 | } |
@@ -343,18 +343,15 @@ discard block |
||
343 | 343 | { |
344 | 344 | $pattern = array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/û/", "/ô/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ö/", "/Ù/", "/Û/", "/Ü/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/"); |
345 | 345 | $rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U"); |
346 | - } |
|
347 | - elseif($type == 'noSpaces') |
|
346 | + } elseif($type == 'noSpaces') |
|
348 | 347 | { |
349 | 348 | $pattern = array('/\s/'); |
350 | 349 | $rep_pat = array('_'); |
351 | 350 | $slugified = trim($slugified); |
352 | - } |
|
353 | - elseif($type == 'lowerCase') |
|
351 | + } elseif($type == 'lowerCase') |
|
354 | 352 | { |
355 | 353 | $slugified = strtolower($slugified); |
356 | - } |
|
357 | - elseif($type == 'noPunctuation') |
|
354 | + } elseif($type == 'noPunctuation') |
|
358 | 355 | { |
359 | 356 | $pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//"); |
360 | 357 | $rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_"); |
@@ -379,9 +376,11 @@ discard block |
||
379 | 376 | * @return string $string The output string that was trunk if necessary |
380 | 377 | */ |
381 | 378 | public static function trunk($string, $maxlength) { |
382 | - if(strlen($string)>$maxlength+3) |
|
383 | - return substr($string,0,$maxlength).'...'; |
|
384 | - else return $string; |
|
379 | + if(strlen($string)>$maxlength+3) { |
|
380 | + return substr($string,0,$maxlength).'...'; |
|
381 | + } else { |
|
382 | + return $string; |
|
383 | + } |
|
385 | 384 | } |
386 | 385 | |
387 | 386 | /** |
@@ -403,8 +402,7 @@ discard block |
||
403 | 402 | ob_start(); |
404 | 403 | if ( !empty($args) ) { |
405 | 404 | do_action($hook_name, $args); |
406 | - } |
|
407 | - else { |
|
405 | + } else { |
|
408 | 406 | do_action($hook_name); |
409 | 407 | } |
410 | 408 | $content = ob_get_contents(); |
@@ -420,8 +418,9 @@ discard block |
||
420 | 418 | */ |
421 | 419 | public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) { |
422 | 420 | $code = ''; |
423 | - if ( !function_exists( 'get_plugin_data') ) |
|
424 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
421 | + if ( !function_exists( 'get_plugin_data') ) { |
|
422 | + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
423 | + } |
|
425 | 424 | $plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' ); |
426 | 425 | $code_part = array(); |
427 | 426 | $code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5); |
@@ -204,7 +204,7 @@ |
||
204 | 204 | * Return s custom shipping cost for a cart |
205 | 205 | * @param string $dest Shipping area zone |
206 | 206 | * @param array $data |
207 | - * @param array $fees |
|
207 | + * @param string $fees |
|
208 | 208 | * @return number|boolean|Ambigous <number, unknown> |
209 | 209 | */ |
210 | 210 | function calculate_custom_shipping_cost($dest='', $data, $fees, $shipping_method = false) { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_shipping { |
3 | 3 | function __construct() { |
4 | 4 | |
@@ -11,41 +11,41 @@ discard block |
||
11 | 11 | */ |
12 | 12 | function shipping_fees_string_2_array($fees_string) { |
13 | 13 | $data = array(); |
14 | - if(!empty($fees_string) && !is_array($fees_string) ) { |
|
15 | - if(preg_match_all('#{[^{]+}#', $fees_string, $cont)){ |
|
16 | - foreach($cont[0] as $c) { |
|
14 | + if (!empty($fees_string) && !is_array($fees_string)) { |
|
15 | + if (preg_match_all('#{[^{]+}#', $fees_string, $cont)) { |
|
16 | + foreach ($cont[0] as $c) { |
|
17 | 17 | preg_match_all('#([a-z]+) ?: ?"(.+)"#', $c, $atts); |
18 | 18 | $temp_data = array(); |
19 | 19 | $country_code = ''; |
20 | - foreach($atts[1] as $key => $value) { |
|
21 | - $temp_data[$value] = $atts[2][$key]; |
|
22 | - if($value=='destination') { |
|
20 | + foreach ($atts[1] as $key => $value) { |
|
21 | + $temp_data[$value] = $atts[2][$key]; |
|
22 | + if ($value == 'destination') { |
|
23 | 23 | $country_code = $atts[2][$key]; |
24 | 24 | } |
25 | - elseif($value=='fees') { |
|
25 | + elseif ($value == 'fees') { |
|
26 | 26 | $fees_data = array(); |
27 | 27 | $fees = explode(',', $atts[2][$key]); |
28 | - foreach($fees as $fee){ |
|
28 | + foreach ($fees as $fee) { |
|
29 | 29 | $fee_element = explode(':', $fee); |
30 | - $fees_data[trim($fee_element[0])] = trim($fee_element[1]); |
|
30 | + $fees_data[trim($fee_element[0])] = trim($fee_element[1]); |
|
31 | 31 | } |
32 | 32 | $number = count($fees_data); |
33 | 33 | |
34 | 34 | $fees_data_1 = array(); |
35 | 35 | preg_match_all('#([0-9]+\.?[0-9]?+) ?: ?([0-9]+\.?[0-9]?+)#', $atts[2][$key], $fees); |
36 | - foreach($fees[1] as $_key => $_value) { |
|
37 | - $fees_data_1[$_value] = $fees[2][$_key]; |
|
36 | + foreach ($fees[1] as $_key => $_value) { |
|
37 | + $fees_data_1[$_value] = $fees[2][$_key]; |
|
38 | 38 | } |
39 | 39 | $number_1 = count($fees_data_1); |
40 | 40 | if ($number == $number_1) { |
41 | - $temp_data[$value] = $fees_data; |
|
41 | + $temp_data[$value] = $fees_data; |
|
42 | 42 | } |
43 | 43 | else { |
44 | - $temp_data[$value] = $fees_data_1; |
|
44 | + $temp_data[$value] = $fees_data_1; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
48 | - if(!empty($country_code)) { |
|
48 | + if (!empty($country_code)) { |
|
49 | 49 | $data[$country_code] = $temp_data; |
50 | 50 | } |
51 | 51 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function shipping_fees_array_2_string($fees_array) { |
64 | 64 | $string = ''; |
65 | - if(!empty($fees_array)) { |
|
66 | - foreach($fees_array as $d) { |
|
67 | - $string .= '{'."\n"; |
|
68 | - foreach($d as $att => $value) { |
|
65 | + if (!empty($fees_array)) { |
|
66 | + foreach ($fees_array as $d) { |
|
67 | + $string .= '{' . "\n"; |
|
68 | + foreach ($d as $att => $value) { |
|
69 | 69 | $val = ''; |
70 | - if($att=='fees') { |
|
71 | - foreach($value as $_k=>$_value) $val .= $_k.':'.$_value.', '; |
|
72 | - $val = substr($val,0,-2); |
|
70 | + if ($att == 'fees') { |
|
71 | + foreach ($value as $_k=>$_value) $val .= $_k . ':' . $_value . ', '; |
|
72 | + $val = substr($val, 0, -2); |
|
73 | 73 | } else $val = $value; |
74 | - $string .= $att.': "'.$val.'",'."\n"; |
|
74 | + $string .= $att . ': "' . $val . '",' . "\n"; |
|
75 | 75 | } |
76 | - $string = substr($string,0,-2)."\n"; |
|
77 | - $string .= '},'."\n"; |
|
76 | + $string = substr($string, 0, -2) . "\n"; |
|
77 | + $string .= '},' . "\n"; |
|
78 | 78 | } |
79 | - $string = substr($string,0,-2); |
|
79 | + $string = substr($string, 0, -2); |
|
80 | 80 | return $string; |
81 | 81 | } |
82 | 82 | else return false; |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return number|string The sipping cost for the current cart |
94 | 94 | */ |
95 | - function get_shipping_cost( $nb_of_items, $total_cart, $total_shipping_cost, $total_weight, $selected_method = '' ) { |
|
95 | + function get_shipping_cost($nb_of_items, $total_cart, $total_shipping_cost, $total_weight, $selected_method = '') { |
|
96 | 96 | global $wpdb; |
97 | 97 | |
98 | 98 | $shipping_cost = 0; |
99 | 99 | |
100 | - $shipping_mode_state = get_option( 'wpshop_shipping_address_choice' ); |
|
101 | - if ( ! empty( $shipping_mode_state ) && isset( $shipping_mode_state['activate'] ) && ( 'on' === $shipping_mode_state['activate'] ) ) { |
|
102 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
103 | - if( ( !empty($selected_method) || isset( $_SESSION['shipping_address'] ) && empty( $_SESSION['shipping_method'] ) ) ) { |
|
104 | - if( !empty($selected_method) ) { |
|
100 | + $shipping_mode_state = get_option('wpshop_shipping_address_choice'); |
|
101 | + if (!empty($shipping_mode_state) && isset($shipping_mode_state['activate']) && ('on' === $shipping_mode_state['activate'])) { |
|
102 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
103 | + if ((!empty($selected_method) || isset($_SESSION['shipping_address']) && empty($_SESSION['shipping_method']))) { |
|
104 | + if (!empty($selected_method)) { |
|
105 | 105 | $chosen_shipping_mode = $selected_method; |
106 | 106 | } else { |
107 | 107 | $ship_mod = new wps_shipping_mode_ctr(); |
108 | - $shipping_modes = $ship_mod->get_shipping_mode_for_address( $_SESSION['shipping_address'] ); |
|
109 | - if( !empty( $shipping_modes ) ) { |
|
108 | + $shipping_modes = $ship_mod->get_shipping_mode_for_address($_SESSION['shipping_address']); |
|
109 | + if (!empty($shipping_modes)) { |
|
110 | 110 | $shipping_modes = $shipping_modes['modes']; |
111 | - foreach( $shipping_modes as $key => $shipping_mode ) { |
|
111 | + foreach ($shipping_modes as $key => $shipping_mode) { |
|
112 | 112 | $chosen_shipping_mode = $key; |
113 | 113 | break; |
114 | 114 | } |
@@ -118,37 +118,37 @@ discard block |
||
118 | 118 | } |
119 | 119 | } |
120 | 120 | else { |
121 | - if( !empty( $_SESSION['shipping_method'] ) ) { |
|
122 | - $chosen_shipping_mode = wpshop_tools::varSanitizer( $_SESSION['shipping_method'] ); |
|
121 | + if (!empty($_SESSION['shipping_method'])) { |
|
122 | + $chosen_shipping_mode = wpshop_tools::varSanitizer($_SESSION['shipping_method']); |
|
123 | 123 | } else { |
124 | 124 | $chosen_shipping_mode = 'default_choice'; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - $default_weight_unity = get_option( 'wpshop_shop_default_weight_unity' ); |
|
129 | - if ( !empty($default_weight_unity) ) { |
|
130 | - $query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = %d', $default_weight_unity); |
|
131 | - $weight_unity = $wpdb->get_var( $query ); |
|
128 | + $default_weight_unity = get_option('wpshop_shop_default_weight_unity'); |
|
129 | + if (!empty($default_weight_unity)) { |
|
130 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d', $default_weight_unity); |
|
131 | + $weight_unity = $wpdb->get_var($query); |
|
132 | 132 | |
133 | - if ( !empty($weight_unity) && $weight_unity == 'kg' ) { |
|
133 | + if (!empty($weight_unity) && $weight_unity == 'kg') { |
|
134 | 134 | |
135 | 135 | $total_weight = $total_weight * 1000; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - if ( ( !empty($_SESSION['shipping_method']) && $_SESSION['shipping_method'] == 'shipping-partners' ) || !empty( $_SESSION['wps-pos-addon']) ) { |
|
139 | + if ((!empty($_SESSION['shipping_method']) && $_SESSION['shipping_method'] == 'shipping-partners') || !empty($_SESSION['wps-pos-addon'])) { |
|
140 | 140 | return 0; |
141 | 141 | } |
142 | 142 | |
143 | 143 | /** Take the selected shipping mode **/ |
144 | - if( $chosen_shipping_mode == 'default_choice' ) { |
|
145 | - if( !empty( $shipping_mode_option['modes'][ $shipping_mode_option['default_choice'] ]) ) { |
|
146 | - $selected_shipping_mode_config = $shipping_mode_option['modes'][ $shipping_mode_option['default_choice'] ]; |
|
144 | + if ($chosen_shipping_mode == 'default_choice') { |
|
145 | + if (!empty($shipping_mode_option['modes'][$shipping_mode_option['default_choice']])) { |
|
146 | + $selected_shipping_mode_config = $shipping_mode_option['modes'][$shipping_mode_option['default_choice']]; |
|
147 | 147 | } else { |
148 | 148 | $selected_shipping_mode_config = ''; |
149 | 149 | } |
150 | 150 | } else { |
151 | - if( !empty( $shipping_mode_option['modes'][$chosen_shipping_mode]) ) { |
|
151 | + if (!empty($shipping_mode_option['modes'][$chosen_shipping_mode])) { |
|
152 | 152 | $selected_shipping_mode_config = $shipping_mode_option['modes'][$chosen_shipping_mode]; |
153 | 153 | } else { |
154 | 154 | $selected_shipping_mode_config = ''; |
@@ -157,41 +157,41 @@ discard block |
||
157 | 157 | $shipping_cost = $total_shipping_cost; |
158 | 158 | |
159 | 159 | /** Free Shipping **/ |
160 | - if ( ( !empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_shipping']) ) || ( $selected_method == 'is_downloadable_' ) ) { |
|
160 | + if ((!empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_shipping'])) || ($selected_method == 'is_downloadable_')) { |
|
161 | 161 | $shipping_cost = 0; |
162 | 162 | } |
163 | 163 | /** Free Shipping From **/ |
164 | - elseif( !empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_from']) && $selected_shipping_mode_config['free_from'] >= 0 && $selected_shipping_mode_config['free_from'] <= number_format( $total_cart, 2, '.', '') ) { |
|
164 | + elseif (!empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_from']) && $selected_shipping_mode_config['free_from'] >= 0 && $selected_shipping_mode_config['free_from'] <= number_format($total_cart, 2, '.', '')) { |
|
165 | 165 | $shipping_cost = 0; |
166 | 166 | } |
167 | 167 | else { |
168 | 168 | /** Check Custom Shipping Cost **/ |
169 | 169 | |
170 | - if ( !empty($selected_shipping_mode_config['custom_shipping_rules']) && !empty($selected_shipping_mode_config['custom_shipping_rules']['active']) ) { |
|
170 | + if (!empty($selected_shipping_mode_config['custom_shipping_rules']) && !empty($selected_shipping_mode_config['custom_shipping_rules']['active'])) { |
|
171 | 171 | $address_infos = ''; |
172 | - if( !empty( $_SESSION['shipping_address'] ) ) { |
|
173 | - $address_infos = get_post_meta($_SESSION['shipping_address'],'_wpshop_address_metadata', true); |
|
172 | + if (!empty($_SESSION['shipping_address'])) { |
|
173 | + $address_infos = get_post_meta($_SESSION['shipping_address'], '_wpshop_address_metadata', true); |
|
174 | 174 | } |
175 | - $country = ( !empty($address_infos['country']) ) ? $address_infos['country'] : ''; |
|
175 | + $country = (!empty($address_infos['country'])) ? $address_infos['country'] : ''; |
|
176 | 176 | /** Check Active Postcode option **/ |
177 | - if ( !empty($selected_shipping_mode_config['custom_shipping_rules']['active_cp']) ) { |
|
177 | + if (!empty($selected_shipping_mode_config['custom_shipping_rules']['active_cp'])) { |
|
178 | 178 | $postcode = $address_infos['postcode']; |
179 | - if ( array_key_exists($country.'-'.$postcode, $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) { |
|
180 | - $country = $country.'-'.$postcode; |
|
179 | + if (array_key_exists($country . '-' . $postcode, $selected_shipping_mode_config['custom_shipping_rules']['fees'])) { |
|
180 | + $country = $country . '-' . $postcode; |
|
181 | 181 | } |
182 | - elseif( array_key_exists($country.'-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) { |
|
183 | - $country = $country.'-OTHERS'; |
|
182 | + elseif (array_key_exists($country . '-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees'])) { |
|
183 | + $country = $country . '-OTHERS'; |
|
184 | 184 | } |
185 | 185 | } |
186 | - $shipping_cost += $this->calculate_custom_shipping_cost($country, array('weight'=>$total_weight,'price'=> $total_cart), $selected_shipping_mode_config['custom_shipping_rules']['fees'], $chosen_shipping_mode); |
|
186 | + $shipping_cost += $this->calculate_custom_shipping_cost($country, array('weight'=>$total_weight, 'price'=> $total_cart), $selected_shipping_mode_config['custom_shipping_rules']['fees'], $chosen_shipping_mode); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** Min- Max config **/ |
190 | - if ( !empty($selected_shipping_mode_config['min_max']) && !empty($selected_shipping_mode_config['min_max']['activate']) ) { |
|
191 | - if ( !empty($selected_shipping_mode_config['min_max']['min']) && $shipping_cost < $selected_shipping_mode_config['min_max']['min'] ) { |
|
190 | + if (!empty($selected_shipping_mode_config['min_max']) && !empty($selected_shipping_mode_config['min_max']['activate'])) { |
|
191 | + if (!empty($selected_shipping_mode_config['min_max']['min']) && $shipping_cost < $selected_shipping_mode_config['min_max']['min']) { |
|
192 | 192 | $shipping_cost = $selected_shipping_mode_config['min_max']['min']; |
193 | 193 | } |
194 | - elseif( !empty($selected_shipping_mode_config['min_max']['max']) &&$shipping_cost > $selected_shipping_mode_config['min_max']['max']) { |
|
194 | + elseif (!empty($selected_shipping_mode_config['min_max']['max']) && $shipping_cost > $selected_shipping_mode_config['min_max']['max']) { |
|
195 | 195 | $shipping_cost = $selected_shipping_mode_config['min_max']['max']; |
196 | 196 | } |
197 | 197 | |
@@ -209,40 +209,40 @@ discard block |
||
209 | 209 | * @param array $fees |
210 | 210 | * @return number|boolean|Ambigous <number, unknown> |
211 | 211 | */ |
212 | - function calculate_custom_shipping_cost($dest='', $data, $fees, $shipping_method = false) { |
|
212 | + function calculate_custom_shipping_cost($dest = '', $data, $fees, $shipping_method = false) { |
|
213 | 213 | $fees_table = array(); |
214 | 214 | $key = ''; $price = 0; |
215 | 215 | |
216 | - if ( !empty($_SESSION['shipping_partner_id']) ) { |
|
216 | + if (!empty($_SESSION['shipping_partner_id'])) { |
|
217 | 217 | return 0; |
218 | 218 | } |
219 | 219 | |
220 | - if($shipping_method === false) { |
|
220 | + if ($shipping_method === false) { |
|
221 | 221 | $shipping_method = $_SESSION['shipping_method']; |
222 | 222 | } |
223 | 223 | |
224 | - if(!empty($fees) || !empty($dest) ) { |
|
225 | - $custom_shipping_option = get_option( 'wpshop_custom_shipping', true ); |
|
226 | - $shipping_modes = get_option( 'wps_shipping_mode' ); |
|
224 | + if (!empty($fees) || !empty($dest)) { |
|
225 | + $custom_shipping_option = get_option('wpshop_custom_shipping', true); |
|
226 | + $shipping_modes = get_option('wps_shipping_mode'); |
|
227 | 227 | |
228 | - if ( !empty($shipping_method) ) { |
|
229 | - if ( !empty($shipping_modes) && !empty($shipping_modes['modes']) && !empty($shipping_modes['modes'][ $shipping_method ]) ) { |
|
230 | - $custom_shipping_option = $shipping_modes['modes'][ $shipping_method ]['custom_shipping_rules']; |
|
228 | + if (!empty($shipping_method)) { |
|
229 | + if (!empty($shipping_modes) && !empty($shipping_modes['modes']) && !empty($shipping_modes['modes'][$shipping_method])) { |
|
230 | + $custom_shipping_option = $shipping_modes['modes'][$shipping_method]['custom_shipping_rules']; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | $found_active_cp_rule = $found_active_departement_rule = false; |
234 | - $shipping_address_def = get_post_meta( $_SESSION['shipping_address'], '_wpshop_address_metadata', true ); |
|
234 | + $shipping_address_def = get_post_meta($_SESSION['shipping_address'], '_wpshop_address_metadata', true); |
|
235 | 235 | $postcode = ''; |
236 | - if ( !empty($shipping_address_def) ) { |
|
236 | + if (!empty($shipping_address_def)) { |
|
237 | 237 | $postcode = $shipping_address_def['postcode']; |
238 | 238 | } |
239 | 239 | |
240 | 240 | /** Search Postcode custom fees **/ |
241 | - if ( !empty($custom_shipping_option) && !empty($custom_shipping_option['active_cp']) ) { |
|
242 | - $key = $dest.'-'.$postcode; |
|
243 | - if ( array_key_exists($key, $fees) ) { |
|
241 | + if (!empty($custom_shipping_option) && !empty($custom_shipping_option['active_cp'])) { |
|
242 | + $key = $dest . '-' . $postcode; |
|
243 | + if (array_key_exists($key, $fees)) { |
|
244 | 244 | foreach ($fees[$key]['fees'] as $k => $shipping_price) { |
245 | - if ( $data['weight'] <= $k) { |
|
245 | + if ($data['weight'] <= $k) { |
|
246 | 246 | break; |
247 | 247 | } |
248 | 248 | } |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | /** Search Department custom fees **/ |
254 | - if( !empty($custom_shipping_option) && !empty($custom_shipping_option['active_department']) && !$found_active_cp_rule ) { |
|
255 | - $department = substr( $postcode, 0,2 ); |
|
256 | - $key = $dest.'-'.$department; |
|
254 | + if (!empty($custom_shipping_option) && !empty($custom_shipping_option['active_department']) && !$found_active_cp_rule) { |
|
255 | + $department = substr($postcode, 0, 2); |
|
256 | + $key = $dest . '-' . $department; |
|
257 | 257 | /** Check if a rule exists **/ |
258 | - if ( array_key_exists($key, $fees) ) { |
|
258 | + if (array_key_exists($key, $fees)) { |
|
259 | 259 | foreach ($fees[$key]['fees'] as $k => $shipping_price) { |
260 | - if ( $data['weight'] <= $k) { |
|
260 | + if ($data['weight'] <= $k) { |
|
261 | 261 | break; |
262 | 262 | } |
263 | 263 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | /** Search general custom fees **/ |
269 | - if( !$found_active_cp_rule && !$found_active_departement_rule ){ |
|
270 | - if ( array_key_exists($dest, $fees) ) { |
|
269 | + if (!$found_active_cp_rule && !$found_active_departement_rule) { |
|
270 | + if (array_key_exists($dest, $fees)) { |
|
271 | 271 | $key = $dest; |
272 | 272 | } |
273 | - elseif( array_key_exists( 'OTHERS', $fees) ) { |
|
273 | + elseif (array_key_exists('OTHERS', $fees)) { |
|
274 | 274 | $key = 'OTHERS'; |
275 | 275 | } |
276 | 276 | else { |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | //Search fees |
282 | - if ( !empty($key) ) { |
|
283 | - ksort( $fees[$key]['fees'] ); |
|
282 | + if (!empty($key)) { |
|
283 | + ksort($fees[$key]['fees']); |
|
284 | 284 | foreach ($fees[$key]['fees'] as $k => $shipping_price) { |
285 | - if ( $data['weight'] <= $k) { |
|
285 | + if ($data['weight'] <= $k) { |
|
286 | 286 | $price = $shipping_price; |
287 | 287 | break; |
288 | 288 | } |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | * @param array $cart_items |
305 | 305 | * @return number |
306 | 306 | */ |
307 | - function calcul_cart_items_shipping_cost( $cart_items ) { |
|
307 | + function calcul_cart_items_shipping_cost($cart_items) { |
|
308 | 308 | $shipping_cost = 0; |
309 | - if( !empty($cart_items) ) { |
|
310 | - foreach( $cart_items as $cart_item ) { |
|
311 | - $product_data = get_post_meta( $cart_item['item_id'], '_wpshop_product_metadata', true ); |
|
309 | + if (!empty($cart_items)) { |
|
310 | + foreach ($cart_items as $cart_item) { |
|
311 | + $product_data = get_post_meta($cart_item['item_id'], '_wpshop_product_metadata', true); |
|
312 | 312 | |
313 | - if ( !empty( $product_data ) && !empty( $product_data['cost_of_postage'] ) ) { |
|
314 | - $shipping_cost += ( $product_data['cost_of_postage'] * $cart_item['item_qty'] ); |
|
313 | + if (!empty($product_data) && !empty($product_data['cost_of_postage'])) { |
|
314 | + $shipping_cost += ($product_data['cost_of_postage'] * $cart_item['item_qty']); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | * @param array $cart_items |
325 | 325 | * @return number |
326 | 326 | */ |
327 | - function calcul_cart_weight( $cart_items ) { |
|
327 | + function calcul_cart_weight($cart_items) { |
|
328 | 328 | $cart_weight = 0; |
329 | - if ( !empty( $cart_items) ) { |
|
330 | - foreach( $cart_items as $id_item => $cart_item ) { |
|
329 | + if (!empty($cart_items)) { |
|
330 | + foreach ($cart_items as $id_item => $cart_item) { |
|
331 | 331 | $id_item = wpshop_products::get_id_variation($id_item); |
332 | - if ( get_post_type($id_item) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
333 | - $product_data = get_post_meta( $id_item, '_wpshop_product_metadata', true ); |
|
334 | - if ( !empty($product_data) && !empty($product_data['product_weight']) ) { |
|
335 | - $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |
|
332 | + if (get_post_type($id_item) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
333 | + $product_data = get_post_meta($id_item, '_wpshop_product_metadata', true); |
|
334 | + if (!empty($product_data) && !empty($product_data['product_weight'])) { |
|
335 | + $cart_weight += ($product_data['product_weight'] * $cart_item['item_qty']); |
|
336 | 336 | } |
337 | 337 | else { |
338 | - $parent_def = wpshop_products::get_parent_variation( $id_item ); |
|
339 | - if ( !empty($parent_def) && !empty( $parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['product_weight']) ) { |
|
340 | - $cart_weight += ( $parent_def['parent_post_meta']['product_weight'] * $cart_item['item_qty'] ); |
|
338 | + $parent_def = wpshop_products::get_parent_variation($id_item); |
|
339 | + if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['product_weight'])) { |
|
340 | + $cart_weight += ($parent_def['parent_post_meta']['product_weight'] * $cart_item['item_qty']); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | } |
344 | 344 | else { |
345 | - $product_data = get_post_meta( $cart_item['item_id'], '_wpshop_product_metadata', true ); |
|
346 | - if ( !empty($product_data) && !empty($product_data['product_weight']) && !empty($cart_item['item_qty']) ) { |
|
347 | - $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |
|
345 | + $product_data = get_post_meta($cart_item['item_id'], '_wpshop_product_metadata', true); |
|
346 | + if (!empty($product_data) && !empty($product_data['product_weight']) && !empty($cart_item['item_qty'])) { |
|
347 | + $cart_weight += ($product_data['product_weight'] * $cart_item['item_qty']); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
352 | - $cart_weight = apply_filters( 'extra_cart_weight_calcul', $cart_weight, $cart_items ); |
|
352 | + $cart_weight = apply_filters('extra_cart_weight_calcul', $cart_weight, $cart_items); |
|
353 | 353 | return $cart_weight; |
354 | 354 | } |
355 | 355 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_shipping { |
3 | 5 | function __construct() { |
4 | 6 | |
@@ -21,8 +23,7 @@ discard block |
||
21 | 23 | $temp_data[$value] = $atts[2][$key]; |
22 | 24 | if($value=='destination') { |
23 | 25 | $country_code = $atts[2][$key]; |
24 | - } |
|
25 | - elseif($value=='fees') { |
|
26 | + } elseif($value=='fees') { |
|
26 | 27 | $fees_data = array(); |
27 | 28 | $fees = explode(',', $atts[2][$key]); |
28 | 29 | foreach($fees as $fee){ |
@@ -39,8 +40,7 @@ discard block |
||
39 | 40 | $number_1 = count($fees_data_1); |
40 | 41 | if ($number == $number_1) { |
41 | 42 | $temp_data[$value] = $fees_data; |
42 | - } |
|
43 | - else { |
|
43 | + } else { |
|
44 | 44 | $temp_data[$value] = $fees_data_1; |
45 | 45 | } |
46 | 46 | } |
@@ -68,9 +68,13 @@ discard block |
||
68 | 68 | foreach($d as $att => $value) { |
69 | 69 | $val = ''; |
70 | 70 | if($att=='fees') { |
71 | - foreach($value as $_k=>$_value) $val .= $_k.':'.$_value.', '; |
|
71 | + foreach($value as $_k=>$_value) { |
|
72 | + $val .= $_k.':'.$_value.', '; |
|
73 | + } |
|
72 | 74 | $val = substr($val,0,-2); |
73 | - } else $val = $value; |
|
75 | + } else { |
|
76 | + $val = $value; |
|
77 | + } |
|
74 | 78 | $string .= $att.': "'.$val.'",'."\n"; |
75 | 79 | } |
76 | 80 | $string = substr($string,0,-2)."\n"; |
@@ -78,8 +82,9 @@ discard block |
||
78 | 82 | } |
79 | 83 | $string = substr($string,0,-2); |
80 | 84 | return $string; |
81 | - } |
|
82 | - else return false; |
|
85 | + } else { |
|
86 | + return false; |
|
87 | + } |
|
83 | 88 | } |
84 | 89 | |
85 | 90 | /** |
@@ -116,8 +121,7 @@ discard block |
||
116 | 121 | $chosen_shipping_mode = 'default_choice'; |
117 | 122 | } |
118 | 123 | } |
119 | - } |
|
120 | - else { |
|
124 | + } else { |
|
121 | 125 | if( !empty( $_SESSION['shipping_method'] ) ) { |
122 | 126 | $chosen_shipping_mode = wpshop_tools::varSanitizer( $_SESSION['shipping_method'] ); |
123 | 127 | } else { |
@@ -163,8 +167,7 @@ discard block |
||
163 | 167 | /** Free Shipping From **/ |
164 | 168 | elseif( !empty($selected_shipping_mode_config) && !empty($selected_shipping_mode_config['free_from']) && $selected_shipping_mode_config['free_from'] >= 0 && $selected_shipping_mode_config['free_from'] <= number_format( $total_cart, 2, '.', '') ) { |
165 | 169 | $shipping_cost = 0; |
166 | - } |
|
167 | - else { |
|
170 | + } else { |
|
168 | 171 | /** Check Custom Shipping Cost **/ |
169 | 172 | |
170 | 173 | if ( !empty($selected_shipping_mode_config['custom_shipping_rules']) && !empty($selected_shipping_mode_config['custom_shipping_rules']['active']) ) { |
@@ -178,8 +181,7 @@ discard block |
||
178 | 181 | $postcode = $address_infos['postcode']; |
179 | 182 | if ( array_key_exists($country.'-'.$postcode, $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) { |
180 | 183 | $country = $country.'-'.$postcode; |
181 | - } |
|
182 | - elseif( array_key_exists($country.'-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) { |
|
184 | + } elseif( array_key_exists($country.'-OTHERS', $selected_shipping_mode_config['custom_shipping_rules']['fees']) ) { |
|
183 | 185 | $country = $country.'-OTHERS'; |
184 | 186 | } |
185 | 187 | } |
@@ -190,8 +192,7 @@ discard block |
||
190 | 192 | if ( !empty($selected_shipping_mode_config['min_max']) && !empty($selected_shipping_mode_config['min_max']['activate']) ) { |
191 | 193 | if ( !empty($selected_shipping_mode_config['min_max']['min']) && $shipping_cost < $selected_shipping_mode_config['min_max']['min'] ) { |
192 | 194 | $shipping_cost = $selected_shipping_mode_config['min_max']['min']; |
193 | - } |
|
194 | - elseif( !empty($selected_shipping_mode_config['min_max']['max']) &&$shipping_cost > $selected_shipping_mode_config['min_max']['max']) { |
|
195 | + } elseif( !empty($selected_shipping_mode_config['min_max']['max']) &&$shipping_cost > $selected_shipping_mode_config['min_max']['max']) { |
|
195 | 196 | $shipping_cost = $selected_shipping_mode_config['min_max']['max']; |
196 | 197 | } |
197 | 198 | |
@@ -269,11 +270,9 @@ discard block |
||
269 | 270 | if( !$found_active_cp_rule && !$found_active_departement_rule ){ |
270 | 271 | if ( array_key_exists($dest, $fees) ) { |
271 | 272 | $key = $dest; |
272 | - } |
|
273 | - elseif( array_key_exists( 'OTHERS', $fees) ) { |
|
273 | + } elseif( array_key_exists( 'OTHERS', $fees) ) { |
|
274 | 274 | $key = 'OTHERS'; |
275 | - } |
|
276 | - else { |
|
275 | + } else { |
|
277 | 276 | return false; |
278 | 277 | } |
279 | 278 | } |
@@ -290,8 +289,7 @@ discard block |
||
290 | 289 | $price = $shipping_price; |
291 | 290 | } |
292 | 291 | } |
293 | - } |
|
294 | - else { |
|
292 | + } else { |
|
295 | 293 | return false; |
296 | 294 | } |
297 | 295 | return $price; |
@@ -333,15 +331,13 @@ discard block |
||
333 | 331 | $product_data = get_post_meta( $id_item, '_wpshop_product_metadata', true ); |
334 | 332 | if ( !empty($product_data) && !empty($product_data['product_weight']) ) { |
335 | 333 | $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |
336 | - } |
|
337 | - else { |
|
334 | + } else { |
|
338 | 335 | $parent_def = wpshop_products::get_parent_variation( $id_item ); |
339 | 336 | if ( !empty($parent_def) && !empty( $parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['product_weight']) ) { |
340 | 337 | $cart_weight += ( $parent_def['parent_post_meta']['product_weight'] * $cart_item['item_qty'] ); |
341 | 338 | } |
342 | 339 | } |
343 | - } |
|
344 | - else { |
|
340 | + } else { |
|
345 | 341 | $product_data = get_post_meta( $cart_item['item_id'], '_wpshop_product_metadata', true ); |
346 | 342 | if ( !empty($product_data) && !empty($product_data['product_weight']) && !empty($cart_item['item_qty']) ) { |
347 | 343 | $cart_weight += ( $product_data['product_weight'] * $cart_item['item_qty'] ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_barcode { |
3 | 5 | public function __construct() { |
4 | 6 | global $post_ID; |
@@ -80,22 +82,18 @@ discard block |
||
80 | 82 | $conf['normal_country_code'], |
81 | 83 | 'enterprise' => |
82 | 84 | $conf['normal_enterprise_code'],'ID' => $ref); |
83 | - } |
|
84 | - else if ( $conf['type'] === 'internal' ) { |
|
85 | + } else if ( $conf['type'] === 'internal' ) { |
|
85 | 86 | $pDate = new DateTime($post->post_date); |
86 | 87 | $date = $pDate->format('my'); |
87 | 88 | |
88 | 89 | if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT || |
89 | 90 | $post->post_type === WPSHOP_IDENTIFIER_PRODUCT) { |
90 | 91 | $type = $conf['internal_product']; |
91 | - } |
|
92 | - else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
92 | + } else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
93 | 93 | $type = $conf['internal_invoice_client']; |
94 | - } |
|
95 | - else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_COUPON) { |
|
94 | + } else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_COUPON) { |
|
96 | 95 | $type = $conf['internal_coupons']; |
97 | - } |
|
98 | - else { |
|
96 | + } else { |
|
99 | 97 | $type = '000'; |
100 | 98 | } |
101 | 99 | |
@@ -149,15 +147,13 @@ discard block |
||
149 | 147 | $conf['normal_country_code'], |
150 | 148 | 'enterprise' => |
151 | 149 | $conf['normal_enterprise_code'],'ID' => $ref); |
152 | - } |
|
153 | - else if ( $conf['type'] === 'internal' ) { |
|
150 | + } else if ( $conf['type'] === 'internal' ) { |
|
154 | 151 | $pDate = new DateTime($post->post_date); |
155 | 152 | $date = $pDate->format('my'); |
156 | 153 | |
157 | 154 | if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_COUPON) { |
158 | 155 | $type = $conf['internal_coupons']; |
159 | - } |
|
160 | - else { |
|
156 | + } else { |
|
161 | 157 | $type = '000'; |
162 | 158 | } |
163 | 159 | |
@@ -187,8 +183,9 @@ discard block |
||
187 | 183 | * @param string $post_ID Ident of post |
188 | 184 | */ |
189 | 185 | public function insert_barcode( $post_ID, $post, $update ) { |
190 | - if ( wp_is_post_revision( $post_ID ) ) |
|
191 | - return; |
|
186 | + if ( wp_is_post_revision( $post_ID ) ) { |
|
187 | + return; |
|
188 | + } |
|
192 | 189 | |
193 | 190 | global $wpdb; |
194 | 191 | |
@@ -222,21 +219,17 @@ discard block |
||
222 | 219 | 'enterprise' => $conf['normal_enterprise_code'], |
223 | 220 | 'ID' => $ref, |
224 | 221 | ); |
225 | - } |
|
226 | - else if ( $conf['type'] === 'internal' ) { |
|
222 | + } else if ( $conf['type'] === 'internal' ) { |
|
227 | 223 | $pDate = new DateTime($post->post_date); |
228 | 224 | $date = $pDate->format('my'); |
229 | 225 | |
230 | 226 | if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT || $post->post_type === WPSHOP_IDENTIFIER_PRODUCT) { |
231 | 227 | $type = $conf['internal_product']; |
232 | - } |
|
233 | - else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
228 | + } else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
234 | 229 | $type = $conf['internal_invoice_client']; |
235 | - } |
|
236 | - else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_COUPON) { |
|
230 | + } else if ($post->post_type === WPSHOP_NEWTYPE_IDENTIFIER_COUPON) { |
|
237 | 231 | $type = $conf['internal_coupons']; |
238 | - } |
|
239 | - else { |
|
232 | + } else { |
|
240 | 233 | $type = '000'; |
241 | 234 | } |
242 | 235 | |
@@ -318,8 +311,7 @@ discard block |
||
318 | 311 | |
319 | 312 | $id = $array['normal']['ID']; |
320 | 313 | |
321 | - } |
|
322 | - else if ( array_key_exists('internal', $array) ) { |
|
314 | + } else if ( array_key_exists('internal', $array) ) { |
|
323 | 315 | $code.= $array['internal']['type']; |
324 | 316 | $code .= $array['internal']['date']; |
325 | 317 | $code .= $array['internal']['ID']; |
@@ -1,10 +1,10 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_barcode { |
3 | 3 | public function __construct() { |
4 | 4 | global $post_ID; |
5 | 5 | |
6 | 6 | $this->install(); |
7 | - add_action( 'save_post', array($this, 'insert_barcode' ), 10, 3 ); |
|
7 | + add_action('save_post', array($this, 'insert_barcode'), 10, 3); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /*Create config informations*/ |
17 | 17 | $conf = get_option('wps_barcode'); |
18 | 18 | |
19 | - if ( empty($conf) ) { |
|
19 | + if (empty($conf)) { |
|
20 | 20 | $conf['generate_barcode'] = false; |
21 | 21 | $conf['type'] = 'internal'; |
22 | 22 | $conf['internal_client'] = '040'; |
@@ -35,20 +35,20 @@ discard block |
||
35 | 35 | add_option('wps_barcode', $conf); |
36 | 36 | |
37 | 37 | /*Adding barcode for existing products*/ |
38 | - $posts = get_posts( array('posts_per_page' => -1 ,'post_type' => 'wpshop_product')); |
|
39 | - foreach ( $posts as $post ) { |
|
38 | + $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'wpshop_product')); |
|
39 | + foreach ($posts as $post) { |
|
40 | 40 | $meta = get_post_meta($post->ID); |
41 | 41 | |
42 | 42 | $attr = wpshop_attributes_set::getAttributeSetDetails($meta['_wpshop_product_attribute_set_id']); |
43 | 43 | $output_order = array(); |
44 | 44 | |
45 | - if ( count($attr) > 0 ) { |
|
46 | - if (!empty($attr) ) { |
|
47 | - foreach ( $attr as $product_attr_group_id => |
|
45 | + if (count($attr) > 0) { |
|
46 | + if (!empty($attr)) { |
|
47 | + foreach ($attr as $product_attr_group_id => |
|
48 | 48 | $product_attr_group_detail) { |
49 | - foreach ( $product_attr_group_detail['attribut'] |
|
49 | + foreach ($product_attr_group_detail['attribut'] |
|
50 | 50 | as $position => $attribute_def) { |
51 | - if ( !empty($attribute_def->code) |
|
51 | + if (!empty($attribute_def->code) |
|
52 | 52 | AND $attribute_def->code === 'barcode') { |
53 | 53 | |
54 | 54 | $types_with_barcode = array( |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
60 | 60 | ); |
61 | 61 | |
62 | - if ( !empty( $post->post_type ) && |
|
63 | - in_array( $post->post_type, |
|
64 | - $types_with_barcode ) ) { |
|
62 | + if (!empty($post->post_type) && |
|
63 | + in_array($post->post_type, |
|
64 | + $types_with_barcode)) { |
|
65 | 65 | |
66 | 66 | $ref = ''; |
67 | 67 | |
68 | - if ( strlen($post->ID) < 5 ) { |
|
69 | - $length = 5-strlen($post->ID); |
|
68 | + if (strlen($post->ID) < 5) { |
|
69 | + $length = 5 - strlen($post->ID); |
|
70 | 70 | for ($i = 0; $i < $length; $i++) { |
71 | 71 | $ref .= '0'; |
72 | 72 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | |
75 | 75 | $ref .= strval($post->ID); |
76 | 76 | |
77 | - if ( $conf['type'] === 'normal' ) { |
|
77 | + if ($conf['type'] === 'normal') { |
|
78 | 78 | $array['normal'] = array('country' => |
79 | 79 | $conf['normal_country_code'], |
80 | 80 | 'enterprise' => |
81 | - $conf['normal_enterprise_code'],'ID' => $ref); |
|
81 | + $conf['normal_enterprise_code'], 'ID' => $ref); |
|
82 | 82 | } |
83 | - else if ( $conf['type'] === 'internal' ) { |
|
83 | + else if ($conf['type'] === 'internal') { |
|
84 | 84 | $pDate = new DateTime($post->post_date); |
85 | 85 | $date = $pDate->format('my'); |
86 | 86 | |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | 'entity_id' => $post->ID, |
110 | 110 | 'user_id' => $post->post_author, |
111 | 111 | 'value' => $barcode, |
112 | - 'creation_date_value' => date( 'Y-m-d H:i:s' )); |
|
112 | + 'creation_date_value' => date('Y-m-d H:i:s')); |
|
113 | 113 | |
114 | 114 | |
115 | - $query = $wpdb->prepare( " |
|
115 | + $query = $wpdb->prepare(" |
|
116 | 116 | SELECT * |
117 | 117 | FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . " |
118 | 118 | WHERE entity_id = %d |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | SELECT id |
121 | 121 | FROM " . WPSHOP_DBT_ATTRIBUTE . " |
122 | 122 | WHERE code = %s |
123 | - )" , $post->ID, 'barcode' ); |
|
124 | - $result = $wpdb->get_results( $query, ARRAY_A ); |
|
123 | + )" , $post->ID, 'barcode'); |
|
124 | + $result = $wpdb->get_results($query, ARRAY_A); |
|
125 | 125 | |
126 | - if ( empty($result) ) { |
|
127 | - $wpdb->insert($table_prefix. |
|
126 | + if (empty($result)) { |
|
127 | + $wpdb->insert($table_prefix . |
|
128 | 128 | 'wpshop__attribute_value_varchar', $data); |
129 | - } elseif( empty( $result[0]['value'] ) ) { |
|
130 | - $wpdb->update($table_prefix. |
|
131 | - 'wpshop__attribute_value_varchar', $data, array( 'value_id' => $result[0]['value_id'] ) ); |
|
129 | + } elseif (empty($result[0]['value'])) { |
|
130 | + $wpdb->update($table_prefix . |
|
131 | + 'wpshop__attribute_value_varchar', $data, array('value_id' => $result[0]['value_id'])); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | /*Adding barcode for existing coupon*/ |
142 | - $posts = get_posts( array('posts_per_page' => -1 ,'post_type' => 'wpshop_shop_coupon') ); |
|
143 | - foreach ( $posts as $post ) { |
|
142 | + $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'wpshop_shop_coupon')); |
|
143 | + foreach ($posts as $post) { |
|
144 | 144 | $meta = get_post_meta($post->ID); |
145 | - if ( empty($meta['wpshop_coupon_barcode']) ) { |
|
146 | - if ( $conf['type'] === 'normal' ) { |
|
145 | + if (empty($meta['wpshop_coupon_barcode'])) { |
|
146 | + if ($conf['type'] === 'normal') { |
|
147 | 147 | $array['normal'] = array('country' => |
148 | 148 | $conf['normal_country_code'], |
149 | 149 | 'enterprise' => |
150 | - $conf['normal_enterprise_code'],'ID' => $ref); |
|
150 | + $conf['normal_enterprise_code'], 'ID' => $ref); |
|
151 | 151 | } |
152 | - else if ( $conf['type'] === 'internal' ) { |
|
152 | + else if ($conf['type'] === 'internal') { |
|
153 | 153 | $pDate = new DateTime($post->post_date); |
154 | 154 | $date = $pDate->format('my'); |
155 | 155 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $ref = ''; |
164 | - if ( strlen($post->ID) < 5 ) { |
|
165 | - $length = 5-strlen($post->ID); |
|
164 | + if (strlen($post->ID) < 5) { |
|
165 | + $length = 5 - strlen($post->ID); |
|
166 | 166 | for ($i = 0; $i < $length; $i++) { |
167 | 167 | $ref .= '0'; |
168 | 168 | } |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * Verifty post identifier and run a barcode generator |
185 | 185 | * @param string $post_ID Ident of post |
186 | 186 | */ |
187 | - public function insert_barcode( $post_ID, $post, $update ) { |
|
188 | - if ( wp_is_post_revision( $post_ID ) ) |
|
187 | + public function insert_barcode($post_ID, $post, $update) { |
|
188 | + if (wp_is_post_revision($post_ID)) |
|
189 | 189 | return; |
190 | 190 | |
191 | 191 | global $wpdb; |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | ); |
200 | 200 | |
201 | 201 | /** Si c'est un type qui est dans le tableau $types_with_barcode */ |
202 | - if ( !empty( $post->post_type ) && in_array( $post->post_type, |
|
203 | - $types_with_barcode ) ) { |
|
202 | + if (!empty($post->post_type) && in_array($post->post_type, |
|
203 | + $types_with_barcode)) { |
|
204 | 204 | |
205 | 205 | $conf = get_option('wps_barcode'); |
206 | 206 | $ref = ''; |
207 | 207 | |
208 | - if ( strlen($post_ID) < 5 ) { |
|
209 | - $length = 5-strlen($post_ID); |
|
208 | + if (strlen($post_ID) < 5) { |
|
209 | + $length = 5 - strlen($post_ID); |
|
210 | 210 | for ($i = 0; $i < $length; $i++) { |
211 | 211 | $ref .= '0'; |
212 | 212 | } |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | |
215 | 215 | $ref .= strval($post_ID); |
216 | 216 | |
217 | - if ( $conf['type'] === 'normal' ) { |
|
217 | + if ($conf['type'] === 'normal') { |
|
218 | 218 | $array['normal'] = array( |
219 | 219 | 'country' => $conf['normal_country_code'], |
220 | 220 | 'enterprise' => $conf['normal_enterprise_code'], |
221 | 221 | 'ID' => $ref, |
222 | 222 | ); |
223 | 223 | } |
224 | - else if ( $conf['type'] === 'internal' ) { |
|
224 | + else if ($conf['type'] === 'internal') { |
|
225 | 225 | $pDate = new DateTime($post->post_date); |
226 | 226 | $date = $pDate->format('my'); |
227 | 227 | |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | |
248 | 248 | //$barcode = $this->wps_generate_barcode($array); |
249 | 249 | /** For add a product */ |
250 | - $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] = !empty( $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] ) ? sanitize_text_field( $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] ) : null; |
|
251 | - if( !isset($_REQUEST['wpshop_product_attribute']['varchar']['barcode']) ) { |
|
252 | - \eoxia\log_class::exec( 'wps_barcode', 'wps_barcode', sprintf( __('Adding barcode: %s for %s object ID', 'wps_barcode'), '<b>'.$_REQUEST['wpshop_product_attribute']['varchar']['barcode'].'</b>', '<b>'.$post_ID.'</b>'), array( 'object_id' => $post_ID ), 0 ); |
|
250 | + $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] = !empty($_REQUEST['wpshop_product_attribute']['varchar']['barcode']) ? sanitize_text_field($_REQUEST['wpshop_product_attribute']['varchar']['barcode']) : null; |
|
251 | + if (!isset($_REQUEST['wpshop_product_attribute']['varchar']['barcode'])) { |
|
252 | + \eoxia\log_class::exec('wps_barcode', 'wps_barcode', sprintf(__('Adding barcode: %s for %s object ID', 'wps_barcode'), '<b>' . $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] . '</b>', '<b>' . $post_ID . '</b>'), array('object_id' => $post_ID), 0); |
|
253 | 253 | |
254 | 254 | $_REQUEST['wpshop_product_attribute']['varchar']['barcode'] = $this->wps_generate_barcode($array); |
255 | 255 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | $conf = get_option('wps_barcode'); |
275 | 275 | |
276 | - if ( array_key_exists('normal', $array) ) { |
|
276 | + if (array_key_exists('normal', $array)) { |
|
277 | 277 | $code .= $array['normal']['country']; |
278 | 278 | $code .= $array['normal']['enterprise']; |
279 | 279 | $code .= $array['normal']['ID']; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | $id = $array['normal']['ID']; |
282 | 282 | |
283 | 283 | } |
284 | - else if ( array_key_exists('internal', $array) ) { |
|
285 | - $code.= $array['internal']['type']; |
|
284 | + else if (array_key_exists('internal', $array)) { |
|
285 | + $code .= $array['internal']['type']; |
|
286 | 286 | $code .= $array['internal']['date']; |
287 | 287 | $code .= $array['internal']['ID']; |
288 | 288 | |
@@ -291,15 +291,15 @@ discard block |
||
291 | 291 | |
292 | 292 | $gencode = $barcode->checksum($code); |
293 | 293 | |
294 | - $barcode->writeLog( sprintf( __("Checksum generate: %s from %s <br />", |
|
295 | - 'wps_barcode'), '<b>'.$gencode.'</b>', |
|
296 | - '<b>'.$code.'</b>') ); |
|
294 | + $barcode->writeLog(sprintf(__("Checksum generate: %s from %s <br />", |
|
295 | + 'wps_barcode'), '<b>' . $gencode . '</b>', |
|
296 | + '<b>' . $code . '</b>')); |
|
297 | 297 | |
298 | - $message = sprintf( __("Log generated by wps_barcodegen for add/update product: <br /> %s", |
|
299 | - 'wps_barcode'), $barcode->getLog() ); |
|
298 | + $message = sprintf(__("Log generated by wps_barcodegen for add/update product: <br /> %s", |
|
299 | + 'wps_barcode'), $barcode->getLog()); |
|
300 | 300 | |
301 | - if ( class_exists('wpeologs_ctr') ) { |
|
302 | - \eoxia\log_class::exec( 'wps_barcode', 'wps_barcode', $message, array( 'object_id' => $id ), 0 ); |
|
301 | + if (class_exists('wpeologs_ctr')) { |
|
302 | + \eoxia\log_class::exec('wps_barcode', 'wps_barcode', $message, array('object_id' => $id), 0); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | return $gencode; |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | +if (!defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_VERSION', 1.0 ); |
|
5 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_DIR', basename( dirname( __FILE__ ) ) ); |
|
6 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_PATH', str_replace( "\\", "/", plugin_dir_path( __FILE__ ) ) ); |
|
7 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPSPDTVARIATION_INTERFACE_PATH ) ); |
|
4 | +DEFINE('WPSPDTVARIATION_INTERFACE_VERSION', 1.0); |
|
5 | +DEFINE('WPSPDTVARIATION_INTERFACE_DIR', basename(dirname(__FILE__))); |
|
6 | +DEFINE('WPSPDTVARIATION_INTERFACE_PATH', str_replace("\\", "/", plugin_dir_path(__FILE__))); |
|
7 | +DEFINE('WPSPDTVARIATION_INTERFACE_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPSPDTVARIATION_INTERFACE_PATH)); |
|
8 | 8 | |
9 | 9 | /** Définition du chemin absolu vers les templates / Define the templates absolute directories */ |
10 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR', WPSPDTVARIATION_INTERFACE_PATH . '/templates/'); |
|
11 | -DEFINE( 'WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR', WPSPDTVARIATION_INTERFACE_URL . '/assets/'); |
|
10 | +DEFINE('WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR', WPSPDTVARIATION_INTERFACE_PATH . '/templates/'); |
|
11 | +DEFINE('WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR', WPSPDTVARIATION_INTERFACE_URL . '/assets/'); |
|
12 | 12 | |
13 | 13 | |
14 | 14 | /** Inclusion des différents composants / Include plugin components */ |
15 | -require_once( WPSPDTVARIATION_INTERFACE_PATH . 'controller/wps_product_variation_interface.ctr.php' ); |
|
15 | +require_once(WPSPDTVARIATION_INTERFACE_PATH . 'controller/wps_product_variation_interface.ctr.php'); |
|
16 | 16 | /** Instanciation du controlleur principal / Main controller instanciation */ |
17 | 17 | $wps_product_variation_interface = new wps_product_variation_interface(); |
18 | 18 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( !defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | DEFINE( 'WPSPDTVARIATION_INTERFACE_VERSION', 1.0 ); |
5 | 7 | DEFINE( 'WPSPDTVARIATION_INTERFACE_DIR', basename( dirname( __FILE__ ) ) ); |
@@ -1,4 +1,4 @@ discard block |
||
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 | * |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function __construct() { |
21 | 21 | /** Affiche un formulaire permettant de créer un produit / Display a form allowing to add a new product */ |
22 | - add_action( 'wp_ajax_wps-product-quick-creation', array( $this, 'product_creation' ) ); |
|
23 | - add_action( 'wp_ajax_wps-product-quick-add-reload-attribute-list', array( $this, 'attribute_list_reload' ) ); |
|
24 | - add_action( 'wp_ajax_wps-product-quick-add', array( $this, 'create_product' ) ); |
|
22 | + add_action('wp_ajax_wps-product-quick-creation', array($this, 'product_creation')); |
|
23 | + add_action('wp_ajax_wps-product-quick-add-reload-attribute-list', array($this, 'attribute_list_reload')); |
|
24 | + add_action('wp_ajax_wps-product-quick-add', array($this, 'create_product')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param integer $chosen_set Le groupe d'attribut dont on veut afficher les champs / Attribute set we want display input for |
31 | 31 | */ |
32 | - function display_attribute( $chosen_set = 0 ) { |
|
33 | - require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list" ) ); |
|
32 | + function display_attribute($chosen_set = 0) { |
|
33 | + require_once(wpshop_tools::get_template_part(WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "attribute", "list")); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * AJAX - Charge le fomulaire d'ajout rapide d'un produit / Load the form for new product quick add |
38 | 38 | */ |
39 | 39 | function product_creation() { |
40 | - $_wpnonce = !empty( $_POST['wps-nonce'] ) ? sanitize_text_field( $_POST['wps-nonce'] ) : ''; |
|
41 | - if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) ) |
|
40 | + $_wpnonce = !empty($_POST['wps-nonce']) ? sanitize_text_field($_POST['wps-nonce']) : ''; |
|
41 | + if (!wp_verify_nonce($_wpnonce, 'wps-product-quick-nonce')) |
|
42 | 42 | wp_die(); |
43 | 43 | |
44 | - require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) ); |
|
44 | + require_once(wpshop_tools::get_template_part(WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation")); |
|
45 | 45 | wp_die( ); |
46 | 46 | } |
47 | 47 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * 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 |
50 | 50 | */ |
51 | 51 | function attribute_list_reload() { |
52 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
52 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
53 | 53 | |
54 | - if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) ) |
|
54 | + if (!wp_verify_nonce($_wpnonce, 'attribute_list_reload')) |
|
55 | 55 | wp_die(); |
56 | 56 | |
57 | - $attribute_set = !empty( $_POST['attribute_set'] ) ? (int) $_POST['attribute_set'] : 0; |
|
58 | - $this->display_attribute( $attribute_set ); |
|
57 | + $attribute_set = !empty($_POST['attribute_set']) ? (int)$_POST['attribute_set'] : 0; |
|
58 | + $this->display_attribute($attribute_set); |
|
59 | 59 | wp_die( ); |
60 | 60 | } |
61 | 61 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * AJAX - Création d'un nouveau produit / Create a new product |
64 | 64 | */ |
65 | 65 | function create_product() { |
66 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
66 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
67 | 67 | |
68 | - if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) ) |
|
68 | + if (!wp_verify_nonce($_wpnonce, 'create_product')) |
|
69 | 69 | wp_die(); |
70 | 70 | |
71 | 71 | global $wpdb; |
@@ -75,51 +75,51 @@ discard block |
||
75 | 75 | 'pid' => -1, |
76 | 76 | ); |
77 | 77 | |
78 | - $post_title = ( !empty($_POST['post_title']) ) ? sanitize_text_field( $_POST['post_title'] ) : -1; |
|
79 | - $post_content = ( !empty($_POST['post_content']) ) ? sanitize_text_field( $_POST['post_content'] ) : ''; |
|
80 | - $attributes = ( !empty($_POST['attribute']) ) ? (array)$_POST['attribute'] : array(); |
|
81 | - $id_attribute_set = ( !empty($_POST['wps-product-attribute-set']) ) ? (int) $_POST['wps-product-attribute-set'] : -1; |
|
78 | + $post_title = (!empty($_POST['post_title'])) ? sanitize_text_field($_POST['post_title']) : -1; |
|
79 | + $post_content = (!empty($_POST['post_content'])) ? sanitize_text_field($_POST['post_content']) : ''; |
|
80 | + $attributes = (!empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array(); |
|
81 | + $id_attribute_set = (!empty($_POST['wps-product-attribute-set'])) ? (int)$_POST['wps-product-attribute-set'] : -1; |
|
82 | 82 | |
83 | 83 | $post_type = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT; |
84 | - $attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity( wpshop_entities::get_entity_identifier_from_code( 'wpshop_product' ) ); |
|
85 | - foreach( $attribute_set_list as $attribute_set ) { |
|
86 | - if( $id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product' ) { |
|
84 | + $attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code('wpshop_product')); |
|
85 | + foreach ($attribute_set_list as $attribute_set) { |
|
86 | + if ($id_attribute_set == $attribute_set->id && $attribute_set->slug == 'free_product') { |
|
87 | 87 | $post_type = 'free_product'; |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - if( ( -1 != $post_title ) && ( -1 != $id_attribute_set ) ) { |
|
92 | - $new_product_id = wp_insert_post( array( |
|
91 | + if (( -1 != $post_title ) && ( -1 != $id_attribute_set )) { |
|
92 | + $new_product_id = wp_insert_post(array( |
|
93 | 93 | 'post_type' => $post_type, |
94 | 94 | 'post_status' => 'publish', |
95 | 95 | 'post_title' => $post_title, |
96 | 96 | 'post_content' => $post_content, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - if( !is_wp_error( $new_product_id ) ) { |
|
100 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set ); |
|
101 | - $data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $new_product_id ); |
|
102 | - $data_to_save['wpshop_product_attribute'] = ( !empty($attributes) ) ? $attributes : array(); |
|
99 | + if (!is_wp_error($new_product_id)) { |
|
100 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set); |
|
101 | + $data_to_save['post_ID'] = $data_to_save['product_id'] = intval($new_product_id); |
|
102 | + $data_to_save['wpshop_product_attribute'] = (!empty($attributes)) ? $attributes : array(); |
|
103 | 103 | $data_to_save['user_ID'] = get_current_user_id(); |
104 | 104 | $data_to_save['action'] = 'editpost'; |
105 | - $response[ 'pid' ] = $new_product_id; |
|
106 | - $response[ 'status' ] = false; |
|
107 | - $response[ 'output' ] = __('Product created partially!', 'wpshop'); |
|
108 | - if( !empty( $new_product_id ) && !empty( $data_to_save['user_ID'] ) ) { |
|
105 | + $response['pid'] = $new_product_id; |
|
106 | + $response['status'] = false; |
|
107 | + $response['output'] = __('Product created partially!', 'wpshop'); |
|
108 | + if (!empty($new_product_id) && !empty($data_to_save['user_ID'])) { |
|
109 | 109 | $product_class = new wpshop_products(); |
110 | - $product_class->save_product_custom_informations( $new_product_id, $data_to_save ); |
|
111 | - $response[ 'status' ] = true; |
|
112 | - $response[ 'output' ] = __('Product created successfully.', 'wpshop'); |
|
110 | + $product_class->save_product_custom_informations($new_product_id, $data_to_save); |
|
111 | + $response['status'] = true; |
|
112 | + $response['output'] = __('Product created successfully.', 'wpshop'); |
|
113 | 113 | } |
114 | 114 | |
115 | - $wps_quick_creation_hook = do_action( 'wps-new-product-quick-created', $new_product_id ); |
|
116 | - if ( !empty( $wps_quick_creation_hook ) ) { |
|
117 | - $response[ '' ] = $wps_quick_creation_hook; |
|
115 | + $wps_quick_creation_hook = do_action('wps-new-product-quick-created', $new_product_id); |
|
116 | + if (!empty($wps_quick_creation_hook)) { |
|
117 | + $response[''] = $wps_quick_creation_hook; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - wp_die( json_encode( $response ) ); |
|
122 | + wp_die(json_encode($response)); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | } |
@@ -1,4 +1,6 @@ discard block |
||
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 | * |
@@ -38,8 +40,9 @@ discard block |
||
38 | 40 | */ |
39 | 41 | function product_creation() { |
40 | 42 | $_wpnonce = !empty( $_POST['wps-nonce'] ) ? sanitize_text_field( $_POST['wps-nonce'] ) : ''; |
41 | - if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) ) |
|
42 | - wp_die(); |
|
43 | + if ( !wp_verify_nonce( $_wpnonce, 'wps-product-quick-nonce' ) ) { |
|
44 | + wp_die(); |
|
45 | + } |
|
43 | 46 | |
44 | 47 | require_once( wpshop_tools::get_template_part( WPSPDTQUICK_DIR, WPSPDTQUICK_TEMPLATES_MAIN_DIR, "backend", "product_creation" ) ); |
45 | 48 | wp_die( ); |
@@ -51,8 +54,9 @@ discard block |
||
51 | 54 | function attribute_list_reload() { |
52 | 55 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
53 | 56 | |
54 | - if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) ) |
|
55 | - wp_die(); |
|
57 | + if ( !wp_verify_nonce( $_wpnonce, 'attribute_list_reload' ) ) { |
|
58 | + wp_die(); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | $attribute_set = !empty( $_POST['attribute_set'] ) ? (int) $_POST['attribute_set'] : 0; |
58 | 62 | $this->display_attribute( $attribute_set ); |
@@ -65,8 +69,9 @@ discard block |
||
65 | 69 | function create_product() { |
66 | 70 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
67 | 71 | |
68 | - if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) ) |
|
69 | - wp_die(); |
|
72 | + if ( !wp_verify_nonce( $_wpnonce, 'create_product' ) ) { |
|
73 | + wp_die(); |
|
74 | + } |
|
70 | 75 | |
71 | 76 | global $wpdb; |
72 | 77 | $response = array( |
@@ -1,25 +1,25 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wrap"> |
4 | - <h2><span class="dashicons dashicons-update" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e( 'Mass edit products interface', 'wpshop')?><button class="add-new-h2" data-nonce="<?php echo wp_create_nonce( 'wps_mass_interface_new_product_creation' ); ?>" id="wps-mass-interface-button-new-product"><i class="wps-icon-pencil"></i> <?php _e( 'Create a new product', 'wpshop'); ?></button></h2> |
|
4 | + <h2><span class="dashicons dashicons-update" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e('Mass edit products interface', 'wpshop')?><button class="add-new-h2" data-nonce="<?php echo wp_create_nonce('wps_mass_interface_new_product_creation'); ?>" id="wps-mass-interface-button-new-product"><i class="wps-icon-pencil"></i> <?php _e('Create a new product', 'wpshop'); ?></button></h2> |
|
5 | 5 | |
6 | 6 | |
7 | 7 | <div class="wps-boxed"> |
8 | 8 | <div class="wps-row wps-gridwrapper3-padded"> |
9 | 9 | <div> |
10 | 10 | <div class="wps-form-group"> |
11 | - <?php if( !empty($products_attributes_groups) ): ?> |
|
12 | - <?php if ( 1 < count( $products_attributes_groups ) ) : ?> |
|
13 | - <label><?php _e( 'Products Attributes groups', 'wpshop' ); ?> : </label> |
|
11 | + <?php if (!empty($products_attributes_groups)): ?> |
|
12 | + <?php if (1 < count($products_attributes_groups)) : ?> |
|
13 | + <label><?php _e('Products Attributes groups', 'wpshop'); ?> : </label> |
|
14 | 14 | <div class="wps-form"> |
15 | 15 | <select id="wps_mass_edit_products_default_attributes_set" name="wps_mass_edit_products_default_attributes_set" > |
16 | - <?php foreach( $products_attributes_groups as $products_attributes_group ) : ?> |
|
17 | - <option value="<?php echo $products_attributes_group->id; ?>" <?php echo ( (!empty($products_attributes_group->default_set) && $products_attributes_group->default_set == 'yes' ) ? 'selected="selected"' : '' ); ?> ><?php echo $products_attributes_group->name; ?></option> |
|
16 | + <?php foreach ($products_attributes_groups as $products_attributes_group) : ?> |
|
17 | + <option value="<?php echo $products_attributes_group->id; ?>" <?php echo ((!empty($products_attributes_group->default_set) && $products_attributes_group->default_set == 'yes') ? 'selected="selected"' : ''); ?> ><?php echo $products_attributes_group->name; ?></option> |
|
18 | 18 | <?php endforeach; ?> |
19 | 19 | </select> |
20 | 20 | </div> |
21 | 21 | <?php else: ?> |
22 | - <input type="hidden" id="wps_mass_edit_products_default_attributes_set" name="wps_mass_edit_products_default_attributes_set" value="<?php echo $products_attributes_groups[ 0 ]->id; ?>" /> |
|
22 | + <input type="hidden" id="wps_mass_edit_products_default_attributes_set" name="wps_mass_edit_products_default_attributes_set" value="<?php echo $products_attributes_groups[0]->id; ?>" /> |
|
23 | 23 | <?php endif; ?> |
24 | 24 | <?php endif; ?> |
25 | 25 | </div> |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | <div> </div> |
30 | 30 | |
31 | 31 | <div> |
32 | - <div style="width : 100%; margin-top : 20px" class="alignright"><button class="button-primary alignright wps-mass-interface-button-save"><i class="wps-icon-save"></i> <?php _e( 'Save selected products', 'wpshop' ); ?> </button></div> |
|
32 | + <div style="width : 100%; margin-top : 20px" class="alignright"><button class="button-primary alignright wps-mass-interface-button-save"><i class="wps-icon-save"></i> <?php _e('Save selected products', 'wpshop'); ?> </button></div> |
|
33 | 33 | </div> |
34 | 34 | |
35 | 35 | </div> |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | <div style="display : none" class="wps-alert-error"></div> |
39 | 39 | <div style="display : none" class="wps-alert-success"></div> |
40 | 40 | |
41 | -<div id="wps_mass_products_edit_tab_container" data-nonce="<?php echo wp_create_nonce( 'wps_mass_edit_change_page' ); ?>"> |
|
41 | +<div id="wps_mass_products_edit_tab_container" data-nonce="<?php echo wp_create_nonce('wps_mass_edit_change_page'); ?>"> |
|
42 | 42 | |
43 | 43 | <?php echo $product_list_interface; ?> |
44 | 44 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div class="wrap"> |
4 | 6 | <h2><span class="dashicons dashicons-update" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e( 'Mass edit products interface', 'wpshop')?><button class="add-new-h2" data-nonce="<?php echo wp_create_nonce( 'wps_mass_interface_new_product_creation' ); ?>" id="wps-mass-interface-button-new-product"><i class="wps-icon-pencil"></i> <?php _e( 'Create a new product', 'wpshop'); ?></button></h2> |
@@ -18,8 +20,11 @@ discard block |
||
18 | 20 | <?php endforeach; ?> |
19 | 21 | </select> |
20 | 22 | </div> |
21 | - <?php else: ?> |
|
22 | - <input type="hidden" id="wps_mass_edit_products_default_attributes_set" name="wps_mass_edit_products_default_attributes_set" value="<?php echo $products_attributes_groups[ 0 ]->id; ?>" /> |
|
23 | + <?php else { |
|
24 | + : ?> |
|
25 | + <input type="hidden" id="wps_mass_edit_products_default_attributes_set" name="wps_mass_edit_products_default_attributes_set" value="<?php echo $products_attributes_groups[ 0 ]->id; |
|
26 | +} |
|
27 | +?>" /> |
|
23 | 28 | <?php endif; ?> |
24 | 29 | <?php endif; ?> |
25 | 30 | </div> |
@@ -1,32 +1,32 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
2 | -<form id="wps-checkout-valid-step-five-form" method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" class="wps-checkout-wrapper"> |
|
1 | +<?php if (!defined('ABSPATH')) exit; ?> |
|
2 | +<form id="wps-checkout-valid-step-five-form" method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" class="wps-checkout-wrapper"> |
|
3 | 3 | <div class="wps-sidebar-resume"> |
4 | 4 | <input type="hidden" name="action" value="wps-checkout_valid_step_five"/> |
5 | - <?php wp_nonce_field( 'wps_checkout_valid_step_five' ); ?> |
|
6 | - <?php echo do_shortcode( '[wps_resume_cart]' ); ?> |
|
5 | + <?php wp_nonce_field('wps_checkout_valid_step_five'); ?> |
|
6 | + <?php echo do_shortcode('[wps_resume_cart]'); ?> |
|
7 | 7 | </div> |
8 | 8 | <div class="wps-checkout-content"> |
9 | 9 | |
10 | - <?php echo do_shortcode('[wps_payment]' ); ?> |
|
10 | + <?php echo do_shortcode('[wps_payment]'); ?> |
|
11 | 11 | |
12 | 12 | <div class="wps-form-group wps-comment-box"> |
13 | - <label><?php _e( 'Customer comment', 'wpshop'); ?> : </label> |
|
13 | + <label><?php _e('Customer comment', 'wpshop'); ?> : </label> |
|
14 | 14 | <div class="wps-form"> |
15 | 15 | <textarea name="wps-customer-comment" id="wps-customer-comment"></textarea> |
16 | 16 | </div> |
17 | 17 | </div> |
18 | 18 | |
19 | 19 | <!-- Terms of sale --> |
20 | - <?php $terms_page_id = get_option( 'wpshop_terms_of_sale_page_id' ); |
|
21 | - if(0 != $terms_page_id): ?> |
|
22 | - <div class="wps-cgv-line"><label for="terms_of_sale"><input type="hidden" name="terms_of_sale_indicator" value="1" /><input id="terms_of_sale" type="checkbox" value="1" name="terms_of_sale"> <?php printf( __('I have read and I accept the %sterms of sale%s.', 'wpshop'), '<a href="' . get_permalink( wpshop_tools::get_page_id( get_option('wpshop_terms_of_sale_page_id') ) ) . '" target="_blank">', '</a>'); ?></label></div> |
|
20 | + <?php $terms_page_id = get_option('wpshop_terms_of_sale_page_id'); |
|
21 | + if (0 != $terms_page_id): ?> |
|
22 | + <div class="wps-cgv-line"><label for="terms_of_sale"><input type="hidden" name="terms_of_sale_indicator" value="1" /><input id="terms_of_sale" type="checkbox" value="1" name="terms_of_sale"> <?php printf(__('I have read and I accept the %sterms of sale%s.', 'wpshop'), '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_terms_of_sale_page_id'))) . '" target="_blank">', '</a>'); ?></label></div> |
|
23 | 23 | <?php endif; ?> |
24 | 24 | |
25 | 25 | <div id="wps-checkout-step-errors"></div> |
26 | - <?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?> |
|
27 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e( 'Validate my quotation', 'wpshop' ); ?></button></div> |
|
26 | + <?php if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') : ?> |
|
27 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e('Validate my quotation', 'wpshop'); ?></button></div> |
|
28 | 28 | <?php else : ?> |
29 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e( 'Order', 'wpshop' ); ?></button></div> |
|
29 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e('Order', 'wpshop'); ?></button></div> |
|
30 | 30 | <?php endif; ?> |
31 | 31 | </div> |
32 | 32 | </form> |
@@ -1,4 +1,7 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
4 | +?> |
|
2 | 5 | <form id="wps-checkout-valid-step-five-form" method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" class="wps-checkout-wrapper"> |
3 | 6 | <div class="wps-sidebar-resume"> |
4 | 7 | <input type="hidden" name="action" value="wps-checkout_valid_step_five"/> |
@@ -25,8 +28,11 @@ discard block |
||
25 | 28 | <div id="wps-checkout-step-errors"></div> |
26 | 29 | <?php if( !empty( $_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation' ) : ?> |
27 | 30 | <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e( 'Validate my quotation', 'wpshop' ); ?></button></div> |
28 | - <?php else : ?> |
|
29 | - <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e( 'Order', 'wpshop' ); ?></button></div> |
|
31 | + <?php else { |
|
32 | + : ?> |
|
33 | + <div class="wps"><button class="wps-bton-first-alignRight-rounded" id="wps-checkout-valid-step-five"><?php _e( 'Order', 'wpshop' ); |
|
34 | +} |
|
35 | +?></button></div> |
|
30 | 36 | <?php endif; ?> |
31 | 37 | </div> |
32 | 38 | </form> |
@@ -1,6 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | $order_meta = get_post_meta($_SESSION['order_id'], '_order_postmeta', true); |
3 | -if( !empty( $order_meta ) ) { |
|
3 | +if (!empty($order_meta)) { |
|
4 | 4 | ?> |
5 | 5 | <div style="text-align: center;"> |
6 | 6 | <script> |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | }); |
26 | 26 | </script> |
27 | 27 | <a class="wps-bton-first" role="button" href="<?php echo get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))); ?>"><?php echo __('My account', 'wpshop'); ?></a> |
28 | - <button data-nonce="<?php echo wp_create_nonce( 'wps_orders_load_details' ); ?>" class="wps-bton-second wps-orders-details-opener" id="wps-order-details-opener-<?php echo $_SESSION['order_id']; ?>"><?php _e( 'Order details', 'wpshop' ); ?></button> |
|
29 | - <?php if ( !empty( $order_meta ) && !empty( $order_meta[ 'order_invoice_ref' ] ) ) : ?> |
|
30 | - <a href="<?php echo admin_url( 'admin-post.php?action=wps_invoice&order_id='.$_SESSION['order_id'].'&invoice_ref='.$order_meta[ 'order_invoice_ref' ].'&mode=pdf' ); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e( 'Download invoice', 'wpshop' ); ?></a> |
|
28 | + <button data-nonce="<?php echo wp_create_nonce('wps_orders_load_details'); ?>" class="wps-bton-second wps-orders-details-opener" id="wps-order-details-opener-<?php echo $_SESSION['order_id']; ?>"><?php _e('Order details', 'wpshop'); ?></button> |
|
29 | + <?php if (!empty($order_meta) && !empty($order_meta['order_invoice_ref'])) : ?> |
|
30 | + <a href="<?php echo admin_url('admin-post.php?action=wps_invoice&order_id=' . $_SESSION['order_id'] . '&invoice_ref=' . $order_meta['order_invoice_ref'] . '&mode=pdf'); ?>" target="_blank" class="wps-bton-third" role="button"><?php _e('Download invoice', 'wpshop'); ?></a> |
|
31 | 31 | <?php endif; ?> |
32 | 32 | </div> |
33 | 33 | <?php } ?> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | $order_meta = get_post_meta($_SESSION['order_id'], '_order_postmeta', true); |
3 | 5 | if( !empty( $order_meta ) ) { |
4 | 6 | ?> |
@@ -1,4 +1,7 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
4 | +?> |
|
2 | 5 | <div class="wpspos-customer-selected" > |
3 | 6 | <?php if ( !empty( $customer_infos ) ) : ?> |
4 | 7 | <div class="customer_info wps-boxed"> |
@@ -68,7 +71,10 @@ discard block |
||
68 | 71 | ?> |
69 | 72 | </div> |
70 | 73 | |
71 | - <?php else : ?> |
|
72 | - <?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' ); ?> |
|
74 | + <?php else { |
|
75 | + : ?> |
|
76 | + <?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' ); |
|
77 | +} |
|
78 | +?> |
|
73 | 79 | <?php endif; ?> |
74 | 80 | </div> |
@@ -1,8 +1,8 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; ?> |
|
1 | +<?php if (!defined('ABSPATH')) exit; ?> |
|
2 | 2 | <div class="wpspos-customer-selected" > |
3 | - <?php if ( !empty( $customer_infos ) ) : ?> |
|
3 | + <?php if (!empty($customer_infos)) : ?> |
|
4 | 4 | <div class="customer_info wps-boxed"> |
5 | - <span class="wps-h4"><?php _e( 'Account', 'wpshop' ); ?></span> |
|
5 | + <span class="wps-h4"><?php _e('Account', 'wpshop'); ?></span> |
|
6 | 6 | <div class="wps-form-group"><?php _e('Customer last name', 'wps-pos-i18n')?> : <?php echo $customer_infos->last_name; ?></div> |
7 | 7 | <div class="wps-form-group"><?php _e('Customer first name', 'wps-pos-i18n')?> : <?php echo $customer_infos->first_name; ?></div> |
8 | 8 | <div class="wps-form-group"><?php _e('Customer email', 'wps-pos-i18n')?> : <?php echo $customer_infos->user_email; ?></div> |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | </div> |
11 | 11 | |
12 | 12 | <div class="customer_address wps-boxed"> |
13 | - <span class="wps-h4"><?php _e( 'Billing address', 'wpshop' ); ?></span> |
|
13 | + <span class="wps-h4"><?php _e('Billing address', 'wpshop'); ?></span> |
|
14 | 14 | <?php |
15 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
16 | - $addresses_customer = wps_address::get_addresses_list_no_hidden_attributes( $customer_id ); |
|
17 | - if( !empty($addresses_customer[$billing_option['choice']]) ) { |
|
15 | + $billing_option = get_option('wpshop_billing_address'); |
|
16 | + $addresses_customer = wps_address::get_addresses_list_no_hidden_attributes($customer_id); |
|
17 | + if (!empty($addresses_customer[$billing_option['choice']])) { |
|
18 | 18 | $billing = reset($addresses_customer[$billing_option['choice']]); |
19 | 19 | //echo '<strong>' . $billing['address_title']['value'] . '</strong>' . '' . '<br>'; |
20 | - echo isset($billing['civility']) ? __( wpshop_attributes::get_attribute_type_select_option_info($billing['civility']['value'], 'label', 'custom') ): ''; |
|
20 | + echo isset($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility']['value'], 'label', 'custom')) : ''; |
|
21 | 21 | echo ' <strong>' . (isset($billing['address_first_name']) ? $billing['address_first_name']['value'] : '') . ' ' . (isset($billing['address_last_name']) ? $billing['address_last_name']['value'] : '') . '</strong><br>'; |
22 | 22 | echo (isset($billing['address']) ? $billing['address']['value'] : '') . '<br>'; |
23 | 23 | echo (isset($billing['city']) ? $billing['city']['value'] . ' ' : '') . (isset($billing['postcode']) ? $billing['postcode']['value'] . ' ' : '') . (isset($billing['country']) ? $billing['country']['value'] : '') . '<br>'; |
@@ -27,35 +27,35 @@ discard block |
||
27 | 27 | |
28 | 28 | <div class="order_historic wps-boxed"> |
29 | 29 | <a href="#" class="toggle-historic dashicons dashicons-arrow-down alignright"></a> |
30 | - <span class="wps-h4"><?php _e( 'Historic', 'wpshop' ); ?></span> |
|
30 | + <span class="wps-h4"><?php _e('Historic', 'wpshop'); ?></span> |
|
31 | 31 | <?php |
32 | - foreach( $this->get_orders_customer( 3, $customer_id ) as $order ) { |
|
32 | + foreach ($this->get_orders_customer(3, $customer_id) as $order) { |
|
33 | 33 | ?> |
34 | 34 | <div class="wps-form-group toggle-historic-group"> |
35 | - <a href="#" class="lnk_load_order" data-display-nonce="<?php echo wp_create_nonce( 'wps_pos_order_content' ); ?>" data-finish-nonce="<?php echo wp_create_nonce( 'wps_pos_process_checkout' ); ?>" data-oid="<?php echo $order->ID; ?>" data-cid="<?php echo $customer_id; ?>"> |
|
35 | + <a href="#" class="lnk_load_order" data-display-nonce="<?php echo wp_create_nonce('wps_pos_order_content'); ?>" data-finish-nonce="<?php echo wp_create_nonce('wps_pos_process_checkout'); ?>" data-oid="<?php echo $order->ID; ?>" data-cid="<?php echo $customer_id; ?>"> |
|
36 | 36 | <?php |
37 | - if( $order->_order_postmeta['order_key'] ) { |
|
38 | - if( $order->_order_postmeta['order_invoice_ref'] ) { |
|
37 | + if ($order->_order_postmeta['order_key']) { |
|
38 | + if ($order->_order_postmeta['order_invoice_ref']) { |
|
39 | 39 | $link = $order->_order_postmeta['order_invoice_ref']; |
40 | 40 | } else { |
41 | 41 | $link = $order->_order_postmeta['order_key']; |
42 | 42 | } |
43 | 43 | } else { |
44 | - $link = __( 'Order summary ', 'wpshop' ); |
|
44 | + $link = __('Order summary ', 'wpshop'); |
|
45 | 45 | } |
46 | 46 | echo $link; |
47 | 47 | ?> |
48 | 48 | </a> |
49 | - <span class="price_order"><?php echo number_format( round($order->_order_postmeta['order_grand_total'], 2), 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency( false ); ?></span> |
|
50 | - <span class="date_order"><?php echo date("d/m/Y | H:i:s", strtotime( $order->_order_postmeta['order_date'] ) ); ?></span> |
|
49 | + <span class="price_order"><?php echo number_format(round($order->_order_postmeta['order_grand_total'], 2), 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false); ?></span> |
|
50 | + <span class="date_order"><?php echo date("d/m/Y | H:i:s", strtotime($order->_order_postmeta['order_date'])); ?></span> |
|
51 | 51 | <?php |
52 | - if( $order->_order_postmeta['order_invoice_ref'] ) { |
|
52 | + if ($order->_order_postmeta['order_invoice_ref']) { |
|
53 | 53 | ?> |
54 | 54 | <span class="invoice_order"> |
55 | 55 | <a href="" target="_blank" role="button"> |
56 | 56 | <i class="dashicons dashicons-welcome-view-site"></i> |
57 | 57 | </a> |
58 | - <a href="<?php echo admin_url( 'admin-post.php?action=wps_invoice&mode=pdf&order_id=' . $order->ID . '&invoice_ref='.$order->_order_postmeta['order_invoice_ref']); ?>" target="_blank" role="button"> |
|
58 | + <a href="<?php echo admin_url('admin-post.php?action=wps_invoice&mode=pdf&order_id=' . $order->ID . '&invoice_ref=' . $order->_order_postmeta['order_invoice_ref']); ?>" target="_blank" role="button"> |
|
59 | 59 | <i class="dashicons dashicons-download"></i> |
60 | 60 | </a> |
61 | 61 | </span> |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | </div> |
70 | 70 | |
71 | 71 | <?php else : ?> |
72 | - <?php _e( 'Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n' ); ?> |
|
72 | + <?php _e('Nothing was found for selected customer. Please check this customer account before continuing', 'wps-pos-i18n'); ?> |
|
73 | 73 | <?php endif; ?> |
74 | 74 | </div> |