@@ -1,80 +1,80 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | - $order_post_meta = !empty($post) ? get_post_meta( $post->ID, '_wpshop_order_status', true ) : ""; ?> |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | + $order_post_meta = !empty($post) ? get_post_meta($post->ID, '_wpshop_order_status', true) : ""; ?> |
|
| 3 | 3 | <div class="wps-table"> |
| 4 | 4 | <div class="wps-table-header wps-table-row"> |
| 5 | - <div class="wps-table-cell"><?php _e( 'Picture', 'wpshop'); ?></div> |
|
| 6 | - <div class="wps-table-cell"><?php _e( 'Product reference', 'wpshop'); ?></div> |
|
| 7 | - <div class="wps-table-cell"><?php _e( 'Product name', 'wpshop'); ?></div> |
|
| 8 | - <div class="wps-table-cell"><?php _e( 'Price', 'wpshop'); ?></div> |
|
| 5 | + <div class="wps-table-cell"><?php _e('Picture', 'wpshop'); ?></div> |
|
| 6 | + <div class="wps-table-cell"><?php _e('Product reference', 'wpshop'); ?></div> |
|
| 7 | + <div class="wps-table-cell"><?php _e('Product name', 'wpshop'); ?></div> |
|
| 8 | + <div class="wps-table-cell"><?php _e('Price', 'wpshop'); ?></div> |
|
| 9 | 9 | |
| 10 | - <?php if ( 'completed' != $order_post_meta ) : ?> |
|
| 11 | - <div class="wps-table-cell"><?php _e( 'Quantity', 'wpshop'); ?></div> |
|
| 12 | - <div class="wps-table-cell"><?php _e( 'Add to order', 'wpshop'); ?></div> |
|
| 10 | + <?php if ('completed' != $order_post_meta) : ?> |
|
| 11 | + <div class="wps-table-cell"><?php _e('Quantity', 'wpshop'); ?></div> |
|
| 12 | + <div class="wps-table-cell"><?php _e('Add to order', 'wpshop'); ?></div> |
|
| 13 | 13 | <?php endif; ?> |
| 14 | 14 | </div> |
| 15 | - <?php if( !empty($products) ) : |
|
| 16 | - $total_products = count( $products ); |
|
| 15 | + <?php if (!empty($products)) : |
|
| 16 | + $total_products = count($products); |
|
| 17 | 17 | $i = 0; |
| 18 | 18 | $elements_per_page = 20; |
| 19 | - $paged = absint( isset( $_REQUEST['paged_order'] ) ? $_REQUEST['paged_order'] : 1 ); |
|
| 20 | - $paginate_links = paginate_links( array( |
|
| 19 | + $paged = absint(isset($_REQUEST['paged_order']) ? $_REQUEST['paged_order'] : 1); |
|
| 20 | + $paginate_links = paginate_links(array( |
|
| 21 | 21 | 'base' => '%_%', |
| 22 | 22 | 'format' => '?paged_order=%#%', |
| 23 | 23 | 'current' => $paged, |
| 24 | - 'total' => ceil( $total_products / $elements_per_page ), |
|
| 24 | + 'total' => ceil($total_products / $elements_per_page), |
|
| 25 | 25 | 'type' => 'list', |
| 26 | 26 | 'prev_next' => true, |
| 27 | - ) ); |
|
| 28 | - foreach ( $products as $product ) : |
|
| 29 | - if( ( $elements_per_page * ( $paged - 1 ) ) > $i ) { |
|
| 27 | + )); |
|
| 28 | + foreach ($products as $product) : |
|
| 29 | + if (($elements_per_page * ($paged - 1)) > $i) { |
|
| 30 | 30 | $i++; |
| 31 | 31 | continue; |
| 32 | - } elseif ( ( $elements_per_page * $paged ) <= $i ) { |
|
| 32 | + } elseif (($elements_per_page * $paged) <= $i) { |
|
| 33 | 33 | break; |
| 34 | 34 | } |
| 35 | 35 | $i++; |
| 36 | 36 | $pid = $product->ID; |
| 37 | 37 | ?> |
| 38 | - <?php $product_metadata = get_post_meta( $product->ID, '_wpshop_product_metadata', true ); ?> |
|
| 38 | + <?php $product_metadata = get_post_meta($product->ID, '_wpshop_product_metadata', true); ?> |
|
| 39 | 39 | <div class="wps-table-content wps-table-row"> |
| 40 | - <div class="wps-table-cell wps-cart-item-img"><?php echo get_the_post_thumbnail( $product->ID, 'thumbnail' ); ?></div> |
|
| 41 | - <div class="wps-table-cell"><?php echo ( !empty( $product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div> |
|
| 40 | + <div class="wps-table-cell wps-cart-item-img"><?php echo get_the_post_thumbnail($product->ID, 'thumbnail'); ?></div> |
|
| 41 | + <div class="wps-table-cell"><?php echo (!empty($product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div> |
|
| 42 | 42 | <div class="wps-table-cell"><?php echo $product->post_title; ?></div> |
| 43 | 43 | <div class="wps-table-cell"> |
| 44 | 44 | <?php |
| 45 | 45 | $product = wpshop_products::get_product_data($product->ID); |
| 46 | - echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid') ); |
|
| 46 | + echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid')); |
|
| 47 | 47 | ?> |
| 48 | 48 | </div> |
| 49 | - <?php if ( 'completed' != $order_post_meta ) : ?> |
|
| 49 | + <?php if ('completed' != $order_post_meta) : ?> |
|
| 50 | 50 | <div class="wps-table-cell"> |
| 51 | - <a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a> |
|
| 51 | + <a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a> |
|
| 52 | 52 | <input id="wps-cart-product-qty-<?php echo $pid; ?>" class="wps-cart-product-qty" type="text" value="1" name="french-hens" size="3" style="text-align : center"> |
| 53 | - <a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a> |
|
| 53 | + <a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a> |
|
| 54 | 54 | </div> |
| 55 | 55 | <div class="wps-table-cell"> |
| 56 | - <a href="#" data-nonce="<?php echo wp_create_nonce( 'wps_add_product_to_order_admin' ); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e( 'Add to order', 'wpshop'); ?></a> |
|
| 56 | + <a href="#" data-nonce="<?php echo wp_create_nonce('wps_add_product_to_order_admin'); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e('Add to order', 'wpshop'); ?></a> |
|
| 57 | 57 | </div> |
| 58 | 58 | <?php endif; ?> |
| 59 | 59 | </div> |
| 60 | 60 | <?php endforeach; |
| 61 | 61 | else : |
| 62 | - if( !empty( $research ) ) : ?> |
|
| 63 | - <div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research ); ?></div> |
|
| 62 | + if (!empty($research)) : ?> |
|
| 63 | + <div class="wps-alert-info"><?php printf(__('No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research); ?></div> |
|
| 64 | 64 | <?php else : |
| 65 | - $letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __('ALL', 'wpshop' ); ?> |
|
| 66 | - <div class="wps-alert-info"><?php printf( __( 'No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper( $letter_display ) ); ?></div> |
|
| 65 | + $letter_display = (strtoupper($current_letter) != 'ALL') ? $current_letter : __('ALL', 'wpshop'); ?> |
|
| 66 | + <div class="wps-alert-info"><?php printf(__('No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper($letter_display)); ?></div> |
|
| 67 | 67 | <?php endif; |
| 68 | 68 | endif; ?> |
| 69 | 69 | </div> |
| 70 | 70 | <?php |
| 71 | -if( !empty($products) && $total_products > $elements_per_page ) : |
|
| 71 | +if (!empty($products) && $total_products > $elements_per_page) : |
|
| 72 | 72 | echo $paginate_links; |
| 73 | 73 | ?> |
| 74 | 74 | <input type="hidden" name="last_query[oid]" value="<?php echo $post->ID; ?>"> |
| 75 | - <input type="hidden" name="last_query[letter]" value="<?php echo strtoupper( $current_letter ); ?>"> |
|
| 75 | + <input type="hidden" name="last_query[letter]" value="<?php echo strtoupper($current_letter); ?>"> |
|
| 76 | 76 | <input type="hidden" name="last_query[research]" value="<?php echo $research; ?>"> |
| 77 | - <input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce( 'refresh_product_list_'.strtolower($current_letter) ); ?>"> |
|
| 77 | + <input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce('refresh_product_list_' . strtolower($current_letter)); ?>"> |
|
| 78 | 78 | <?php |
| 79 | 79 | endif; |
| 80 | 80 | ?> |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_orders_in_back_office { |
| 3 | 3 | |
| 4 | 4 | function __construct() { |
| 5 | 5 | // Template loading |
| 6 | 6 | $this->template_dir = WPS_ORDERS_PATH . WPS_ORDERS_DIR . "/templates/"; |
| 7 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes') ); |
|
| 7 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
| 8 | 8 | |
| 9 | 9 | // Ajax actions |
| 10 | - add_action('wp_ajax_wpshop_add_private_comment_to_order', array( $this, 'wpshop_add_private_comment_to_order' ) ); |
|
| 11 | - add_action('wp_ajax_wps_order_refresh_product_listing', array( $this, 'refresh_product_list' ) ); |
|
| 12 | - add_action('wp_ajax_wps_add_product_to_order_admin', array( $this, 'wps_add_product_to_order_admin' ) ); |
|
| 13 | - add_action('wp_ajax_wps_refresh_cart_order', array( $this, 'refresh_cart_order' ) ); |
|
| 14 | - add_action('wp_ajax_wps_refresh_payments_order', array( $this, 'refresh_payments_order' ) ); |
|
| 15 | - add_action('wp_ajax_wps_update_product_qty_in_admin', array( $this, 'wps_update_product_qty_in_admin' ) ); |
|
| 16 | - add_action('wp_ajax_wps_order_load_product_variations', array( $this, 'wps_order_load_product_variations' ) ); |
|
| 17 | - add_action('wp_ajax_wps-orders-update-cart-informations', array( $this, 'wps_orders_update_cart_informations' ) ); |
|
| 18 | - add_action('wp_ajax_wps_reverify_payment_invoice_ref', array( $this, 'wps_reverify_payment_invoice_ref' ) ); |
|
| 10 | + add_action('wp_ajax_wpshop_add_private_comment_to_order', array($this, 'wpshop_add_private_comment_to_order')); |
|
| 11 | + add_action('wp_ajax_wps_order_refresh_product_listing', array($this, 'refresh_product_list')); |
|
| 12 | + add_action('wp_ajax_wps_add_product_to_order_admin', array($this, 'wps_add_product_to_order_admin')); |
|
| 13 | + add_action('wp_ajax_wps_refresh_cart_order', array($this, 'refresh_cart_order')); |
|
| 14 | + add_action('wp_ajax_wps_refresh_payments_order', array($this, 'refresh_payments_order')); |
|
| 15 | + add_action('wp_ajax_wps_update_product_qty_in_admin', array($this, 'wps_update_product_qty_in_admin')); |
|
| 16 | + add_action('wp_ajax_wps_order_load_product_variations', array($this, 'wps_order_load_product_variations')); |
|
| 17 | + add_action('wp_ajax_wps-orders-update-cart-informations', array($this, 'wps_orders_update_cart_informations')); |
|
| 18 | + add_action('wp_ajax_wps_reverify_payment_invoice_ref', array($this, 'wps_reverify_payment_invoice_ref')); |
|
| 19 | 19 | |
| 20 | 20 | // WP General actions |
| 21 | - add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts' ) ); |
|
| 22 | - add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts_texts' ), 20 ); |
|
| 23 | - add_action('save_post', array( $this, 'save_order_custom_informations')); |
|
| 21 | + add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts')); |
|
| 22 | + add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts_texts'), 20); |
|
| 23 | + add_action('save_post', array($this, 'save_order_custom_informations')); |
|
| 24 | 24 | |
| 25 | 25 | // WP Filters |
| 26 | 26 | //add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'wps_notif_user_on_order_saving'), 100, 2 ); |
@@ -31,52 +31,52 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function wps_orders_scripts() { |
| 33 | 33 | global $current_screen; |
| 34 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
| 34 | + if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER), true)) |
|
| 35 | 35 | return; |
| 36 | 36 | |
| 37 | - wp_enqueue_style( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css' ); |
|
| 38 | - wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js' ); |
|
| 37 | + wp_enqueue_style('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css'); |
|
| 38 | + wp_enqueue_script('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function wps_orders_scripts_texts() { |
| 42 | - wp_localize_script( 'wps_orders_backend', 'message_confirm_reload', __( 'Are you sure you want to refresh your browser?', 'wpshop' ) ); |
|
| 43 | - wp_localize_script( 'wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __( 'Error detected.', 'wpshop' ) ); |
|
| 42 | + wp_localize_script('wps_orders_backend', 'message_confirm_reload', __('Are you sure you want to refresh your browser?', 'wpshop')); |
|
| 43 | + wp_localize_script('wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __('Error detected.', 'wpshop')); |
|
| 44 | 44 | } |
| 45 | 45 | /** |
| 46 | 46 | * Add meta boxes |
| 47 | 47 | */ |
| 48 | 48 | function add_meta_boxes() { |
| 49 | 49 | global $post; |
| 50 | - $order_meta = get_post_meta( $post->ID, '_order_postmeta', true ); |
|
| 50 | + $order_meta = get_post_meta($post->ID, '_order_postmeta', true); |
|
| 51 | 51 | /** Box Order Payments **/ |
| 52 | - if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) { |
|
| 53 | - add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> '.__('Order payment', 'wpshop'),array($this, 'display_order_payments_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
| 52 | + if (!in_array($post->post_status, array('auto-draft'))) { |
|
| 53 | + add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> ' . __('Order payment', 'wpshop'), array($this, 'display_order_payments_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
| 54 | 54 | } |
| 55 | 55 | /** Box for customer order comment */ |
| 56 | - if ( ! empty( $post->post_excerpt ) ) { |
|
| 57 | - add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> '.__('Order customer comment', 'wpshop'),array( $this, 'order_customer_comment_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
| 56 | + if (!empty($post->post_excerpt)) { |
|
| 57 | + add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> ' . __('Order customer comment', 'wpshop'), array($this, 'order_customer_comment_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
| 58 | 58 | } |
| 59 | 59 | /** Historic sales **/ |
| 60 | - add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array( $this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low'); |
|
| 60 | + add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array($this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low'); |
|
| 61 | 61 | /** Box with the complete order content */ |
| 62 | 62 | $payment_started = false; |
| 63 | - if ( ! empty( $order_meta['order_payment'] ) && ! empty( $order_meta['order_payment']['received'] ) ) { |
|
| 64 | - foreach ( $order_meta['order_payment']['received'] as $received ) { |
|
| 65 | - if ( empty( $received['received_amount'] ) ) { |
|
| 63 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received'])) { |
|
| 64 | + foreach ($order_meta['order_payment']['received'] as $received) { |
|
| 65 | + if (empty($received['received_amount'])) { |
|
| 66 | 66 | continue; |
| 67 | 67 | } |
| 68 | 68 | $payment_started = true; |
| 69 | 69 | break; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - if ( ! $payment_started ) { |
|
| 73 | - add_meta_box( 'wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __( 'Product List', 'wpshop' ), array( $this, 'wps_products_listing_for_quotation' ), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low' ); |
|
| 72 | + if (!$payment_started) { |
|
| 73 | + add_meta_box('wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __('Product List', 'wpshop'), array($this, 'wps_products_listing_for_quotation'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
| 74 | 74 | } |
| 75 | 75 | /** Box with the complete order content */ |
| 76 | - add_meta_box( 'wpshop_order_content', '<span class="dashicons dashicons-cart"></span> '.__('Order content', 'wpshop'), array( $this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
| 76 | + add_meta_box('wpshop_order_content', '<span class="dashicons dashicons-cart"></span> ' . __('Order content', 'wpshop'), array($this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
| 77 | 77 | /** Box Private order comments **/ |
| 78 | - if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) { |
|
| 79 | - add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> '.__('Comments', 'wpshop'), array( $this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
| 78 | + if (!in_array($post->post_status, array('auto-draft'))) { |
|
| 79 | + add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> ' . __('Comments', 'wpshop'), array($this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -84,65 +84,65 @@ discard block |
||
| 84 | 84 | * METABOX CONTENT - Display Customer comments on order in administration panel |
| 85 | 85 | * @param object $order |
| 86 | 86 | */ |
| 87 | - function order_customer_comment_box( $order ) { |
|
| 88 | - if ( !empty($order) && !empty($order->ID) ) { |
|
| 89 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box") ); |
|
| 87 | + function order_customer_comment_box($order) { |
|
| 88 | + if (!empty($order) && !empty($order->ID)) { |
|
| 89 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box")); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * METABOX CONTENT - Display an order historic of product in administration product panel |
| 95 | 95 | */ |
| 96 | - function meta_box_product_sale_informations () { |
|
| 96 | + function meta_box_product_sale_informations() { |
|
| 97 | 97 | global $post; |
| 98 | 98 | $product_id = $post->ID; |
| 99 | - $variations = wpshop_products::get_variation( $product_id ); |
|
| 100 | - $order_status = unserialize( WPSHOP_ORDER_STATUS ); |
|
| 101 | - $color_label = array( 'awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu'); |
|
| 99 | + $variations = wpshop_products::get_variation($product_id); |
|
| 100 | + $order_status = unserialize(WPSHOP_ORDER_STATUS); |
|
| 101 | + $color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu'); |
|
| 102 | 102 | // Get datas |
| 103 | 103 | $sales_informations = array(); |
| 104 | 104 | /** Query **/ |
| 105 | - $data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";'; |
|
| 106 | - $query_args = array( 'posts_per_page' => 10, 'paged' => absint( isset( $_GET['paged_sales'] ) ? $_GET['paged_sales'] : 1 ), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) ); |
|
| 107 | - $orders = new WP_Query( $query_args ); |
|
| 108 | - if ( !empty($orders) && !empty($orders->posts) ) { |
|
| 109 | - foreach( $orders->posts as $order ) { |
|
| 110 | - $order_meta = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
| 111 | - $order_info = get_post_meta( $order->ID, '_order_info', true ); |
|
| 105 | + $data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";'; |
|
| 106 | + $query_args = array('posts_per_page' => 10, 'paged' => absint(isset($_GET['paged_sales']) ? $_GET['paged_sales'] : 1), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE'))); |
|
| 107 | + $orders = new WP_Query($query_args); |
|
| 108 | + if (!empty($orders) && !empty($orders->posts)) { |
|
| 109 | + foreach ($orders->posts as $order) { |
|
| 110 | + $order_meta = get_post_meta($order->ID, '_order_postmeta', true); |
|
| 111 | + $order_info = get_post_meta($order->ID, '_order_info', true); |
|
| 112 | 112 | $sales_informations[] = array( |
| 113 | - 'order_key' => ( !empty($order_meta) && !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '', |
|
| 114 | - 'order_date' => ( !empty($order_meta) && !empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '', |
|
| 115 | - 'customer_firstname' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '', |
|
| 116 | - 'customer_name' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '', |
|
| 117 | - 'customer_email' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '', |
|
| 113 | + 'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '', |
|
| 114 | + 'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '', |
|
| 115 | + 'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '', |
|
| 116 | + 'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '', |
|
| 117 | + 'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : '', |
|
| 118 | 118 | 'order_id' => $order->ID, |
| 119 | 119 | 'order_status' => $order_meta['order_status'] |
| 120 | 120 | ); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | // Display results |
| 124 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic") ); |
|
| 124 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic")); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * METABOX CONTENT - Payments Box in Orders panel |
| 129 | 129 | * @param string $order |
| 130 | 130 | */ |
| 131 | - function display_order_payments_box( $order ) { |
|
| 131 | + function display_order_payments_box($order) { |
|
| 132 | 132 | $order_status = unserialize(WPSHOP_ORDER_STATUS); |
| 133 | 133 | $order_postmeta = get_post_meta($order->ID, '_order_postmeta', true); |
| 134 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box") ); |
|
| 134 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box")); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * METABOX CONTENT - Display an lsiting of products to make quotation in backend |
| 139 | 139 | */ |
| 140 | - function wps_products_listing_for_quotation( $post ) { |
|
| 141 | - $letters = array( 'ALL', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); |
|
| 142 | - $current_letter = sanitize_title( $letters[0] ); |
|
| 140 | + function wps_products_listing_for_quotation($post) { |
|
| 141 | + $letters = array('ALL', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); |
|
| 142 | + $current_letter = sanitize_title($letters[0]); |
|
| 143 | 143 | $wps_product_mdl = new wps_product_mdl(); |
| 144 | - $products = $wps_product_mdl->get_products_by_letter( $current_letter ); |
|
| 145 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing") ); |
|
| 144 | + $products = $wps_product_mdl->get_products_by_letter($current_letter); |
|
| 145 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing")); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | function meta_box_private_comment() { |
| 152 | 152 | global $post; |
| 153 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments") ); |
|
| 153 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments")); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | function meta_box_order_content() { |
| 160 | 160 | global $post_id; |
| 161 | - unset( $_SESSION['cart'] ); |
|
| 162 | - echo do_shortcode( '[wps_cart oid="' .$post_id. '" cart_type="admin-panel"]'); |
|
| 161 | + unset($_SESSION['cart']); |
|
| 162 | + echo do_shortcode('[wps_cart oid="' . $post_id . '" cart_type="admin-panel"]'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -169,68 +169,68 @@ discard block |
||
| 169 | 169 | function save_order_custom_informations() { |
| 170 | 170 | global $wpdb; |
| 171 | 171 | |
| 172 | - $post_ID = !empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0; |
|
| 172 | + $post_ID = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0; |
|
| 173 | 173 | // Check if it is an order save action |
| 174 | - if ( !empty($post_ID) && ( get_post_type($post_ID) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) ) { |
|
| 174 | + if (!empty($post_ID) && (get_post_type($post_ID) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
|
| 175 | 175 | //Define Customer ID |
| 176 | - $user_id = ( !empty( $_REQUEST['wps_customer_id'] ) ) ? (int) $_REQUEST['wps_customer_id'] : get_current_user_id(); |
|
| 176 | + $user_id = (!empty($_REQUEST['wps_customer_id'])) ? (int)$_REQUEST['wps_customer_id'] : get_current_user_id(); |
|
| 177 | 177 | |
| 178 | 178 | // Order MetaData |
| 179 | - $order_meta = get_post_meta( $post_ID, '_order_postmeta', true); |
|
| 179 | + $order_meta = get_post_meta($post_ID, '_order_postmeta', true); |
|
| 180 | 180 | |
| 181 | 181 | // Save General information of order's attached customer |
| 182 | - $wpdb->update( $wpdb->posts, array('post_author' => $user_id, 'post_parent' => $user_id, 'post_status' => 'publish'), array('ID' => $post_ID) ); |
|
| 183 | - update_post_meta( $post_ID, '_wpshop_order_customer_id', $user_id ); |
|
| 182 | + $wpdb->update($wpdb->posts, array('post_author' => $user_id, 'post_parent' => $user_id, 'post_status' => 'publish'), array('ID' => $post_ID)); |
|
| 183 | + update_post_meta($post_ID, '_wpshop_order_customer_id', $user_id); |
|
| 184 | 184 | $order_meta['customer_id'] = $user_id; |
| 185 | - if ( empty($order_meta['order_key']) ) { |
|
| 186 | - $order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status']!='awaiting_payment') ? wpshop_orders::get_new_order_reference() : ''); |
|
| 185 | + if (empty($order_meta['order_key'])) { |
|
| 186 | + $order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status'] != 'awaiting_payment') ? wpshop_orders::get_new_order_reference() : ''); |
|
| 187 | 187 | $order_meta['order_temporary_key'] = (isset($order_meta['order_temporary_key']) && ($order_meta['order_temporary_key'] != '')) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference(); |
| 188 | 188 | } |
| 189 | 189 | $order_meta['order_status'] = (isset($order_meta['order_status']) && ($order_meta['order_status'] != '')) ? $order_meta['order_status'] : 'awaiting_payment'; |
| 190 | 190 | $order_meta['order_date'] = (isset($order_meta['order_date']) && ($order_meta['order_date'] != '')) ? $order_meta['order_date'] : current_time('mysql', 0); |
| 191 | 191 | $order_meta['order_currency'] = wpshop_tools::wpshop_get_currency(true); |
| 192 | 192 | |
| 193 | - $billing_adress_id = ( !empty( $_REQUEST['wps_order_selected_address'] ) && !empty( $_REQUEST['wps_order_selected_address']['billing'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['billing'] : 0; |
|
| 193 | + $billing_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['billing'])) ? (int)$_REQUEST['wps_order_selected_address']['billing'] : 0; |
|
| 194 | 194 | |
| 195 | 195 | // Order Attached Addresses save |
| 196 | - if( !empty( $billing_adress_id ) ) { |
|
| 196 | + if (!empty($billing_adress_id)) { |
|
| 197 | 197 | // Informations |
| 198 | - $order_informations = get_post_meta( $post_ID, '_order_info', true ); |
|
| 199 | - $order_informations = ( !empty($order_informations) ) ? $order_informations : array(); |
|
| 200 | - $billing_address_option = get_option( 'wpshop_billing_address' ); |
|
| 201 | - $billing_address_option = ( !empty($billing_address_option) && !empty( $billing_address_option['choice'] ) ) ? $billing_address_option['choice'] : ''; |
|
| 198 | + $order_informations = get_post_meta($post_ID, '_order_info', true); |
|
| 199 | + $order_informations = (!empty($order_informations)) ? $order_informations : array(); |
|
| 200 | + $billing_address_option = get_option('wpshop_billing_address'); |
|
| 201 | + $billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : ''; |
|
| 202 | 202 | |
| 203 | 203 | // Billing datas |
| 204 | - $order_informations['billing'] = array( 'id' => $billing_address_option, |
|
| 204 | + $order_informations['billing'] = array('id' => $billing_address_option, |
|
| 205 | 205 | 'address_id' => $billing_adress_id, |
| 206 | - 'address' => get_post_meta( $billing_adress_id, '_wpshop_address_metadata', true ) |
|
| 206 | + 'address' => get_post_meta($billing_adress_id, '_wpshop_address_metadata', true) |
|
| 207 | 207 | ); |
| 208 | 208 | // Shipping datas |
| 209 | - $shipping_adress_id = ( !empty( $_REQUEST['wps_order_selected_address'] ) && !empty( $_REQUEST['wps_order_selected_address']['shipping'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['shipping'] : 0; |
|
| 209 | + $shipping_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['shipping'])) ? (int)$_REQUEST['wps_order_selected_address']['shipping'] : 0; |
|
| 210 | 210 | |
| 211 | - if( !empty( $shipping_adress_id ) ) { |
|
| 212 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 213 | - $shipping_address_option = ( !empty($shipping_address_option) && !empty($shipping_address_option['choice']) ) ? $shipping_address_option['choice'] : ''; |
|
| 214 | - $order_informations['shipping'] = array( 'id' => $shipping_address_option, |
|
| 211 | + if (!empty($shipping_adress_id)) { |
|
| 212 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
| 213 | + $shipping_address_option = (!empty($shipping_address_option) && !empty($shipping_address_option['choice'])) ? $shipping_address_option['choice'] : ''; |
|
| 214 | + $order_informations['shipping'] = array('id' => $shipping_address_option, |
|
| 215 | 215 | 'address_id' => $shipping_adress_id, |
| 216 | - 'address' => get_post_meta( $shipping_adress_id, '_wpshop_address_metadata', true ) |
|
| 216 | + 'address' => get_post_meta($shipping_adress_id, '_wpshop_address_metadata', true) |
|
| 217 | 217 | ); |
| 218 | 218 | } |
| 219 | - update_post_meta( $post_ID, '_order_info', $order_informations ); |
|
| 219 | + update_post_meta($post_ID, '_order_info', $order_informations); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $wpshop_admin_order_payment_received = !empty( $_REQUEST['wpshop_admin_order_payment_received'] ) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array(); |
|
| 223 | - $wpshop_admin_order_payment_received['method'] = !empty( $wpshop_admin_order_payment_received['method'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['method'] ) : ''; |
|
| 224 | - $wpshop_admin_order_payment_received['payment_reference'] = !empty( $wpshop_admin_order_payment_received['payment_reference'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['payment_reference'] ) : ''; |
|
| 225 | - $wpshop_admin_order_payment_received['date'] = !empty( $wpshop_admin_order_payment_received['date'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['date'] ) : ''; |
|
| 226 | - $wpshop_admin_order_payment_received['received_amount'] = !empty( $wpshop_admin_order_payment_received['received_amount'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['received_amount'] ) : ''; |
|
| 227 | - $action_triggered_from = !empty( $_REQUEST['action_triggered_from'] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : ''; |
|
| 228 | - $wshop_admin_order_payment_reference = !empty( $_REQUEST['wpshop_admin_order_payment_reference'] ) ? sanitize_text_field( $_REQUEST['wpshop_admin_order_payment_reference'] ) : ''; |
|
| 222 | + $wpshop_admin_order_payment_received = !empty($_REQUEST['wpshop_admin_order_payment_received']) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array(); |
|
| 223 | + $wpshop_admin_order_payment_received['method'] = !empty($wpshop_admin_order_payment_received['method']) ? sanitize_text_field($wpshop_admin_order_payment_received['method']) : ''; |
|
| 224 | + $wpshop_admin_order_payment_received['payment_reference'] = !empty($wpshop_admin_order_payment_received['payment_reference']) ? sanitize_text_field($wpshop_admin_order_payment_received['payment_reference']) : ''; |
|
| 225 | + $wpshop_admin_order_payment_received['date'] = !empty($wpshop_admin_order_payment_received['date']) ? sanitize_text_field($wpshop_admin_order_payment_received['date']) : ''; |
|
| 226 | + $wpshop_admin_order_payment_received['received_amount'] = !empty($wpshop_admin_order_payment_received['received_amount']) ? sanitize_text_field($wpshop_admin_order_payment_received['received_amount']) : ''; |
|
| 227 | + $action_triggered_from = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : ''; |
|
| 228 | + $wshop_admin_order_payment_reference = !empty($_REQUEST['wpshop_admin_order_payment_reference']) ? sanitize_text_field($_REQUEST['wpshop_admin_order_payment_reference']) : ''; |
|
| 229 | 229 | |
| 230 | 230 | // Add a Payment to Order MetaData |
| 231 | - if ( !empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method']) |
|
| 231 | + if (!empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method']) |
|
| 232 | 232 | && !empty($wpshop_admin_order_payment_received['date']) && !empty($wpshop_admin_order_payment_received['received_amount']) && |
| 233 | - ( $action_triggered_from == 'add_payment' || !empty($wshop_admin_order_payment_reference) ) ) { |
|
| 233 | + ($action_triggered_from == 'add_payment' || !empty($wshop_admin_order_payment_reference))) { |
|
| 234 | 234 | |
| 235 | 235 | $received_payment_amount = $wpshop_admin_order_payment_received['received_amount']; |
| 236 | 236 | // Payment Params |
@@ -243,36 +243,36 @@ discard block |
||
| 243 | 243 | 'date' => current_time('mysql', 0), |
| 244 | 244 | 'received_amount' => $received_payment_amount |
| 245 | 245 | ); |
| 246 | - $order_meta = wpshop_payment::check_order_payment_total_amount($post_ID, $params_array, 'completed', $order_meta, false ); |
|
| 246 | + $order_meta = wpshop_payment::check_order_payment_total_amount($post_ID, $params_array, 'completed', $order_meta, false); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | //Round final amount |
| 250 | - $order_meta['order_grand_total'] = number_format( round($order_meta['order_grand_total'], 2), 2, '.', ''); |
|
| 251 | - $order_meta['order_total_ttc'] = number_format( round($order_meta['order_total_ttc'], 2), 2, '.', ''); |
|
| 252 | - $order_meta['order_amount_to_pay_now'] = number_format( round($order_meta['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 250 | + $order_meta['order_grand_total'] = number_format(round($order_meta['order_grand_total'], 2), 2, '.', ''); |
|
| 251 | + $order_meta['order_total_ttc'] = number_format(round($order_meta['order_total_ttc'], 2), 2, '.', ''); |
|
| 252 | + $order_meta['order_amount_to_pay_now'] = number_format(round($order_meta['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 253 | 253 | |
| 254 | 254 | // Payment Pre-Fill |
| 255 | - if ( empty( $order_meta['order_payment'] ) ) { |
|
| 255 | + if (empty($order_meta['order_payment'])) { |
|
| 256 | 256 | $order_meta['order_payment']['customer_choice']['method'] = ''; |
| 257 | - $order_meta['order_payment']['received'][] = array('waited_amount' => ( !empty($order_meta) && !empty($order_meta['order_grand_total']) ) ? number_format($order_meta['order_grand_total'],2,'.', '') : 0 ); |
|
| 257 | + $order_meta['order_payment']['received'][] = array('waited_amount' => (!empty($order_meta) && !empty($order_meta['order_grand_total'])) ? number_format($order_meta['order_grand_total'], 2, '.', '') : 0); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $data['post_ID'] = !empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0; |
|
| 261 | - $data['markascanceled_order_hidden_indicator'] = !empty( $_REQUEST['markascanceled_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['markascanceled_order_hidden_indicator'] ) : ''; |
|
| 262 | - $data['resendordertocustomer_order_hidden_indicator'] = !empty( $_REQUEST['resendordertocustomer_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['resendordertocustomer_order_hidden_indicator'] ) : ''; |
|
| 263 | - $data['action_triggered_from'] = !empty( $_REQUEST['action_triggered_from' ] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : ''; |
|
| 264 | - $data['notif_the_customer'] = !empty( $_REQUEST['notif_the_customer' ] ) ? sanitize_text_field( $_REQUEST['notif_the_customer'] ) : ''; |
|
| 260 | + $data['post_ID'] = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0; |
|
| 261 | + $data['markascanceled_order_hidden_indicator'] = !empty($_REQUEST['markascanceled_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['markascanceled_order_hidden_indicator']) : ''; |
|
| 262 | + $data['resendordertocustomer_order_hidden_indicator'] = !empty($_REQUEST['resendordertocustomer_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['resendordertocustomer_order_hidden_indicator']) : ''; |
|
| 263 | + $data['action_triggered_from'] = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : ''; |
|
| 264 | + $data['notif_the_customer'] = !empty($_REQUEST['notif_the_customer']) ? sanitize_text_field($_REQUEST['notif_the_customer']) : ''; |
|
| 265 | 265 | // Apply a filter to make credit, notificate the customer and generate billing actions |
| 266 | - $order_meta = apply_filters( 'wps_order_saving_admin_extra_action', $order_meta, $data ); |
|
| 266 | + $order_meta = apply_filters('wps_order_saving_admin_extra_action', $order_meta, $data); |
|
| 267 | 267 | |
| 268 | 268 | // Save Shipping informations & Order status |
| 269 | - if ( isset( $order_meta['order_shipping_date'] ) ) { |
|
| 270 | - update_post_meta( $post_ID, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']); |
|
| 269 | + if (isset($order_meta['order_shipping_date'])) { |
|
| 270 | + update_post_meta($post_ID, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']); |
|
| 271 | 271 | } |
| 272 | - update_post_meta( $post_ID, '_wpshop_order_status', $order_meta['order_status']); |
|
| 272 | + update_post_meta($post_ID, '_wpshop_order_status', $order_meta['order_status']); |
|
| 273 | 273 | |
| 274 | 274 | // Save Metadata |
| 275 | - update_post_meta( $post_ID, '_order_postmeta', $order_meta); |
|
| 275 | + update_post_meta($post_ID, '_order_postmeta', $order_meta); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | * @param array $posted_datas |
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | - function wps_notif_user_on_order_saving( $order_metadata, $posted_datas ) { |
|
| 287 | - if( !empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer']=='on' ) { |
|
| 286 | + function wps_notif_user_on_order_saving($order_metadata, $posted_datas) { |
|
| 287 | + if (!empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer'] == 'on') { |
|
| 288 | 288 | $wps_message = new wps_message_ctr(); |
| 289 | 289 | /* Get order current content */ |
| 290 | 290 | $user = get_post_meta($posted_datas['post_ID'], '_order_info', true); |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | $first_name = $user['billing']['address']['address_first_name']; |
| 294 | 294 | $last_name = $user['billing']['address']['address_last_name']; |
| 295 | 295 | |
| 296 | - $object = array('object_type'=>'order','object_id'=>(int)$_REQUEST['post_ID']); |
|
| 296 | + $object = array('object_type'=>'order', 'object_id'=>(int)$_REQUEST['post_ID']); |
|
| 297 | 297 | /* Envoie du message de confirmation de commande au client */ |
| 298 | - if ( empty( $order_metadata['order_key'] ) ) { |
|
| 298 | + if (empty($order_metadata['order_key'])) { |
|
| 299 | 299 | $wps_message->wpshop_prepared_email($email, |
| 300 | 300 | 'WPSHOP_QUOTATION_UPDATE_MESSAGE', |
| 301 | - array( 'order_id' => $object['object_id'], |
|
| 301 | + array('order_id' => $object['object_id'], |
|
| 302 | 302 | 'customer_first_name' => $first_name, |
| 303 | 303 | 'customer_last_name' => $last_name, |
| 304 | 304 | 'order_date' => current_time('mysql', 0), |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $wps_message->wpshop_prepared_email( |
| 314 | 314 | $email, |
| 315 | 315 | 'WPSHOP_ORDER_UPDATE_MESSAGE', |
| 316 | - array( 'customer_first_name' => $first_name, |
|
| 316 | + array('customer_first_name' => $first_name, |
|
| 317 | 317 | 'customer_last_name' => $last_name, |
| 318 | 318 | 'order_key' => $order_metadata['order_key'], |
| 319 | 319 | 'order_billing_address' => '', |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | 'order_addresses' => '', |
| 322 | 322 | 'order_addresses' => '', |
| 323 | 323 | 'order_billing_address' => '', |
| 324 | - 'order_shipping_address' => '' ), |
|
| 324 | + 'order_shipping_address' => ''), |
|
| 325 | 325 | $object); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -332,25 +332,25 @@ discard block |
||
| 332 | 332 | * AJAX - Add a private comment to order |
| 333 | 333 | */ |
| 334 | 334 | function wpshop_add_private_comment_to_order() { |
| 335 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 335 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 336 | 336 | |
| 337 | - if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) |
|
| 337 | + if (!wp_verify_nonce($_wpnonce, 'wpshop_add_private_comment_to_order')) |
|
| 338 | 338 | wp_die(); |
| 339 | 339 | |
| 340 | 340 | $status = false; $result = ''; |
| 341 | - $order_id = ( !empty($_POST['oid']) ) ? intval($_POST['oid']) : null; |
|
| 342 | - $comment = ( !empty($_POST['comment']) ) ? wpshop_tools::varSanitizer($_POST['comment']) : null; |
|
| 343 | - $send_email = ( !empty($_POST['send_email']) ) ? wpshop_tools::varSanitizer($_POST['send_email']) : null; |
|
| 344 | - $copy_to_administrator = ( !empty($_POST['copy_to_administrator']) ) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null; |
|
| 341 | + $order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null; |
|
| 342 | + $comment = (!empty($_POST['comment'])) ? wpshop_tools::varSanitizer($_POST['comment']) : null; |
|
| 343 | + $send_email = (!empty($_POST['send_email'])) ? wpshop_tools::varSanitizer($_POST['send_email']) : null; |
|
| 344 | + $copy_to_administrator = (!empty($_POST['copy_to_administrator'])) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null; |
|
| 345 | 345 | |
| 346 | - if ( !empty($comment) && !empty($order_id) ) { |
|
| 346 | + if (!empty($comment) && !empty($order_id)) { |
|
| 347 | 347 | $wps_back_office_orders_mdl = new wps_back_office_orders_mdl(); |
| 348 | - $new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator ); |
|
| 349 | - if($new_comment) { |
|
| 350 | - $order_private_comment = get_post_meta( $order_id, '_order_private_comments', true ); |
|
| 348 | + $new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator); |
|
| 349 | + if ($new_comment) { |
|
| 350 | + $order_private_comment = get_post_meta($order_id, '_order_private_comments', true); |
|
| 351 | 351 | $oid = $order_id; |
| 352 | 352 | ob_start(); |
| 353 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments") ); |
|
| 353 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments")); |
|
| 354 | 354 | $result = ob_get_contents(); |
| 355 | 355 | ob_end_clean(); |
| 356 | 356 | $status = true; |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | $result = __('An error was occured', 'wpshop'); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $response = array( 'status' => $status, 'response' => $result ); |
|
| 364 | - echo json_encode( $response ); |
|
| 363 | + $response = array('status' => $status, 'response' => $result); |
|
| 364 | + echo json_encode($response); |
|
| 365 | 365 | wp_die(); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -369,34 +369,34 @@ discard block |
||
| 369 | 369 | * AJAX - Refresh product listing in order back-office |
| 370 | 370 | */ |
| 371 | 371 | function refresh_product_list() { |
| 372 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 373 | - $letter = ( !empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : ''; |
|
| 374 | - $research = !empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : ''; |
|
| 372 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 373 | + $letter = (!empty($_POST['letter'])) ? sanitize_title($_POST['letter']) : ''; |
|
| 374 | + $research = !empty($_POST['research']) ? sanitize_text_field($_POST['research']) : ''; |
|
| 375 | 375 | |
| 376 | - if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) |
|
| 376 | + if (!wp_verify_nonce($_wpnonce, 'refresh_product_list_' . strtolower($letter))) |
|
| 377 | 377 | wp_die(); |
| 378 | 378 | |
| 379 | 379 | $status = false; $response = ''; |
| 380 | - $oid = !empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0; |
|
| 380 | + $oid = !empty($_POST['oid']) ? (int)$_POST['oid'] : 0; |
|
| 381 | 381 | |
| 382 | - if( !empty($oid) ) { |
|
| 383 | - $post = get_post( $oid ); |
|
| 382 | + if (!empty($oid)) { |
|
| 383 | + $post = get_post($oid); |
|
| 384 | 384 | } |
| 385 | - if( !empty($letter) ) { |
|
| 385 | + if (!empty($letter)) { |
|
| 386 | 386 | $current_letter = $letter; |
| 387 | 387 | $wps_product_mdl = new wps_product_mdl(); |
| 388 | - if( !empty( $research ) ) { |
|
| 389 | - $products = $wps_product_mdl->get_products_by_title_or_barcode( $research, strlen( $research ) >= 8 && ctype_digit( $research ) ); |
|
| 388 | + if (!empty($research)) { |
|
| 389 | + $products = $wps_product_mdl->get_products_by_title_or_barcode($research, strlen($research) >= 8 && ctype_digit($research)); |
|
| 390 | 390 | } else { |
| 391 | - $products = $wps_product_mdl->get_products_by_letter( $letter ); |
|
| 391 | + $products = $wps_product_mdl->get_products_by_letter($letter); |
|
| 392 | 392 | } |
| 393 | 393 | ob_start(); |
| 394 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table") ); |
|
| 394 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table")); |
|
| 395 | 395 | $response = ob_get_contents(); |
| 396 | 396 | ob_end_clean(); |
| 397 | 397 | $status = true; |
| 398 | 398 | } |
| 399 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
| 399 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 400 | 400 | wp_die(); |
| 401 | 401 | } |
| 402 | 402 | |
@@ -404,38 +404,38 @@ discard block |
||
| 404 | 404 | * AJAX - Add product to order in back-office panel |
| 405 | 405 | */ |
| 406 | 406 | function wps_add_product_to_order_admin() { |
| 407 | - check_ajax_referer( 'wps_add_product_to_order_admin' ); |
|
| 407 | + check_ajax_referer('wps_add_product_to_order_admin'); |
|
| 408 | 408 | |
| 409 | 409 | $status = false; $response = ''; $product_have_variations = false; |
| 410 | 410 | // Sended vars |
| 411 | - $product_id = ( !empty($_POST['pid']) ) ? intval( $_POST['pid']) : null; |
|
| 412 | - $order_id = ( !empty($_POST['oid']) ) ? intval( $_POST['oid']) : null; |
|
| 413 | - $product_qty = ( !empty($_POST['qty']) ) ? intval( $_POST['qty']) : 1; |
|
| 411 | + $product_id = (!empty($_POST['pid'])) ? intval($_POST['pid']) : null; |
|
| 412 | + $order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null; |
|
| 413 | + $product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 1; |
|
| 414 | 414 | |
| 415 | - if( !empty($order_id) && !empty($product_id) ) { |
|
| 415 | + if (!empty($order_id) && !empty($product_id)) { |
|
| 416 | 416 | $wps_orders = new wps_orders_ctr(); |
| 417 | 417 | $product_datas = wpshop_products::get_product_data($product_id, false, '"publish", "free_product"'); |
| 418 | 418 | // Check if product have variations |
| 419 | - $have_variations_checking = wpshop_products::get_variation( $product_id ); |
|
| 420 | - if( !empty($have_variations_checking) ) { |
|
| 419 | + $have_variations_checking = wpshop_products::get_variation($product_id); |
|
| 420 | + if (!empty($have_variations_checking)) { |
|
| 421 | 421 | $product_have_variations = true; |
| 422 | 422 | } |
| 423 | 423 | else { |
| 424 | 424 | // Get Metadatas |
| 425 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 425 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 426 | 426 | // Calcul cart informations |
| 427 | 427 | $wps_cart = new wps_cart(); |
| 428 | - $order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false ); |
|
| 428 | + $order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false); |
|
| 429 | 429 | // Update Metadatas |
| 430 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
| 430 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
| 431 | 431 | $status = true; |
| 432 | 432 | } |
| 433 | 433 | $status = true; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $_wpnonce = wp_create_nonce( 'wps_order_load_product_variations' ); |
|
| 436 | + $_wpnonce = wp_create_nonce('wps_order_load_product_variations'); |
|
| 437 | 437 | |
| 438 | - echo json_encode( array( '_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations ) ); |
|
| 438 | + echo json_encode(array('_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations)); |
|
| 439 | 439 | wp_die(); |
| 440 | 440 | } |
| 441 | 441 | |
@@ -443,15 +443,15 @@ discard block |
||
| 443 | 443 | * AJAX - Refresh cart in administration |
| 444 | 444 | */ |
| 445 | 445 | function refresh_cart_order() { |
| 446 | - check_ajax_referer( 'wps_reload_cart' ); |
|
| 446 | + check_ajax_referer('wps_reload_cart'); |
|
| 447 | 447 | |
| 448 | 448 | $status = false; $response = ''; |
| 449 | - $order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null; |
|
| 450 | - if( !empty($order_id) ) { |
|
| 451 | - $response = do_shortcode( '[wps_cart oid="' .$order_id. '" cart_type="admin-panel"]'); |
|
| 449 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 450 | + if (!empty($order_id)) { |
|
| 451 | + $response = do_shortcode('[wps_cart oid="' . $order_id . '" cart_type="admin-panel"]'); |
|
| 452 | 452 | $status = true; |
| 453 | 453 | } |
| 454 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
| 454 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 455 | 455 | wp_die(); |
| 456 | 456 | } |
| 457 | 457 | |
@@ -459,17 +459,17 @@ discard block |
||
| 459 | 459 | * AJAX - Refresh cart in administration |
| 460 | 460 | */ |
| 461 | 461 | function refresh_payments_order() { |
| 462 | - check_ajax_referer( 'wps_reload_cart' ); |
|
| 462 | + check_ajax_referer('wps_reload_cart'); |
|
| 463 | 463 | $status = false; $response = ''; |
| 464 | - $order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null; |
|
| 465 | - if( !empty($order_id) ) { |
|
| 464 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 465 | + if (!empty($order_id)) { |
|
| 466 | 466 | ob_start(); |
| 467 | - echo $this->display_order_payments_box( get_post( $order_id ) ); |
|
| 467 | + echo $this->display_order_payments_box(get_post($order_id)); |
|
| 468 | 468 | $response = ob_get_contents(); |
| 469 | 469 | ob_end_clean(); |
| 470 | 470 | $status = true; |
| 471 | 471 | } |
| 472 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
| 472 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 473 | 473 | wp_die(); |
| 474 | 474 | } |
| 475 | 475 | |
@@ -477,25 +477,25 @@ discard block |
||
| 477 | 477 | * AJAX - Update product Quantity in Back-office Panel |
| 478 | 478 | */ |
| 479 | 479 | function wps_update_product_qty_in_admin() { |
| 480 | - check_ajax_referer( 'wps_reload_cart' ); |
|
| 480 | + check_ajax_referer('wps_reload_cart'); |
|
| 481 | 481 | |
| 482 | 482 | $status = false; $response = ''; |
| 483 | - $product_id = ( !empty($_POST['product_id']) ) ? wpshop_tools::varSanitizer( $_POST['product_id'] ) : null; |
|
| 484 | - $order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null; |
|
| 485 | - $product_qty = ( !empty($_POST['qty']) ) ? intval( $_POST['qty'] ) : 0; |
|
| 483 | + $product_id = (!empty($_POST['product_id'])) ? wpshop_tools::varSanitizer($_POST['product_id']) : null; |
|
| 484 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 485 | + $product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 0; |
|
| 486 | 486 | |
| 487 | - if( !empty($product_id) && !empty($order_id) ) { |
|
| 487 | + if (!empty($product_id) && !empty($order_id)) { |
|
| 488 | 488 | // Get Metadatas |
| 489 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 489 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 490 | 490 | // Calcul cart informations |
| 491 | 491 | $wps_cart = new wps_cart(); |
| 492 | - $order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false ); |
|
| 492 | + $order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false); |
|
| 493 | 493 | // Update Metadatas |
| 494 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
| 494 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
| 495 | 495 | $status = true; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - echo json_encode( array( 'status' => $status ) ); |
|
| 498 | + echo json_encode(array('status' => $status)); |
|
| 499 | 499 | wp_die(); |
| 500 | 500 | } |
| 501 | 501 | |
@@ -503,15 +503,15 @@ discard block |
||
| 503 | 503 | * AJAX - Load Product Variations in ThickBox on Add product to order action |
| 504 | 504 | */ |
| 505 | 505 | function wps_order_load_product_variations() { |
| 506 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 506 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 507 | 507 | |
| 508 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) |
|
| 508 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_load_product_variations')) |
|
| 509 | 509 | wp_die(); |
| 510 | 510 | |
| 511 | - $product_id = ( !empty($_GET['pid']) ) ? intval( $_GET['pid']) : null; |
|
| 512 | - $order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
|
| 513 | - $qty = ( !empty($_GET['qty']) ) ? intval( $_GET['qty']) : 1; |
|
| 514 | - echo '<div class="wps-boxed"><span class="wps-h5">'.__( 'Select your variations', 'wpshop' ).'</span>'.wpshop_products::wpshop_variation($product_id, true, $order_id, $qty ).'<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' .__( 'Add to cart', 'wpshop' ). '</a>'.'</div>'; |
|
| 511 | + $product_id = (!empty($_GET['pid'])) ? intval($_GET['pid']) : null; |
|
| 512 | + $order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null; |
|
| 513 | + $qty = (!empty($_GET['qty'])) ? intval($_GET['qty']) : 1; |
|
| 514 | + echo '<div class="wps-boxed"><span class="wps-h5">' . __('Select your variations', 'wpshop') . '</span>' . wpshop_products::wpshop_variation($product_id, true, $order_id, $qty) . '<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' . __('Add to cart', 'wpshop') . '</a>' . '</div>'; |
|
| 515 | 515 | wp_die(); |
| 516 | 516 | } |
| 517 | 517 | |
@@ -519,67 +519,67 @@ discard block |
||
| 519 | 519 | * AJAX - Update cart informations |
| 520 | 520 | */ |
| 521 | 521 | function wps_orders_update_cart_informations() { |
| 522 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 522 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 523 | 523 | |
| 524 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) |
|
| 524 | + if (!wp_verify_nonce($_wpnonce, 'wps_orders_update_cart_informations')) |
|
| 525 | 525 | wp_die(); |
| 526 | 526 | |
| 527 | 527 | $status = false; |
| 528 | - $order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : ''; |
|
| 528 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : ''; |
|
| 529 | 529 | $shipping_cost = isset($_POST['shipping_cost']) ? wpshop_tools::varSanitizer($_POST['shipping_cost']) : ''; |
| 530 | 530 | $discount_value = isset($_POST['discount_amount']) ? wpshop_tools::varSanitizer($_POST['discount_amount']) : ''; |
| 531 | 531 | $discount_type = isset($_POST['discount_type']) ? wpshop_tools::varSanitizer($_POST['discount_type']) : ''; |
| 532 | 532 | |
| 533 | 533 | |
| 534 | - if( !empty($order_id) ) { |
|
| 535 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 534 | + if (!empty($order_id)) { |
|
| 535 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 536 | 536 | $order_meta['order_shipping_cost'] = $shipping_cost; |
| 537 | 537 | |
| 538 | 538 | //Add discounts if exists |
| 539 | - if( isset($discount_value) && !empty($discount_type) ) { |
|
| 539 | + if (isset($discount_value) && !empty($discount_type)) { |
|
| 540 | 540 | $order_meta['order_discount_type'] = $discount_type; |
| 541 | 541 | $order_meta['order_discount_value'] = $discount_value; |
| 542 | 542 | } |
| 543 | 543 | $wps_cart = new wps_cart(); |
| 544 | - $order_meta = $wps_cart->calcul_cart_information( array(), '', $order_meta, true ); |
|
| 545 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 544 | + $order_meta = $wps_cart->calcul_cart_information(array(), '', $order_meta, true); |
|
| 545 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 546 | 546 | $status = true; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - echo json_encode( array( 'status' => $status) ); |
|
| 549 | + echo json_encode(array('status' => $status)); |
|
| 550 | 550 | wp_die(); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | function wps_reverify_payment_invoice_ref() { |
| 554 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 554 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 555 | 555 | |
| 556 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) |
|
| 556 | + if (!wp_verify_nonce($_wpnonce, 'wps_reverify_payment_invoice_ref')) |
|
| 557 | 557 | wp_die(); |
| 558 | 558 | |
| 559 | 559 | $status = true; |
| 560 | - $inputs = !empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false; |
|
| 560 | + $inputs = !empty($_POST['inputs']) ? (array)$_POST['inputs'] : false; |
|
| 561 | 561 | |
| 562 | 562 | if (!$inputs) |
| 563 | 563 | $status = false; |
| 564 | 564 | |
| 565 | - if( $status ) { |
|
| 565 | + if ($status) { |
|
| 566 | 566 | $inputs_clone = $inputs; |
| 567 | 567 | $inputs = array(); |
| 568 | - foreach( $inputs_clone as $var ) { |
|
| 569 | - if( isset( $var['key'] ) && isset( $var['value'] ) ) { |
|
| 568 | + foreach ($inputs_clone as $var) { |
|
| 569 | + if (isset($var['key']) && isset($var['value'])) { |
|
| 570 | 570 | $inputs[$var['key']] = $var['value']; |
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - ( isset( $inputs['order_id'] ) ) ? $order_id = $inputs['order_id'] : $status = $order_id = false; |
|
| 575 | - ( isset( $inputs['index_payment'] ) ) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false; |
|
| 574 | + (isset($inputs['order_id'])) ? $order_id = $inputs['order_id'] : $status = $order_id = false; |
|
| 575 | + (isset($inputs['index_payment'])) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - if( $status ) { |
|
| 579 | - $status = wpshop_payment::reverify_payment_invoice_ref( $order_id, $index_payment ); |
|
| 578 | + if ($status) { |
|
| 579 | + $status = wpshop_payment::reverify_payment_invoice_ref($order_id, $index_payment); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - echo json_encode( array( 'status' => $status ) ); |
|
| 582 | + echo json_encode(array('status' => $status)); |
|
| 583 | 583 | wp_die(); |
| 584 | 584 | } |
| 585 | 585 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | class wps_orders_in_back_office { |
| 3 | 5 | |
| 4 | 6 | function __construct() { |
@@ -31,8 +33,9 @@ discard block |
||
| 31 | 33 | */ |
| 32 | 34 | function wps_orders_scripts() { |
| 33 | 35 | global $current_screen; |
| 34 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
| 35 | - return; |
|
| 36 | + if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 36 | 39 | |
| 37 | 40 | wp_enqueue_style( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css' ); |
| 38 | 41 | wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js' ); |
@@ -308,8 +311,7 @@ discard block |
||
| 308 | 311 | 'order_shipping_address' => '' |
| 309 | 312 | ) |
| 310 | 313 | ); |
| 311 | - } |
|
| 312 | - else { |
|
| 314 | + } else { |
|
| 313 | 315 | $wps_message->wpshop_prepared_email( |
| 314 | 316 | $email, |
| 315 | 317 | 'WPSHOP_ORDER_UPDATE_MESSAGE', |
@@ -334,8 +336,9 @@ discard block |
||
| 334 | 336 | function wpshop_add_private_comment_to_order() { |
| 335 | 337 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
| 336 | 338 | |
| 337 | - if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) |
|
| 338 | - wp_die(); |
|
| 339 | + if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) { |
|
| 340 | + wp_die(); |
|
| 341 | + } |
|
| 339 | 342 | |
| 340 | 343 | $status = false; $result = ''; |
| 341 | 344 | $order_id = ( !empty($_POST['oid']) ) ? intval($_POST['oid']) : null; |
@@ -355,8 +358,7 @@ discard block |
||
| 355 | 358 | ob_end_clean(); |
| 356 | 359 | $status = true; |
| 357 | 360 | } |
| 358 | - } |
|
| 359 | - else { |
|
| 361 | + } else { |
|
| 360 | 362 | $result = __('An error was occured', 'wpshop'); |
| 361 | 363 | } |
| 362 | 364 | |
@@ -373,8 +375,9 @@ discard block |
||
| 373 | 375 | $letter = ( !empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : ''; |
| 374 | 376 | $research = !empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : ''; |
| 375 | 377 | |
| 376 | - if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) |
|
| 377 | - wp_die(); |
|
| 378 | + if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) { |
|
| 379 | + wp_die(); |
|
| 380 | + } |
|
| 378 | 381 | |
| 379 | 382 | $status = false; $response = ''; |
| 380 | 383 | $oid = !empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0; |
@@ -419,8 +422,7 @@ discard block |
||
| 419 | 422 | $have_variations_checking = wpshop_products::get_variation( $product_id ); |
| 420 | 423 | if( !empty($have_variations_checking) ) { |
| 421 | 424 | $product_have_variations = true; |
| 422 | - } |
|
| 423 | - else { |
|
| 425 | + } else { |
|
| 424 | 426 | // Get Metadatas |
| 425 | 427 | $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
| 426 | 428 | // Calcul cart informations |
@@ -505,8 +507,9 @@ discard block |
||
| 505 | 507 | function wps_order_load_product_variations() { |
| 506 | 508 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
| 507 | 509 | |
| 508 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) |
|
| 509 | - wp_die(); |
|
| 510 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) { |
|
| 511 | + wp_die(); |
|
| 512 | + } |
|
| 510 | 513 | |
| 511 | 514 | $product_id = ( !empty($_GET['pid']) ) ? intval( $_GET['pid']) : null; |
| 512 | 515 | $order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
@@ -521,8 +524,9 @@ discard block |
||
| 521 | 524 | function wps_orders_update_cart_informations() { |
| 522 | 525 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
| 523 | 526 | |
| 524 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) |
|
| 525 | - wp_die(); |
|
| 527 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) { |
|
| 528 | + wp_die(); |
|
| 529 | + } |
|
| 526 | 530 | |
| 527 | 531 | $status = false; |
| 528 | 532 | $order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : ''; |
@@ -553,14 +557,16 @@ discard block |
||
| 553 | 557 | function wps_reverify_payment_invoice_ref() { |
| 554 | 558 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
| 555 | 559 | |
| 556 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) |
|
| 557 | - wp_die(); |
|
| 560 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) { |
|
| 561 | + wp_die(); |
|
| 562 | + } |
|
| 558 | 563 | |
| 559 | 564 | $status = true; |
| 560 | 565 | $inputs = !empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false; |
| 561 | 566 | |
| 562 | - if (!$inputs) |
|
| 563 | - $status = false; |
|
| 567 | + if (!$inputs) { |
|
| 568 | + $status = false; |
|
| 569 | + } |
|
| 564 | 570 | |
| 565 | 571 | if( $status ) { |
| 566 | 572 | $inputs_clone = $inputs; |