@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | public static function admin_menu() { |
185 | 185 | global $submenu; |
186 | 186 | $attributeEntitySetList = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode)); |
187 | - $entities_to_unset = array( 'free_product', 'default' ); |
|
187 | + $entities_to_unset = array('free_product', 'default'); |
|
188 | 188 | $submenu_before = $submenu['edit.php?post_type=wpshop_product']; |
189 | 189 | foreach ($attributeEntitySetList as $key_attribute_set => $attribute_set) { |
190 | - if ( !( in_array( $attribute_set->slug, $entities_to_unset ) || in_array( $attribute_set->name, $entities_to_unset ) ) ) { |
|
191 | - add_submenu_page( 'edit.php?post_type=wpshop_product', sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product'); |
|
190 | + if (!(in_array($attribute_set->slug, $entities_to_unset) || in_array($attribute_set->name, $entities_to_unset))) { |
|
191 | + add_submenu_page('edit.php?post_type=wpshop_product', sprintf(__('Add %s', 'wpshop'), $attribute_set->name), sprintf(__('Add %s', 'wpshop'), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product'); |
|
192 | 192 | } |
193 | 193 | } |
194 | - $submenu_new_elements = array_diff_key ( $submenu['edit.php?post_type=wpshop_product'], $submenu_before ); |
|
194 | + $submenu_new_elements = array_diff_key($submenu['edit.php?post_type=wpshop_product'], $submenu_before); |
|
195 | 195 | $submenu_reorder = array(); |
196 | - foreach( $submenu_before as $key => $element ) { |
|
197 | - if( empty( $submenu_reorder[$key] ) ) { |
|
196 | + foreach ($submenu_before as $key => $element) { |
|
197 | + if (empty($submenu_reorder[$key])) { |
|
198 | 198 | $submenu_reorder[$key] = $element; |
199 | - if( in_array( 'post-new.php?post_type=wpshop_product', $element ) ) { |
|
200 | - $submenu_reorder = array_merge( $submenu_reorder, array_values( $submenu_new_elements ) ); |
|
199 | + if (in_array('post-new.php?post_type=wpshop_product', $element)) { |
|
200 | + $submenu_reorder = array_merge($submenu_reorder, array_values($submenu_new_elements)); |
|
201 | 201 | } |
202 | 202 | } else { |
203 | 203 | $submenu_reorder[] = $element; |
@@ -604,12 +604,12 @@ discard block |
||
604 | 604 | |
605 | 605 | $products = array(); |
606 | 606 | $query = "SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code=%s"; |
607 | - $data = (array) $wpdb->get_row($wpdb->prepare($query, $attr_name)); |
|
607 | + $data = (array)$wpdb->get_row($wpdb->prepare($query, $attr_name)); |
|
608 | 608 | |
609 | 609 | if (!empty($data)) { |
610 | 610 | if ($data['data_type_to_use'] == 'custom') { |
611 | 611 | // Find which table to take |
612 | - if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME;} elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL;} elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER;} elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;} elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT;} elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR;} |
|
612 | + if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; } elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; } elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; } elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; } elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; } elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; } |
|
613 | 613 | |
614 | 614 | if (isset($table_name)) { |
615 | 615 | // If the value is an id of a select, radio or checkbox |
@@ -759,11 +759,11 @@ discard block |
||
759 | 759 | if (!empty($atts['product_type'])) { |
760 | 760 | switch ($atts['product_type']) { |
761 | 761 | case 'related': |
762 | - $product_id = !empty($atts['pid']) ? (int) $atts['pid'] : get_the_ID(); |
|
762 | + $product_id = !empty($atts['pid']) ? (int)$atts['pid'] : get_the_ID(); |
|
763 | 763 | $type = !empty($atts['display_mode']) && in_array($atts['display_mode'], array('list', 'grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE; |
764 | 764 | $grid_element_nb_per_line = !empty($atts['grid_element_nb_per_line']) ? $atts['grid_element_nb_per_line'] : WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE; |
765 | 765 | |
766 | - $pids = get_post_meta((int) $product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true); |
|
766 | + $pids = get_post_meta((int)$product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true); |
|
767 | 767 | if (!empty($pids) && !empty($pids[0])) { |
768 | 768 | $pid = implode(',', $pids); |
769 | 769 | } |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | $sub_tpl_component = array(); |
833 | 833 | $criteria = ''; |
834 | 834 | foreach ($sorting_criteria as $c): |
835 | - $criteria .= '<option value="' . $c['code'] . '" ' . selected( $atts['order'], $c['code'], false ) . '>' . __($c['frontend_label'], 'wpshop') . '</option>'; |
|
835 | + $criteria .= '<option value="' . $c['code'] . '" ' . selected($atts['order'], $c['code'], false) . '>' . __($c['frontend_label'], 'wpshop') . '</option>'; |
|
836 | 836 | endforeach; |
837 | 837 | $sub_tpl_component['SORTING_CRITERIA_LIST'] = $criteria; |
838 | 838 | $tpl_component['SORTING_CRITERIA'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component); |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | // --------------------- // |
1002 | 1002 | // Pagination management // |
1003 | 1003 | // --------------------- // |
1004 | - if ( $display_pagination ) { |
|
1004 | + if ($display_pagination) { |
|
1005 | 1005 | if ($nb_of_product_limit == 0) { |
1006 | 1006 | |
1007 | 1007 | $paginate = paginate_links(array( |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | { |
1283 | 1283 | global $wpdb; |
1284 | 1284 | |
1285 | - $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array) $_REQUEST; |
|
1285 | + $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array)$_REQUEST; |
|
1286 | 1286 | // Apply a filter to extra actions |
1287 | 1287 | $data_to_save = apply_filters('wps_save_product_extra_filter', $data_to_save); |
1288 | 1288 | |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | $attributeValue = str_replace(',', '.', $attributeValue); |
1339 | 1339 | } |
1340 | 1340 | if (($attributeType == 'integer') && !is_array($attributeValue)) { |
1341 | - $attributeValue = (int) $attributeValue; |
|
1341 | + $attributeValue = (int)$attributeValue; |
|
1342 | 1342 | } |
1343 | 1343 | $productMetaDatas[$attributeCode] = $attributeValue; |
1344 | 1344 | } |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | $attributeValue = str_replace(',', '.', $attribute->$value_key); |
1389 | 1389 | } |
1390 | 1390 | if (($attribute->data_type == 'integer') && !is_array($attributeValue)) { |
1391 | - $attributeValue = (int) $attribute->$value_key; |
|
1391 | + $attributeValue = (int)$attribute->$value_key; |
|
1392 | 1392 | } |
1393 | 1393 | $variation_metadata[$attribute->code] = $attribute->$value_key; |
1394 | 1394 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $attributeValue = str_replace(',', '.', $attributeValue); |
1402 | 1402 | } |
1403 | 1403 | if (($attributeType == 'integer') && !is_array($attributeValue)) { |
1404 | - $attributeValue = (int) $attributeValue; |
|
1404 | + $attributeValue = (int)$attributeValue; |
|
1405 | 1405 | } |
1406 | 1406 | $variation_metadata[$attributeCode] = $attributeValue; |
1407 | 1407 | } |
@@ -1737,13 +1737,13 @@ discard block |
||
1737 | 1737 | if (!empty($product_price_infos)) { |
1738 | 1738 | $tpl_component_price = array(); |
1739 | 1739 | /** Price piloting **/ |
1740 | - $price_display_option = get_option( 'wpshop_catalog_product_option' ); |
|
1741 | - $tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) ? 'on' : ''; |
|
1740 | + $price_display_option = get_option('wpshop_catalog_product_option'); |
|
1741 | + $tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) ? 'on' : ''; |
|
1742 | 1742 | $price_ploting = get_option('wpshop_shop_price_piloting'); |
1743 | 1743 | $tpl_component_price['CROSSED_OUT_PRICE'] = (!empty($product_price_infos['CROSSED_OUT_PRICE'])) ? ((!empty($product_price_infos['PRICE_FROM'])) ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $product_price_infos['CROSSED_OUT_PRICE'])) : ''; |
1744 | 1744 | $variations = wpshop_products::get_variation($product_id); |
1745 | 1745 | $tpl_component_price['PRODUCT_PRICE'] = $product_price_infos['PRODUCT_PRICE']; |
1746 | - if(empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty( $tpl_component['PRICE_FROM'] ) ))) { |
|
1746 | + if (empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty($tpl_component['PRICE_FROM'])))) { |
|
1747 | 1747 | $tpl_component_price['PRODUCT_PRICE'] = __('Price from', 'wpshop') . ' ' . $tpl_component_price['PRODUCT_PRICE']; |
1748 | 1748 | } |
1749 | 1749 | $tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY']; |
@@ -2186,7 +2186,7 @@ discard block |
||
2186 | 2186 | } |
2187 | 2187 | |
2188 | 2188 | $template_part = ($variations_list && ($output_type == 'mini')) ? 'configure_product_button' : (!empty($productStock) ? 'add_to_cart_button' : 'unavailable_product_button'); |
2189 | - $template_part = apply_filters( 'wps_custom_add_to_cart_button', $template_part, $product_id ); |
|
2189 | + $template_part = apply_filters('wps_custom_add_to_cart_button', $template_part, $product_id); |
|
2190 | 2190 | |
2191 | 2191 | $tpl_component = array(); |
2192 | 2192 | $tpl_component['PRODUCT_ID'] = $product_id; |
@@ -3048,7 +3048,7 @@ discard block |
||
3048 | 3048 | $single_variations = array(); |
3049 | 3049 | foreach ($selected_variation as $attribute_code => $attribute_value) { |
3050 | 3050 | if (isset($attribute_value) && $attribute_code != 'free') { |
3051 | - $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int) $attribute_value)) . "'", $product_id); |
|
3051 | + $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int)$attribute_value)) . "'", $product_id); |
|
3052 | 3052 | $single_variation_id = $wpdb->get_var($query); |
3053 | 3053 | if (!empty($single_variation_id)) { |
3054 | 3054 | $single_variations[] = $single_variation_id; |
@@ -3150,7 +3150,7 @@ discard block |
||
3150 | 3150 | * Since 1.4.3.7 |
3151 | 3151 | * L'option du produit remplace le prix du produit de tête. |
3152 | 3152 | */ |
3153 | - if( true ) { |
|
3153 | + if (true) { |
|
3154 | 3154 | //Replace the product price |
3155 | 3155 | if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) { |
3156 | 3156 | $product_into_cart['price_ttc_before_discount'] = $variations_total_price['price_ati']; |
@@ -3517,16 +3517,16 @@ discard block |
||
3517 | 3517 | $variation_post_meta = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
3518 | 3518 | $variation_post_meta['options'] = $options; |
3519 | 3519 | $variation_post_meta['follow_general_config'] = true; |
3520 | - if( $variation_post_meta['follow_general_config'] ) { |
|
3520 | + if ($variation_post_meta['follow_general_config']) { |
|
3521 | 3521 | $shop_option = get_option('wpshop_catalog_product_option', array()); |
3522 | - if( isset( $shop_option ) ) { |
|
3522 | + if (isset($shop_option)) { |
|
3523 | 3523 | $variation_post_meta['options']['price_display'] = $shop_option['price_display']; |
3524 | 3524 | } |
3525 | 3525 | } |
3526 | 3526 | $variations = wpshop_attributes::get_variation_available_attribute($current_post_id); |
3527 | - if( !empty( $variations['available'] ) ) { |
|
3528 | - foreach( $variations['available'] as $key => $value ) { |
|
3529 | - if( !in_array( $value['attribute_complete_def']->code, $variation_post_meta['attributes'] ) ) { |
|
3527 | + if (!empty($variations['available'])) { |
|
3528 | + foreach ($variations['available'] as $key => $value) { |
|
3529 | + if (!in_array($value['attribute_complete_def']->code, $variation_post_meta['attributes'])) { |
|
3530 | 3530 | $variation_post_meta['attributes'][] = $value['attribute_complete_def']->code; |
3531 | 3531 | } |
3532 | 3532 | } |
@@ -1,19 +1,19 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | class wps_download_file_ctr { |
4 | 4 | public function __construct() { |
5 | - add_action( 'admin_post_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
6 | - add_action( 'admin_post_nopriv_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
5 | + add_action('admin_post_wps_download_file', array($this, 'wps_download_file')); |
|
6 | + add_action('admin_post_nopriv_wps_download_file', array($this, 'wps_download_file')); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | // Function to find download link by |
10 | - public static function get_product_download_link( $oid, $item ) { |
|
10 | + public static function get_product_download_link($oid, $item) { |
|
11 | 11 | $parent_def = array(); |
12 | 12 | $item_id = $item['item_id']; |
13 | - $item_post_type = get_post_type( $item['item_id'] ); |
|
14 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) { |
|
15 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
16 | - if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { |
|
13 | + $item_post_type = get_post_type($item['item_id']); |
|
14 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) { |
|
15 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
16 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
17 | 17 | $parent_post = $parent_def['parent_post']; |
18 | 18 | $item_id = $parent_post->ID; |
19 | 19 | } |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | $download_link = false; |
23 | 23 | $item_id_for_download = null; |
24 | 24 | /** Check if the product or the head product is a download product */ |
25 | - if ( ! empty( $parent_def ) ) { |
|
25 | + if (!empty($parent_def)) { |
|
26 | 26 | $parent_meta = $parent_def['parent_post_meta']; |
27 | - if ( ! empty( $parent_meta['is_downloadable_'] ) ) { |
|
27 | + if (!empty($parent_meta['is_downloadable_'])) { |
|
28 | 28 | global $wpdb; |
29 | - $downloadable_option_value = $wpdb->get_var( $wpdb->prepare( 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'] ) ); |
|
30 | - if ( ! empty( $downloadable_option_value ) ) { |
|
29 | + $downloadable_option_value = $wpdb->get_var($wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'])); |
|
30 | + if (!empty($downloadable_option_value)) { |
|
31 | 31 | $item['item_is_downloadable_'] = $downloadable_option_value; |
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
35 | - if ( ! empty( $item ) && ! empty( $item['item_is_downloadable_'] ) && ( strtolower( __( $item['item_is_downloadable_'], 'wpshop' ) ) === strtolower( __( 'Yes', 'wpshop' ) ) ) ) { |
|
35 | + if (!empty($item) && !empty($item['item_is_downloadable_']) && (strtolower(__($item['item_is_downloadable_'], 'wpshop')) === strtolower(__('Yes', 'wpshop')))) { |
|
36 | 36 | $item_id_for_download = $item_id; |
37 | - if ( isset( $item['item_meta']['variations'] ) ) { |
|
38 | - foreach ( $item['item_meta']['variations'] as $variation_id => $variation ) { |
|
39 | - if ( isset( $variation['item_meta']['is_downloadable_'] ) ) { |
|
37 | + if (isset($item['item_meta']['variations'])) { |
|
38 | + foreach ($item['item_meta']['variations'] as $variation_id => $variation) { |
|
39 | + if (isset($variation['item_meta']['is_downloadable_'])) { |
|
40 | 40 | $item_id_for_download = $item_id . '__' . $variation_id; |
41 | 41 | } |
42 | 42 | } |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** In case there is a item identifier defined for download */ |
47 | - if ( null !== $item_id_for_download ) { |
|
48 | - $download_codes = get_user_meta( get_current_user_id(), '_order_download_codes_' . $oid, true ); |
|
47 | + if (null !== $item_id_for_download) { |
|
48 | + $download_codes = get_user_meta(get_current_user_id(), '_order_download_codes_' . $oid, true); |
|
49 | 49 | /** Check if the current product exist into download code list, if not check if there is a composition between parent product and children product */ |
50 | - if ( empty( $download_codes[ $item_id_for_download ] ) ) { |
|
51 | - $item_id_component = explode( '__', $item_id_for_download ); |
|
52 | - if ( ! empty( $item_id_component ) && ( $item_id_component[0] !== $item_id_for_download ) ) { |
|
50 | + if (empty($download_codes[$item_id_for_download])) { |
|
51 | + $item_id_component = explode('__', $item_id_for_download); |
|
52 | + if (!empty($item_id_component) && ($item_id_component[0] !== $item_id_for_download)) { |
|
53 | 53 | $item_id_for_download = $item_id_component[0]; |
54 | - } elseif ( ! empty( $download_codes[ $item['item_id'] ] ) ) { |
|
54 | + } elseif (!empty($download_codes[$item['item_id']])) { |
|
55 | 55 | $item_id_for_download = $item['item_id']; |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - if ( ! empty( $download_codes ) && ! empty( $download_codes[ $item_id_for_download ] ) && ! empty( $download_codes[ $item_id_for_download ]['download_code'] ) ) { |
|
60 | - $download_link = admin_url( 'admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[ $item_id_for_download ]['download_code'] ); |
|
59 | + if (!empty($download_codes) && !empty($download_codes[$item_id_for_download]) && !empty($download_codes[$item_id_for_download]['download_code'])) { |
|
60 | + $download_link = admin_url('admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[$item_id_for_download]['download_code']); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | return $download_link; |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | |
66 | 66 | // Download product downloadable |
67 | 67 | public function wps_download_file() { |
68 | - $download = !empty( $_GET['download'] ) ? sanitize_text_field( $_GET['download'] ) : ''; |
|
69 | - $oid = !empty( $_GET['oid'] ) ? (int) $_GET['oid'] : 0; |
|
68 | + $download = !empty($_GET['download']) ? sanitize_text_field($_GET['download']) : ''; |
|
69 | + $oid = !empty($_GET['oid']) ? (int)$_GET['oid'] : 0; |
|
70 | 70 | |
71 | - if ( !empty( $download ) && !empty( $oid ) ) { |
|
71 | + if (!empty($download) && !empty($oid)) { |
|
72 | 72 | $variation_id = ''; |
73 | 73 | $order = get_post_meta($oid, '_order_postmeta', true); |
74 | - if(!empty($order) && !empty( $order['customer_id'] )) { |
|
75 | - $download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_'.$oid, true); |
|
76 | - if ( !empty($download_codes) && is_array($download_codes) ) { |
|
77 | - foreach ( $download_codes as $downloadable_product_id => $d ) { |
|
74 | + if (!empty($order) && !empty($order['customer_id'])) { |
|
75 | + $download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_' . $oid, true); |
|
76 | + if (!empty($download_codes) && is_array($download_codes)) { |
|
77 | + foreach ($download_codes as $downloadable_product_id => $d) { |
|
78 | 78 | $is_encrypted = false; |
79 | - if ( $d['download_code'] == $download ) { |
|
80 | - wpshop_tools::create_custom_hook ('encrypt_actions_for_downloadable_product', array( 'order_id' => $oid, 'download_product_id' => $downloadable_product_id ) ); |
|
79 | + if ($d['download_code'] == $download) { |
|
80 | + wpshop_tools::create_custom_hook('encrypt_actions_for_downloadable_product', array('order_id' => $oid, 'download_product_id' => $downloadable_product_id)); |
|
81 | 81 | |
82 | - if ( get_post_type( $downloadable_product_id ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
83 | - $parent_def = wpshop_products::get_parent_variation( $downloadable_product_id ); |
|
84 | - if ( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
82 | + if (get_post_type($downloadable_product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
83 | + $parent_def = wpshop_products::get_parent_variation($downloadable_product_id); |
|
84 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
85 | 85 | $parent_post = $parent_def['parent_post']; |
86 | 86 | $variation_id = $downloadable_product_id; |
87 | 87 | $downloadable_product_id = $parent_post->ID; |
88 | 88 | } |
89 | 89 | |
90 | 90 | } else { |
91 | - $downloadable_product_id = explode( "__", $downloadable_product_id ); |
|
92 | - $downloadable_product_id = isset( $downloadable_product_id[1] ) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
91 | + $downloadable_product_id = explode("__", $downloadable_product_id); |
|
92 | + $downloadable_product_id = isset($downloadable_product_id[1]) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $link = wpshop_attributes::get_attribute_option_output( |
@@ -97,24 +97,24 @@ discard block |
||
97 | 97 | 'is_downloadable_', 'file_url', $order |
98 | 98 | ); |
99 | 99 | |
100 | - if ( $link !== false ) { |
|
100 | + if ($link !== false) { |
|
101 | 101 | $uploads = wp_upload_dir(); |
102 | 102 | $basedir = $uploads['basedir']; |
103 | 103 | $pos = strpos($link, 'uploads'); |
104 | - $link = $basedir.substr($link,$pos+7); |
|
104 | + $link = $basedir . substr($link, $pos + 7); |
|
105 | 105 | /** If plugin is encrypted **/ |
106 | - $encrypted_plugin_path = get_post_meta( $oid, '_download_file_path_'.$oid.'_'.( ( !empty( $variation_id ) && get_post_type( $variation_id ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) ? $variation_id : $downloadable_product_id ), true); |
|
107 | - if ( !empty($encrypted_plugin_path) ) { |
|
108 | - $link = WPSHOP_UPLOAD_DIR.$encrypted_plugin_path; |
|
106 | + $encrypted_plugin_path = get_post_meta($oid, '_download_file_path_' . $oid . '_' . ((!empty($variation_id) && get_post_type($variation_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ? $variation_id : $downloadable_product_id), true); |
|
107 | + if (!empty($encrypted_plugin_path)) { |
|
108 | + $link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path; |
|
109 | 109 | $is_encrypted = true; |
110 | 110 | } |
111 | 111 | |
112 | - $overload_force_download = apply_filters( 'wps_download_file_overload_force_download', false ); |
|
113 | - if ( !$overload_force_download ) { |
|
112 | + $overload_force_download = apply_filters('wps_download_file_overload_force_download', false); |
|
113 | + if (!$overload_force_download) { |
|
114 | 114 | wpshop_tools::forceDownload($link, $is_encrypted); |
115 | 115 | } |
116 | 116 | else { |
117 | - wpshop_tools::wpshop_safe_redirect( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $link ) ); |
|
117 | + wpshop_tools::wpshop_safe_redirect(str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $link)); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | else { |
125 | - wp_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) ); |
|
125 | + wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | echo __('Impossible to download the file you requested', 'wpshop'); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
1 | +<?php if (!defined('ABSPATH')) { exit; |
|
2 | 2 | } |
3 | 3 | class wps_orders_ctr { |
4 | 4 | |
@@ -20,24 +20,24 @@ discard block |
||
20 | 20 | |
21 | 21 | /** Template Load */ |
22 | 22 | // add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) ); |
23 | - add_shortcode( 'order_customer_informations', array( &$this, 'display_order_customer_informations' ) ); |
|
24 | - add_shortcode( 'wps_orders_in_customer_account', array( $this, 'display_orders_in_account' ) ); |
|
25 | - add_action( 'wp_enqueue_scripts', array( $this, 'wps_orders_scripts' ) ); |
|
23 | + add_shortcode('order_customer_informations', array(&$this, 'display_order_customer_informations')); |
|
24 | + add_shortcode('wps_orders_in_customer_account', array($this, 'display_orders_in_account')); |
|
25 | + add_action('wp_enqueue_scripts', array($this, 'wps_orders_scripts')); |
|
26 | 26 | /** Include the different javascript */ |
27 | - add_action( 'admin_init', array( &$this, 'admin_js' ) ); |
|
27 | + add_action('admin_init', array(&$this, 'admin_js')); |
|
28 | 28 | |
29 | 29 | /** Ajax Actions */ |
30 | 30 | // add_action( 'wp_ajax_wps_add_product_to_quotation', array( &$this, 'wps_add_product_to_quotation') ); |
31 | 31 | // add_action( 'wap_ajax_wps_change_product_list', array( &$this, 'wps_change_product_list') ); |
32 | 32 | // add_action( 'wap_ajax_wps_orders_load_variations_container', array( &$this, 'wps_orders_load_variations_container') ); |
33 | 33 | // add_action( 'wap_ajax_wps_order_refresh_in_admin', array( &$this, 'wps_order_refresh_in_admin') ); |
34 | - add_action( 'wp_ajax_wps_orders_load_details', array( $this, 'wps_orders_load_details' ) ); |
|
34 | + add_action('wp_ajax_wps_orders_load_details', array($this, 'wps_orders_load_details')); |
|
35 | 35 | // Add a product sale historic in administration product panel |
36 | - add_action( 'wp_ajax_wps_order_choose_customer', array( $this, 'wps_order_choose_customer' ) ); |
|
36 | + add_action('wp_ajax_wps_order_choose_customer', array($this, 'wps_order_choose_customer')); |
|
37 | 37 | /** For delete order */ |
38 | - add_action( 'wp_ajax_wps_delete_order', array( $this, 'wps_delete_order' ) ); |
|
38 | + add_action('wp_ajax_wps_delete_order', array($this, 'wps_delete_order')); |
|
39 | 39 | /** Invoice Page */ |
40 | - add_action( 'admin_post_wps_invoice', array( $this, 'wps_invoice_output' ) ); |
|
40 | + add_action('admin_post_wps_invoice', array($this, 'wps_invoice_output')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function wps_orders_scripts() { |
56 | 56 | |
57 | - wp_enqueue_script( 'wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js' ); |
|
57 | + wp_enqueue_script('wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function display_order_customer_informations() { |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | global $post_id; |
63 | 63 | global $wpdb; |
64 | 64 | $output = ''; |
65 | - if ( ! empty( $post_id ) ) { |
|
66 | - $order_postmeta = get_post_meta( $post_id, '_order_postmeta', true ); |
|
67 | - $order_info = get_post_meta( $post_id, '_order_info', true ); |
|
65 | + if (!empty($post_id)) { |
|
66 | + $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
|
67 | + $order_info = get_post_meta($post_id, '_order_info', true); |
|
68 | 68 | /** Check the order status */ |
69 | - if ( ! empty( $order_postmeta ) ) { |
|
70 | - if ( ! empty( $order_postmeta['order_status'] ) && $order_postmeta['order_status'] != 'awaiting_payment' ) { |
|
71 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
72 | - $output .= wps_address::display_an_address( $order_info['shipping']['address'] ); |
|
69 | + if (!empty($order_postmeta)) { |
|
70 | + if (!empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'awaiting_payment') { |
|
71 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
72 | + $output .= wps_address::display_an_address($order_info['shipping']['address']); |
|
73 | 73 | } else { |
74 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
74 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } else { |
78 | 78 | /** Display "Choose customer or create one" Interface */ |
79 | 79 | $tpl_component = array(); |
80 | 80 | $args = array( |
81 | - 'show_option_all' => __( 'Choose a customer', 'wpshop' ), |
|
81 | + 'show_option_all' => __('Choose a customer', 'wpshop'), |
|
82 | 82 | 'orderby' => 'display_name', |
83 | 83 | 'order' => 'ASC', |
84 | 84 | 'include' => null, // string |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | 'id' => null, // integer |
93 | 93 | 'class' => 'chosen_select', // string |
94 | 94 | 'blog_id' => $GLOBALS['blog_id'], |
95 | - 'who' => null,// string |
|
95 | + 'who' => null, // string |
|
96 | 96 | ); |
97 | - $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users( $args ); |
|
98 | - $output = wpshop_display::display_template_element( 'wps_orders_choose_customer_interface', $tpl_component, array(), 'admin' ); |
|
97 | + $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users($args); |
|
98 | + $output = wpshop_display::display_template_element('wps_orders_choose_customer_interface', $tpl_component, array(), 'admin'); |
|
99 | 99 | } |
100 | 100 | return $output; |
101 | 101 | } |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | * @param integer $customer_id |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - function display_orders_in_account( $customer_id = '' ) { |
|
109 | + function display_orders_in_account($customer_id = '') { |
|
110 | 110 | |
111 | 111 | $output = ''; |
112 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : get_current_user_id(); |
|
113 | - $from_admin = ( ! empty( $customer_id ) ) ? true : false; |
|
112 | + $customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id(); |
|
113 | + $from_admin = (!empty($customer_id)) ? true : false; |
|
114 | 114 | $wps_orders_mdl = new wps_orders_mdl(); |
115 | - $orders = $wps_orders_mdl->get_customer_orders( $customer_id ); |
|
115 | + $orders = $wps_orders_mdl->get_customer_orders($customer_id); |
|
116 | 116 | // Display orders |
117 | 117 | ob_start(); |
118 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account' ) ); |
|
118 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account')); |
|
119 | 119 | $output = ob_get_contents(); |
120 | 120 | ob_end_clean(); |
121 | 121 | return $output; |
@@ -128,105 +128,105 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array $item_list The item to add to order |
130 | 130 | */ |
131 | - function add_product_to_order( $product ) { |
|
131 | + function add_product_to_order($product) { |
|
132 | 132 | |
133 | 133 | global $wpdb; |
134 | - if ( ! empty( $product ) && empty( $product['price_ttc_before_discount'] ) && empty( $product['price_ht_before_discount'] ) ) { |
|
135 | - $price_infos = wpshop_prices::check_product_price( $product, true ); |
|
136 | - $product['price_ht'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
137 | - $product['product_price'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
138 | - $product['tva'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
134 | + if (!empty($product) && empty($product['price_ttc_before_discount']) && empty($product['price_ht_before_discount'])) { |
|
135 | + $price_infos = wpshop_prices::check_product_price($product, true); |
|
136 | + $product['price_ht'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
137 | + $product['product_price'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
138 | + $product['tva'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
139 | 139 | } |
140 | 140 | |
141 | - $price_piloting = get_option( 'wpshop_shop_price_piloting' ); |
|
142 | - if ( ! empty( $price_piloting ) && $price_piloting == 'HT' ) { |
|
141 | + $price_piloting = get_option('wpshop_shop_price_piloting'); |
|
142 | + if (!empty($price_piloting) && $price_piloting == 'HT') { |
|
143 | 143 | $total_ht = $product['price_ht'] * $product['product_qty']; |
144 | - $tva_total_amount = $total_ht * ( $product['tx_tva'] / 100 ); |
|
144 | + $tva_total_amount = $total_ht * ($product['tx_tva'] / 100); |
|
145 | 145 | $total_ttc = $total_ht + $tva_total_amount; |
146 | 146 | } else { |
147 | 147 | $total_ttc = $product['product_price'] * $product['product_qty']; |
148 | - $total_ht = $total_ttc / ( 1 + ( $product['tx_tva'] / 100 ) ); |
|
148 | + $total_ht = $total_ttc / (1 + ($product['tx_tva'] / 100)); |
|
149 | 149 | $tva_total_amount = $total_ttc - $total_ht; |
150 | 150 | } |
151 | 151 | |
152 | - $tva = ! empty( $product[ WPSHOP_PRODUCT_PRICE_TAX ] ) ? $product[ WPSHOP_PRODUCT_PRICE_TAX ] : null; |
|
152 | + $tva = !empty($product[WPSHOP_PRODUCT_PRICE_TAX]) ? $product[WPSHOP_PRODUCT_PRICE_TAX] : null; |
|
153 | 153 | $item_discount_type = $item_discount_value = $item_discount_amount = 0; |
154 | - $d_amount = ! empty( $product ) && ! empty( $product['discount_amount'] ) ? wpshop_tools::formate_number( $product['discount_amount'] ) : null; |
|
155 | - $d_rate = ! empty( $product ) && ! empty( $product['discount_rate'] ) ? wpshop_tools::formate_number( $product['discount_rate'] ) : null; |
|
156 | - $d_special = ! empty( $product ) && ! empty( $product['special_price'] ) ? wpshop_tools::formate_number( $product['special_price'] ) : null; |
|
157 | - if ( ! empty( $d_amount ) ) { |
|
154 | + $d_amount = !empty($product) && !empty($product['discount_amount']) ? wpshop_tools::formate_number($product['discount_amount']) : null; |
|
155 | + $d_rate = !empty($product) && !empty($product['discount_rate']) ? wpshop_tools::formate_number($product['discount_rate']) : null; |
|
156 | + $d_special = !empty($product) && !empty($product['special_price']) ? wpshop_tools::formate_number($product['special_price']) : null; |
|
157 | + if (!empty($d_amount)) { |
|
158 | 158 | $item_discount_type = 'discount_amount'; |
159 | 159 | $item_discount_amount = $product['discount_amount']; |
160 | 160 | $item_discount_value = $product['discount_amount']; |
161 | - } elseif ( ! empty( $d_rate ) ) { |
|
161 | + } elseif (!empty($d_rate)) { |
|
162 | 162 | $item_discount_type = 'discount_rate'; |
163 | 163 | $item_discount_amount = $product['discount_rate']; |
164 | 164 | $item_discount_value = $product['discount_rate']; |
165 | - } elseif ( ! empty( $d_special ) ) { |
|
165 | + } elseif (!empty($d_special)) { |
|
166 | 166 | $item_discount_type = 'special_price'; |
167 | 167 | $item_discount_amount = $product['special_price']; |
168 | 168 | $item_discount_value = $product['special_price']; |
169 | 169 | } |
170 | 170 | |
171 | - $item = array( 'item_id' => $product['product_id'], 'item_ref' => ! empty( $product['product_reference'] ) ? $product['product_reference'] : null, 'item_name' => ! empty( $product['product_name'] ) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], 'item_qty' => $product['product_qty'], 'item_pu_ht' => $product['price_ht'], 'item_pu_ttc' => $product['product_price'], 'item_ecotaxe_ht' => 0, 'item_ecotaxe_tva' => 19.6, 'item_ecotaxe_ttc' => 0, 'item_discount_type' => $item_discount_type, 'item_discount_value' => $item_discount_value, 'item_discount_amount' => $item_discount_amount, 'item_tva_rate' => $tva, 'item_tva_amount' => $product['tva'], 'item_total_ht' => $total_ht, 'item_tva_total_amount' => $tva_total_amount, 'item_total_ttc' => $total_ttc, 'item_meta' => ! empty( $product['item_meta'] ) ? $product['item_meta'] : array() ); |
|
172 | - if ( isset( $product['is_downloadable_'] ) ) { |
|
171 | + $item = array('item_id' => $product['product_id'], 'item_ref' => !empty($product['product_reference']) ? $product['product_reference'] : null, 'item_name' => !empty($product['product_name']) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], 'item_qty' => $product['product_qty'], 'item_pu_ht' => $product['price_ht'], 'item_pu_ttc' => $product['product_price'], 'item_ecotaxe_ht' => 0, 'item_ecotaxe_tva' => 19.6, 'item_ecotaxe_ttc' => 0, 'item_discount_type' => $item_discount_type, 'item_discount_value' => $item_discount_value, 'item_discount_amount' => $item_discount_amount, 'item_tva_rate' => $tva, 'item_tva_amount' => $product['tva'], 'item_total_ht' => $total_ht, 'item_tva_total_amount' => $tva_total_amount, 'item_total_ttc' => $total_ttc, 'item_meta' => !empty($product['item_meta']) ? $product['item_meta'] : array()); |
|
172 | + if (isset($product['is_downloadable_'])) { |
|
173 | 173 | $item['item_is_downloadable_'] = $product['is_downloadable_']; |
174 | 174 | } |
175 | - $array_not_to_do = array( WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations' ); |
|
176 | - if ( ! empty( $product['item_meta'] ) ) { |
|
177 | - foreach ( $product['item_meta'] as $key => $value ) { |
|
178 | - if ( ! isset( $item[ 'item_' . $key ] ) && ! in_array( $key, $array_not_to_do ) && ! empty( $product[ $key ] ) ) { |
|
179 | - $item[ 'item_' . $key ] = $product[ $key ]; |
|
175 | + $array_not_to_do = array(WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations'); |
|
176 | + if (!empty($product['item_meta'])) { |
|
177 | + foreach ($product['item_meta'] as $key => $value) { |
|
178 | + if (!isset($item['item_' . $key]) && !in_array($key, $array_not_to_do) && !empty($product[$key])) { |
|
179 | + $item['item_' . $key] = $product[$key]; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | /** Check if it's a variation product */ |
185 | - if ( ! empty( $product ) && ! empty( $product['item_meta'] ) && ! empty( $product['item_meta']['variations'] ) ) { |
|
186 | - foreach ( $product['item_meta']['variations'] as $k => $variation ) { |
|
187 | - $product_variation_def = get_post_meta( $k, '_wpshop_variations_attribute_def', true ); |
|
188 | - if ( ! empty( $product_variation_def ) ) { |
|
189 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
190 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
191 | - if ( ! empty( $variation_attribute_def ) ) { |
|
192 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
193 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
194 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
195 | - $variation_name = $wpdb->get_var( $query ); |
|
185 | + if (!empty($product) && !empty($product['item_meta']) && !empty($product['item_meta']['variations'])) { |
|
186 | + foreach ($product['item_meta']['variations'] as $k => $variation) { |
|
187 | + $product_variation_def = get_post_meta($k, '_wpshop_variations_attribute_def', true); |
|
188 | + if (!empty($product_variation_def)) { |
|
189 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
190 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
191 | + if (!empty($variation_attribute_def)) { |
|
192 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
193 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
194 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
195 | + $variation_name = $wpdb->get_var($query); |
|
196 | 196 | } else { |
197 | - $variation_post = get_post( $variation_id ); |
|
197 | + $variation_post = get_post($variation_id); |
|
198 | 198 | $variation_name = $variation_post->post_title; |
199 | 199 | } |
200 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
201 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
200 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
201 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } else { |
207 | 207 | /** Check if it's product with one variation */ |
208 | - $product_variation_def = get_post_meta( $product['product_id'], '_wpshop_variations_attribute_def', true ); |
|
209 | - if ( ! empty( $product_variation_def ) ) { |
|
210 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
211 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
212 | - if ( ! empty( $variation_attribute_def ) ) { |
|
213 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
214 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
215 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
216 | - $variation_name = $wpdb->get_var( $query ); |
|
208 | + $product_variation_def = get_post_meta($product['product_id'], '_wpshop_variations_attribute_def', true); |
|
209 | + if (!empty($product_variation_def)) { |
|
210 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
211 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
212 | + if (!empty($variation_attribute_def)) { |
|
213 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
214 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
215 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
216 | + $variation_name = $wpdb->get_var($query); |
|
217 | 217 | } else { |
218 | - $variation_post = get_post( $variation_id ); |
|
218 | + $variation_post = get_post($variation_id); |
|
219 | 219 | $variation_name = $variation_post->post_title; |
220 | 220 | } |
221 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
222 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
221 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
222 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | /** On ajoute la possibilité d'étendre les données produits ajoutées dans le panier / Add possibility to extends product data saved into cart */ |
229 | - $item = apply_filters( 'wpshop-add-product-to-order', $item, $product ); |
|
229 | + $item = apply_filters('wpshop-add-product-to-order', $item, $product); |
|
230 | 230 | return $item; |
231 | 231 | } |
232 | 232 | |
@@ -235,40 +235,40 @@ discard block |
||
235 | 235 | */ |
236 | 236 | function wps_invoice_output() { |
237 | 237 | |
238 | - $order_id = ( ! empty( $_GET['order_id'] )) ? (int) $_GET['order_id'] : null; |
|
239 | - $invoice_ref = ( ! empty( $_GET['invoice_ref'] )) ? sanitize_text_field( $_GET['invoice_ref'] ) : null; |
|
240 | - $mode = ( ! empty( $_GET['mode'] )) ? sanitize_text_field( $_GET['mode'] ) : 'html'; |
|
241 | - $is_credit_slip = ( ! empty( $_GET['credit_slip'] )) ? sanitize_text_field( $_GET['credit_slip'] ) : null; |
|
238 | + $order_id = (!empty($_GET['order_id'])) ? (int)$_GET['order_id'] : null; |
|
239 | + $invoice_ref = (!empty($_GET['invoice_ref'])) ? sanitize_text_field($_GET['invoice_ref']) : null; |
|
240 | + $mode = (!empty($_GET['mode'])) ? sanitize_text_field($_GET['mode']) : 'html'; |
|
241 | + $is_credit_slip = (!empty($_GET['credit_slip'])) ? sanitize_text_field($_GET['credit_slip']) : null; |
|
242 | 242 | $user_id = get_current_user_id(); |
243 | - if ( ! empty( $order_id ) && $user_id != 0 ) { |
|
243 | + if (!empty($order_id) && $user_id != 0) { |
|
244 | 244 | /** Order reading */ |
245 | - $order_postmeta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
245 | + $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
246 | 246 | /** Start invoice display */ |
247 | - if ( ! empty( $is_credit_slip ) ) { |
|
248 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref, 'credit_slip' ); |
|
247 | + if (!empty($is_credit_slip)) { |
|
248 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref, 'credit_slip'); |
|
249 | 249 | } else { |
250 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref ); |
|
250 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref); |
|
251 | 251 | } |
252 | 252 | |
253 | - if ( $mode == 'pdf' ) { |
|
254 | - require_once( WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php' ); |
|
253 | + if ($mode == 'pdf') { |
|
254 | + require_once(WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php'); |
|
255 | 255 | try { |
256 | 256 | // $html_content = wpshop_display::display_template_element('invoice_print_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
257 | - $html_content = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ) . '<page>' . $html_content . '</page>'; |
|
258 | - $html2pdf = new HTML2PDF( 'P', 'A4', 'fr' ); |
|
259 | - $html2pdf->setDefaultFont( 'Arial' ); |
|
260 | - $html2pdf->writeHTML( $html_content ); |
|
261 | - $html2pdf->Output( 'order_' . $order_id . '.pdf', 'D' ); |
|
257 | + $html_content = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
|
258 | + $html2pdf = new HTML2PDF('P', 'A4', 'fr'); |
|
259 | + $html2pdf->setDefaultFont('Arial'); |
|
260 | + $html2pdf->writeHTML($html_content); |
|
261 | + $html2pdf->Output('order_' . $order_id . '.pdf', 'D'); |
|
262 | 262 | } catch (HTML2PDF_exception $e) { |
263 | 263 | echo $e; |
264 | 264 | exit; |
265 | 265 | } |
266 | 266 | } else { |
267 | - $order_invoice_ref = ( ! empty( $order_postmeta['order_invoice_ref'] ) ) ? $order_postmeta['order_invoice_ref'] : ''; |
|
268 | - $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ); |
|
267 | + $order_invoice_ref = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ''; |
|
268 | + $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common'); |
|
269 | 269 | $tpl_component['INVOICE_MAIN_PAGE'] = $html_content; |
270 | - $tpl_component['INVOICE_TITLE_PAGE'] = sprintf( __( 'Invoice %1$s for order %3$s (#%2$s)', 'wpshop' ), $order_invoice_ref, $order_id, $order_postmeta['order_key'] ); |
|
271 | - echo wpshop_display::display_template_element( 'invoice_page', $tpl_component, array(), 'common' ); |
|
270 | + $tpl_component['INVOICE_TITLE_PAGE'] = sprintf(__('Invoice %1$s for order %3$s (#%2$s)', 'wpshop'), $order_invoice_ref, $order_id, $order_postmeta['order_key']); |
|
271 | + echo wpshop_display::display_template_element('invoice_page', $tpl_component, array(), 'common'); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | die(); |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | */ |
281 | 281 | function wps_orders_load_details() { |
282 | 282 | |
283 | - check_ajax_referer( 'wps_orders_load_details' ); |
|
284 | - $order_id = ( ! empty( $_POST['order_id'] ) ) ? wpshop_tools::varSanitizer( $_POST['order_id'] ) : ''; |
|
283 | + check_ajax_referer('wps_orders_load_details'); |
|
284 | + $order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : ''; |
|
285 | 285 | $user_id = get_current_user_id(); |
286 | 286 | $status = false; |
287 | 287 | $result = ''; |
288 | - if ( ! empty( $order_id ) ) { |
|
289 | - $order = get_post( $order_id ); |
|
290 | - $order_infos = get_post_meta( $order_id, '_order_postmeta', true ); |
|
291 | - $order_key = ( ! empty( $order_infos['order_key'] ) ) ? $order_infos['order_key'] : '-'; |
|
292 | - if ( ! empty( $order ) && ! empty( $user_id ) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id ) { |
|
293 | - $result = do_shortcode( '[wps_cart cart_type="summary" oid="' . $order_id . '"]' ); |
|
288 | + if (!empty($order_id)) { |
|
289 | + $order = get_post($order_id); |
|
290 | + $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
|
291 | + $order_key = (!empty($order_infos['order_key'])) ? $order_infos['order_key'] : '-'; |
|
292 | + if (!empty($order) && !empty($user_id) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id) { |
|
293 | + $result = do_shortcode('[wps_cart cart_type="summary" oid="' . $order_id . '"]'); |
|
294 | 294 | $status = true; |
295 | 295 | } |
296 | 296 | } |
297 | - echo json_encode( array( 'status' => $status, 'title' => sprintf( __( 'Order n° %s details', 'wpshop' ), $order_key ), 'content' => $result ) ); |
|
297 | + echo json_encode(array('status' => $status, 'title' => sprintf(__('Order n° %s details', 'wpshop'), $order_key), 'content' => $result)); |
|
298 | 298 | wp_die(); |
299 | 299 | } |
300 | 300 | |
@@ -303,60 +303,60 @@ discard block |
||
303 | 303 | */ |
304 | 304 | function wps_order_choose_customer() { |
305 | 305 | |
306 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
307 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_order_choose_customer' ) ) { |
|
306 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
307 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_choose_customer')) { |
|
308 | 308 | wp_die(); |
309 | 309 | } |
310 | 310 | |
311 | 311 | $status = false; |
312 | 312 | $billing_data = $shipping_data = ''; |
313 | - $customer_id = ( ! empty( $_POST['customer_id'] ) ) ? intval( $_POST['customer_id'] ): null; |
|
314 | - if ( ! empty( $customer_id ) ) { |
|
313 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
314 | + if (!empty($customer_id)) { |
|
315 | 315 | $wps_address = new wps_address(); |
316 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
317 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
316 | + $billing_option = get_option('wpshop_billing_address'); |
|
317 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
318 | 318 | $billing_option = $billing_option['choice']; |
319 | - $customer_addresses_list = wps_address::get_addresses_list( $customer_id ); |
|
319 | + $customer_addresses_list = wps_address::get_addresses_list($customer_id); |
|
320 | 320 | $status = true; |
321 | - $billing_data = '<div class="wps-alert-info">' . sprintf( __( 'No Billing address created, <a href="%s" title="' . __( 'Create a new billing address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
322 | - if ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) { |
|
321 | + $billing_data = '<div class="wps-alert-info">' . sprintf(__('No Billing address created, <a href="%s" title="' . __('Create a new billing address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
322 | + if (!empty($shipping_option) && !empty($shipping_option['activate'])) { |
|
323 | 323 | $shipping_option = $shipping_option['choice']; |
324 | - $shipping_data = '<div class="wps-alert-info">' . sprintf( __( 'No shipping address created, <a href="%s" title="' . __( 'Create a new shipping address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
324 | + $shipping_data = '<div class="wps-alert-info">' . sprintf(__('No shipping address created, <a href="%s" title="' . __('Create a new shipping address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( ! empty( $customer_addresses_list ) ) { |
|
328 | - foreach ( $customer_addresses_list as $address_type => $customer_addresses ) { |
|
329 | - if ( $billing_option == $address_type ) { |
|
330 | - $billing_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
327 | + if (!empty($customer_addresses_list)) { |
|
328 | + foreach ($customer_addresses_list as $address_type => $customer_addresses) { |
|
329 | + if ($billing_option == $address_type) { |
|
330 | + $billing_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
331 | 331 | } else { |
332 | - $shipping_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
332 | + $shipping_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
337 | - echo json_encode( array( 'status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data ) ); |
|
337 | + echo json_encode(array('status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data)); |
|
338 | 338 | wp_die(); |
339 | 339 | } |
340 | 340 | |
341 | - static function pay_quotation( $order_id ) { |
|
341 | + static function pay_quotation($order_id) { |
|
342 | 342 | |
343 | 343 | $status = true; |
344 | - $order_id = (int) $order_id; |
|
345 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
346 | - $order_info = get_post_meta( $order_id, '_order_info', true ); |
|
347 | - $_SESSION['shipping_method'] = isset( $order_meta['order_payment']['shipping_method'] ) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
348 | - if ( isset( $order_info['billing']['address_id'] ) ) { |
|
344 | + $order_id = (int)$order_id; |
|
345 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
346 | + $order_info = get_post_meta($order_id, '_order_info', true); |
|
347 | + $_SESSION['shipping_method'] = isset($order_meta['order_payment']['shipping_method']) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
348 | + if (isset($order_info['billing']['address_id'])) { |
|
349 | 349 | $_SESSION['billing_address'] = $order_info['billing']['address_id']; |
350 | 350 | $_SESSION['cart'] = $order_meta; |
351 | 351 | $_SESSION['cart']['order_id'] = $order_id; |
352 | 352 | $_SESSION['cart']['cart_type'] = 'cart'; |
353 | 353 | $_SESSION['cart']['order_shipping_cost_fixe'] = 'on'; |
354 | - $permalink = get_permalink( get_option( 'wpshop_cart_page_id' ) ) . '?order_step=5'; |
|
354 | + $permalink = get_permalink(get_option('wpshop_cart_page_id')) . '?order_step=5'; |
|
355 | 355 | } else { |
356 | - $status = self::add_order_to_session( $order_id ); |
|
357 | - $permalink = get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ) ); |
|
356 | + $status = self::add_order_to_session($order_id); |
|
357 | + $permalink = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))); |
|
358 | 358 | } |
359 | - return array( 'status' => $status, 'permalink' => $permalink ); |
|
359 | + return array('status' => $status, 'permalink' => $permalink); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -365,54 +365,54 @@ discard block |
||
365 | 365 | * @method add_order_to_session |
366 | 366 | * @param int $order_id Id of order. |
367 | 367 | */ |
368 | - public static function add_order_to_session( $order_id ) { |
|
368 | + public static function add_order_to_session($order_id) { |
|
369 | 369 | |
370 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
371 | - if ( $order_meta != false ) { |
|
370 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
371 | + if ($order_meta != false) { |
|
372 | 372 | $_SESSION['cart'] = array(); |
373 | 373 | $_SESSION['cart']['order_amount_to_pay_now'] = $order_meta['order_amount_to_pay_now']; |
374 | 374 | $_SESSION['cart']['order_items'] = array(); |
375 | - if ( ! empty( $order_meta ) && ! empty( $order_meta['order_items'] ) ) { |
|
375 | + if (!empty($order_meta) && !empty($order_meta['order_items'])) { |
|
376 | 376 | $wpshop_cart_type = 'cart'; |
377 | - foreach ( $order_meta['order_items'] as $item ) { |
|
378 | - $_SESSION['cart']['order_items'][ $item['item_id'] ] = $item; |
|
377 | + foreach ($order_meta['order_items'] as $item) { |
|
378 | + $_SESSION['cart']['order_items'][$item['item_id']] = $item; |
|
379 | 379 | } |
380 | 380 | $wps_cart_ctr = new wps_cart(); |
381 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
382 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
381 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
382 | + $wps_cart_ctr->store_cart_in_session($order); |
|
383 | 383 | } |
384 | 384 | $_SESSION['order_id'] = $order_id; |
385 | 385 | } |
386 | - return (bool) ($order_meta != false); |
|
386 | + return (bool)($order_meta != false); |
|
387 | 387 | } |
388 | 388 | /** |
389 | 389 | * AJAX - Delete order by order_id |
390 | 390 | */ |
391 | 391 | public function wps_delete_order() { |
392 | 392 | |
393 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
394 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_delete_order' ) ) { |
|
393 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
394 | + if (!wp_verify_nonce($_wpnonce, 'wps_delete_order')) { |
|
395 | 395 | wp_die(); |
396 | 396 | } |
397 | 397 | |
398 | 398 | $status = false; |
399 | 399 | $output = ''; |
400 | - $order_id = ! empty( $_POST['order_id'] ) ? (int) $_POST['order_id'] : 0; |
|
401 | - if ( $order_id ) { |
|
402 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
400 | + $order_id = !empty($_POST['order_id']) ? (int)$_POST['order_id'] : 0; |
|
401 | + if ($order_id) { |
|
402 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
403 | 403 | $wps_credit = new wps_credit(); |
404 | - $wps_credit->create_an_credit( $order_id ); |
|
404 | + $wps_credit->create_an_credit($order_id); |
|
405 | 405 | $order_meta['order_status'] = 'canceled'; |
406 | - $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time( 'mysql', 0 ); |
|
406 | + $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time('mysql', 0); |
|
407 | 407 | $order_meta['order_payment']['refunded_action']['author'] = get_current_user_id(); |
408 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
408 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
409 | 409 | ob_start(); |
410 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account' ) ); |
|
410 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account')); |
|
411 | 411 | $output = ob_get_contents(); |
412 | 412 | ob_end_clean(); |
413 | 413 | $status = true; |
414 | 414 | } |
415 | - echo json_encode( array( 'status' => $status, 'row' => $output ) ); |
|
415 | + echo json_encode(array('status' => $status, 'row' => $output)); |
|
416 | 416 | wp_die(); |
417 | 417 | } |
418 | 418 | |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | * @param int $order_id OrderID. |
424 | 424 | * @return mixed sha1 or false. |
425 | 425 | */ |
426 | - public static function wps_token_order_customer( $order_id, $date = null ) { |
|
427 | - $date = isset( $date ) ? $date : date( 'Ym' ); |
|
428 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
429 | - if ( ! isset( $order_metadata['customer_id'] ) ) { |
|
426 | + public static function wps_token_order_customer($order_id, $date = null) { |
|
427 | + $date = isset($date) ? $date : date('Ym'); |
|
428 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
429 | + if (!isset($order_metadata['customer_id'])) { |
|
430 | 430 | return false; |
431 | 431 | } |
432 | - return sha1( site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date ); |
|
432 | + return sha1(site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | * @param int $order_id OrderID. |
441 | 441 | * @return boolean |
442 | 442 | */ |
443 | - public static function wps_verify_token_order( $token, $order_id ) { |
|
444 | - $current_month = self::wps_token_order_customer( $order_id ); |
|
445 | - $last_month = self::wps_token_order_customer( $order_id, date_format( date_create( date( 'Y-m' ) . ' - 1month' ), 'Ym' ) ); |
|
446 | - return (bool) ( (bool) $current_month && (bool) $last_month && ( $token === $current_month || $token === $last_month ) ); |
|
443 | + public static function wps_verify_token_order($token, $order_id) { |
|
444 | + $current_month = self::wps_token_order_customer($order_id); |
|
445 | + $last_month = self::wps_token_order_customer($order_id, date_format(date_create(date('Y-m') . ' - 1month'), 'Ym')); |
|
446 | + return (bool)((bool)$current_month && (bool)$last_month && ($token === $current_month || $token === $last_month)); |
|
447 | 447 | } |
448 | 448 | } |