@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Products management method file |
| 4 | 4 | * |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | /* Check if file is include. No direct access possible with file url */ |
| 13 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 14 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 13 | +if (!defined('WPSHOP_VERSION')) { |
|
| 14 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | /** Add action button */ |
| 71 | 71 | add_meta_box( |
| 72 | 72 | 'wpshop_order_actions', |
| 73 | - '<span class="dashicons dashicons-info"></span> '.__('Actions on order', 'wpshop'), |
|
| 73 | + '<span class="dashicons dashicons-info"></span> ' . __('Actions on order', 'wpshop'), |
|
| 74 | 74 | array('wpshop_orders', 'order_actions'), |
| 75 | 75 | WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'high' |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - if ( !in_array( $post->post_status, array( 'auto-draft' ) ) ) { |
|
| 78 | + if (!in_array($post->post_status, array('auto-draft'))) { |
|
| 79 | 79 | add_meta_box('wpshop_credit_actions', __('Credit on order', 'wpshop'), array('wps_credit', 'wps_credit_meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param object $order The current order being edited |
| 102 | 102 | */ |
| 103 | - public static function order_actions( $order ) { |
|
| 103 | + public static function order_actions($order) { |
|
| 104 | 104 | $output = ''; |
| 105 | 105 | |
| 106 | 106 | $order_status = unserialize(WPSHOP_ORDER_STATUS); |
@@ -108,34 +108,34 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $tpl_component = array(); |
| 110 | 110 | |
| 111 | - $delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url( get_delete_post_link($order->ID) ) , 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin'); |
|
| 112 | - $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : ''; |
|
| 111 | + $delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url(get_delete_post_link($order->ID)), 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin'); |
|
| 112 | + $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : ''; |
|
| 113 | 113 | |
| 114 | 114 | /** Add an action list */ |
| 115 | 115 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = ''; |
| 116 | 116 | |
| 117 | 117 | /** Display main information about the order */ |
| 118 | 118 | $order_main_info = ''; |
| 119 | - if(!empty($order_postmeta['order_date'])){ |
|
| 120 | - $order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>'.__('Order date','wpshop').' : </strong><br/>'.mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true).'</div>'; |
|
| 119 | + if (!empty($order_postmeta['order_date'])) { |
|
| 120 | + $order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>' . __('Order date', 'wpshop') . ' : </strong><br/>' . mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true) . '</div>'; |
|
| 121 | 121 | } |
| 122 | 122 | $order_main_info .= '<div class="wps-product-section">'; |
| 123 | - if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
|
| 124 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
|
| 123 | + if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) { |
|
| 124 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>'; |
|
| 125 | 125 | } |
| 126 | - else{ |
|
| 127 | - if(!empty($order_postmeta['order_key'])){ |
|
| 128 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
|
| 126 | + else { |
|
| 127 | + if (!empty($order_postmeta['order_key'])) { |
|
| 128 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>'; |
|
| 129 | 129 | } |
| 130 | - if(!empty($order_postmeta['order_temporary_key'])){ |
|
| 131 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>'; |
|
| 132 | - $post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; |
|
| 133 | - $order_main_info .= '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf' ) . '">' .__('Download the quotation', 'wpshop'). '</a><br />'; |
|
| 130 | + if (!empty($order_postmeta['order_temporary_key'])) { |
|
| 131 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>'; |
|
| 132 | + $post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0; |
|
| 133 | + $order_main_info .= '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf') . '">' . __('Download the quotation', 'wpshop') . '</a><br />'; |
|
| 134 | 134 | } |
| 135 | - if(!empty($order_postmeta['order_invoice_ref'])){ |
|
| 135 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 136 | 136 | $sub_tpl_component = array(); |
| 137 | - $order_invoice_download = '<a href="' . admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_invoice_ref'] . '&mode=pdf' ) . '">' . __('Download invoice', 'wpshop') . '</a><br />'; |
|
| 138 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
|
| 137 | + $order_invoice_download = '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_invoice_ref'] . '&mode=pdf') . '">' . __('Download invoice', 'wpshop') . '</a><br />'; |
|
| 138 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . ''; |
|
| 139 | 139 | } |
| 140 | 140 | else { |
| 141 | 141 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | /*Add the current order status in display**/ |
| 148 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= ( !empty($order_postmeta['order_status']) ) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) ) : ''; |
|
| 148 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= (!empty($order_postmeta['order_status'])) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop'))) : ''; |
|
| 149 | 149 | |
| 150 | 150 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info; |
| 151 | 151 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | </div>'; |
| 164 | 164 | }*/ |
| 165 | 165 | |
| 166 | - if( ( ( !empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation' ) || !empty( $order_postmeta['order_temporary_key'] ) ) && in_array( $order_postmeta['order_status'], array( 'awaiting_payment', 'partially_paid' ) ) && (float) $order_postmeta['order_amount_to_pay_now'] != (float) 0 ) { |
|
| 167 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation( isset( $order_postmeta['pay_quotation'] ), $order->ID ) . '</div>'; |
|
| 166 | + if (((!empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation') || !empty($order_postmeta['order_temporary_key'])) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid')) && (float)$order_postmeta['order_amount_to_pay_now'] != (float)0) { |
|
| 167 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation(isset($order_postmeta['pay_quotation']), $order->ID) . '</div>'; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -175,30 +175,30 @@ discard block |
||
| 175 | 175 | }*/ |
| 176 | 176 | |
| 177 | 177 | /*Add the button regarding the order status**/ |
| 178 | - if ( !empty($order_postmeta['order_status']) ) { |
|
| 179 | - if( $order_postmeta['order_status'] == 'awaiting_payment' ) { |
|
| 180 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_'.$order->ID.'" >'.__('Cancel this order', 'wpshop').'</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>'; |
|
| 178 | + if (!empty($order_postmeta['order_status'])) { |
|
| 179 | + if ($order_postmeta['order_status'] == 'awaiting_payment') { |
|
| 180 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_' . $order->ID . '" >' . __('Cancel this order', 'wpshop') . '</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>'; |
|
| 181 | 181 | } |
| 182 | - $credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true ); |
|
| 182 | + $credit_meta = get_post_meta($order->ID, '_wps_order_credit', true); |
|
| 183 | 183 | |
| 184 | - $total_received = (float) 0; |
|
| 185 | - if ( ! empty( $order_postmeta['order_payment'] ) && ! empty( $order_postmeta['order_payment']['received'] ) ) { |
|
| 186 | - foreach( $order_postmeta['order_payment']['received'] as $received ) { |
|
| 187 | - $total_received += (float) isset( $received['received_amount'] ) ? $received['received_amount'] : 0; |
|
| 184 | + $total_received = (float)0; |
|
| 185 | + if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received'])) { |
|
| 186 | + foreach ($order_postmeta['order_payment']['received'] as $received) { |
|
| 187 | + $total_received += (float)isset($received['received_amount']) ? $received['received_amount'] : 0; |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( empty($credit_meta) && (float) 0 !== $total_received ) { |
|
| 192 | - if( $order_postmeta['order_status'] == 'refunded') { |
|
| 193 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' .$order->ID. '&invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok' ). '" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>'; |
|
| 191 | + if (empty($credit_meta) && (float)0 !== $total_received) { |
|
| 192 | + if ($order_postmeta['order_status'] == 'refunded') { |
|
| 193 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' . __('Credit Slip number', 'wpshop') . ' : <strong>' . ((!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref'])) ? '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '&credit_slip=ok') . '" target="_blank">' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '</a>' : '') . '</strong></div>'; |
|
| 194 | 194 | } |
| 195 | 195 | else { |
| 196 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
|
| 196 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' . $order->ID . '">' . __('Refund this order', 'wpshop') . '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = strrev( preg_replace( strrev( '/wps-product-section/' ), '', strrev( $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] ), 1 ) ); |
|
| 201 | - echo wpshop_display::display_template_element( 'wpshop_admin_order_action_box', $tpl_component, array( 'type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'id' => $order->ID ), 'admin' ); |
|
| 200 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = strrev(preg_replace(strrev('/wps-product-section/'), '', strrev($tpl_component['ADMIN_ORDER_ACTIONS_LIST']), 1)); |
|
| 201 | + echo wpshop_display::display_template_element('wpshop_admin_order_action_box', $tpl_component, array('type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'id' => $order->ID), 'admin'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | function order_container_in_admin() { |
| 207 | 207 | global $post; |
| 208 | 208 | $output = '<div id="wps_order_content_container">'; |
| 209 | - $output .= self::order_content( $post ); |
|
| 209 | + $output .= self::order_content($post); |
|
| 210 | 210 | $output .= '</div>'; |
| 211 | 211 | echo $output; |
| 212 | 212 | } |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @param order $post The complete order content |
| 219 | 219 | */ |
| 220 | - function order_content( $post ) { |
|
| 220 | + function order_content($post) { |
|
| 221 | 221 | $order_content = ''; |
| 222 | 222 | |
| 223 | 223 | $order = get_post_meta($post->ID, '_order_postmeta', true); |
| 224 | 224 | |
| 225 | 225 | $order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >'; |
| 226 | - if($order){/* Read the order content if the order has product */ |
|
| 226 | + if ($order) {/* Read the order content if the order has product */ |
|
| 227 | 227 | $order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin'); |
| 228 | 228 | if (empty($order['order_invoice_ref'])) { |
| 229 | 229 | $order_content .= '<div id="order_refresh_button_container" class="wpshop_clear_block" ><input type="button" class="button-primary alignright wpshopHide" id="wpshop_admin_order_recalculate" value="' . __('Refresh order informations', 'wpshop') . '" /></div>'; |
@@ -241,18 +241,18 @@ discard block |
||
| 241 | 241 | /** Generate the billing reference regarding the order $order_id |
| 242 | 242 | * @return void |
| 243 | 243 | */ |
| 244 | - function order_generate_billing_number($order_id, $force_invoicing = false){ |
|
| 244 | + function order_generate_billing_number($order_id, $force_invoicing = false) { |
|
| 245 | 245 | global $wpdb, $wpshop_modules_billing; |
| 246 | 246 | |
| 247 | 247 | // Get the order from the db |
| 248 | 248 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 249 | 249 | |
| 250 | 250 | // If the payment is completed |
| 251 | - if(($order['order_status']=='completed') || $force_invoicing) { |
|
| 251 | + if (($order['order_status'] == 'completed') || $force_invoicing) { |
|
| 252 | 252 | |
| 253 | 253 | // If the reference hasn't been generated yet |
| 254 | - if(empty($order['order_invoice_ref'])) { |
|
| 255 | - $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id ); |
|
| 254 | + if (empty($order['order_invoice_ref'])) { |
|
| 255 | + $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id); |
|
| 256 | 256 | |
| 257 | 257 | update_post_meta($order_id, '_order_postmeta', $order); |
| 258 | 258 | } |
@@ -263,45 +263,45 @@ discard block |
||
| 263 | 263 | /** Renvoi une nouvelle r�f�rence unique pour une commande |
| 264 | 264 | * @return int |
| 265 | 265 | */ |
| 266 | - public static function get_new_order_reference(){ |
|
| 266 | + public static function get_new_order_reference() { |
|
| 267 | 267 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 268 | 268 | /* If the number doesn't exist, we create a default one */ |
| 269 | - if(!$number_figures){ |
|
| 269 | + if (!$number_figures) { |
|
| 270 | 270 | $number_figures = 5; |
| 271 | 271 | update_option('wpshop_order_number_figures', $number_figures); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 275 | 275 | /* If the counter doesn't exist, we initiate it */ |
| 276 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 276 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 277 | 277 | else { $order_current_number++; } |
| 278 | 278 | update_option('wpshop_order_current_number', $order_current_number); |
| 279 | 279 | |
| 280 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 281 | - return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref; |
|
| 280 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 281 | + return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** Renvoi une nouvelle r�f�rence unique pour un devis |
| 285 | 285 | * @return int |
| 286 | 286 | */ |
| 287 | - public static function get_new_pre_order_reference($save = true){ |
|
| 287 | + public static function get_new_pre_order_reference($save = true) { |
|
| 288 | 288 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 289 | 289 | /* If the number doesn't exist, we create a default one */ |
| 290 | - if(!$number_figures){ |
|
| 290 | + if (!$number_figures) { |
|
| 291 | 291 | $number_figures = 5; |
| 292 | 292 | update_option('wpshop_order_number_figures', $number_figures); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 296 | 296 | /* If the counter doesn't exist, we initiate it */ |
| 297 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 297 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 298 | 298 | else { $order_current_number++; } |
| 299 | - if($save){ |
|
| 299 | + if ($save) { |
|
| 300 | 300 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 304 | - return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref; |
|
| 303 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 304 | + return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | |
@@ -316,24 +316,24 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return void |
| 318 | 318 | */ |
| 319 | - public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){ |
|
| 319 | + public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') { |
|
| 320 | 320 | /** Get order informations */ |
| 321 | 321 | $billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 322 | - $billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 323 | - $billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : ''; |
|
| 324 | - if ( !empty($_SESSION['shipping_partner_id']) ) { |
|
| 325 | - $partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 322 | + $billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 323 | + $billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : ''; |
|
| 324 | + if (!empty($_SESSION['shipping_partner_id'])) { |
|
| 325 | + $partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 326 | 326 | if (!empty($partner_address_id)) { |
| 327 | - foreach( $partner_address_id as $address_id ) { |
|
| 327 | + foreach ($partner_address_id as $address_id) { |
|
| 328 | 328 | $shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 329 | - $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 329 | + $shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | else { |
| 334 | 334 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 335 | - $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 336 | - $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
|
| 335 | + $shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 336 | + $shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : ''; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | $order_info = array('billing' => $billing_info, 'shipping' => $shipping_info); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | /** Set the custom colums |
| 347 | 347 | * @return array |
| 348 | 348 | */ |
| 349 | - static function orders_edit_columns($columns){ |
|
| 349 | + static function orders_edit_columns($columns) { |
|
| 350 | 350 | $columns = array( |
| 351 | 351 | 'cb' => '<input type="checkbox" />', |
| 352 | 352 | 'order_identifier' => __('Identifiers', 'wpshop'), |
@@ -366,40 +366,40 @@ discard block |
||
| 366 | 366 | * @return array |
| 367 | 367 | */ |
| 368 | 368 | public static function orders_custom_columns($column, $post_id) { |
| 369 | - if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
|
| 369 | + if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
| 370 | 370 | global $civility, $order_status; |
| 371 | 371 | |
| 372 | 372 | $metadata = get_post_custom(); |
| 373 | 373 | |
| 374 | - $order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):''; |
|
| 375 | - $addresses = get_post_meta($post_id,'_order_info', true); |
|
| 374 | + $order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : ''; |
|
| 375 | + $addresses = get_post_meta($post_id, '_order_info', true); |
|
| 376 | 376 | |
| 377 | - switch($column){ |
|
| 377 | + switch ($column) { |
|
| 378 | 378 | case "order_identifier": |
| 379 | - if( !empty( $order_postmeta['order_key'] ) ) { |
|
| 379 | + if (!empty($order_postmeta['order_key'])) { |
|
| 380 | 380 | echo '<b>' . $order_postmeta['order_key'] . '</b><br>'; |
| 381 | 381 | } |
| 382 | - if( !empty( $order_postmeta['order_invoice_ref'] ) ) { |
|
| 382 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 383 | 383 | echo '<i>' . $order_postmeta['order_invoice_ref'] . '</i>'; |
| 384 | - } elseif( !empty($order_postmeta['order_temporary_key'] ) ) { |
|
| 384 | + } elseif (!empty($order_postmeta['order_temporary_key'])) { |
|
| 385 | 385 | echo '<b>' . $order_postmeta['order_temporary_key'] . '</b>'; |
| 386 | 386 | } |
| 387 | 387 | break; |
| 388 | 388 | |
| 389 | 389 | case "order_status": |
| 390 | - echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_'.$post_id.'">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop'); |
|
| 390 | + echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_' . $post_id . '">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop'); |
|
| 391 | 391 | break; |
| 392 | 392 | |
| 393 | 393 | case "order_billing": |
| 394 | - if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
|
| 394 | + if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) { |
|
| 395 | 395 | $billing = $addresses['billing']['address']; |
| 396 | 396 | } |
| 397 | - else if ( !empty($addresses['billing']) ) { |
|
| 397 | + else if (!empty($addresses['billing'])) { |
|
| 398 | 398 | $billing = $addresses['billing']; |
| 399 | 399 | } |
| 400 | - if ( !empty($billing) ) { |
|
| 401 | - echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null).' <strong>'.(!empty($billing['address_first_name']) ? $billing['address_first_name'] : null).' '.(!empty($billing['address_last_name']) ? $billing['address_last_name'] : null).'</strong>'; |
|
| 402 | - echo empty($billing['company']) ?'<br />' : ', <i>'.$billing['company'].'</i><br />'; |
|
| 400 | + if (!empty($billing)) { |
|
| 401 | + echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null) . ' <strong>' . (!empty($billing['address_first_name']) ? $billing['address_first_name'] : null) . ' ' . (!empty($billing['address_last_name']) ? $billing['address_last_name'] : null) . '</strong>'; |
|
| 402 | + echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />'; |
|
| 403 | 403 | echo !empty($billing['address']) ? $billing['address'] : null; |
| 404 | 404 | echo !empty($billing['postcode']) ? '<br />' . $billing['postcode'] . ' ' : null; |
| 405 | 405 | echo !empty($billing['city']) ? $billing['city'] . ', ' : null; |
@@ -412,35 +412,35 @@ discard block |
||
| 412 | 412 | break; |
| 413 | 413 | |
| 414 | 414 | case "order_shipping": |
| 415 | - if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
|
| 415 | + if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) { |
|
| 416 | 416 | $shipping = $addresses['shipping']['address']; |
| 417 | 417 | } |
| 418 | - else if ( !empty($addresses['shipping']) ) { |
|
| 418 | + else if (!empty($addresses['shipping'])) { |
|
| 419 | 419 | $shipping = $addresses['shipping']; |
| 420 | 420 | } |
| 421 | - if ( !empty($shipping) ) { |
|
| 422 | - echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>'; |
|
| 423 | - echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
|
| 421 | + if (!empty($shipping)) { |
|
| 422 | + echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>'; |
|
| 423 | + echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />'; |
|
| 424 | 424 | echo (!empty($shipping['address']) ? $shipping['address'] : null); |
| 425 | 425 | echo !empty($billing['postcode']) ? '<br />' . $billing['postcode'] . ' ' : null; |
| 426 | 426 | echo !empty($billing['city']) ? $billing['city'] . ', ' : null; |
| 427 | 427 | echo !empty($billing['country']) ? $billing['country'] : null; |
| 428 | 428 | } |
| 429 | - else{ |
|
| 429 | + else { |
|
| 430 | 430 | echo __('No information available for user shipping', 'wpshop'); |
| 431 | 431 | } |
| 432 | 432 | break; |
| 433 | 433 | |
| 434 | 434 | case "order_type": |
| 435 | - echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.(!empty($order_postmeta['order_temporary_key']) ? __('Quotation','wpshop') : __('Basic order','wpshop')).'</a>'; |
|
| 435 | + echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>'; |
|
| 436 | 436 | $buttons = '<p class="row-actions">'; |
| 437 | 437 | // Voir la commande |
| 438 | - $buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>'; |
|
| 438 | + $buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>'; |
|
| 439 | 439 | // Marquer comme envoy� |
| 440 | 440 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 441 | - $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader" data-nonce="' . wp_create_nonce("wpshop_dialog_inform_shipping_number") . '">'.__('Mark as shipped', 'wpshop').'</a> '; |
|
| 441 | + $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader" data-nonce="' . wp_create_nonce("wpshop_dialog_inform_shipping_number") . '">' . __('Mark as shipped', 'wpshop') . '</a> '; |
|
| 442 | 442 | } |
| 443 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 443 | + else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) { |
|
| 444 | 444 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 445 | 445 | } |
| 446 | 446 | $buttons .= '</p>'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | |
| 454 | 454 | case "order_total": |
| 455 | 455 | $currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency'); |
| 456 | - echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '. wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 456 | + echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 457 | 457 | break; |
| 458 | 458 | |
| 459 | 459 | /*case "order_actions": |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | public static function list_table_filters() { |
| 484 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 485 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 486 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 487 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 484 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 485 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 486 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 487 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 488 | 488 | |
| 489 | 489 | if (isset($post_type)) { |
| 490 | 490 | if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
@@ -496,23 +496,23 @@ discard block |
||
| 496 | 496 | echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index'); |
| 497 | 497 | $min = $entity_filter_btpf; |
| 498 | 498 | $max = $entity_filter_btps; |
| 499 | - echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> '; |
|
| 500 | - echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null); |
|
| 501 | - echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null); |
|
| 499 | + echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> '; |
|
| 500 | + echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null); |
|
| 501 | + echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null); |
|
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | public static function list_table_filter_parse_query($query) { |
| 507 | 507 | global $pagenow, $wpdb; |
| 508 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 509 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 510 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 511 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 508 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 509 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 510 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 511 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 512 | 512 | |
| 513 | - if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) { |
|
| 513 | + if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) { |
|
| 514 | 514 | $check = null; |
| 515 | - switch ( $entity_filter ) { |
|
| 515 | + switch ($entity_filter) { |
|
| 516 | 516 | case 'all': |
| 517 | 517 | $sql_query = $wpdb->prepare( |
| 518 | 518 | "SELECT ID |
@@ -576,27 +576,27 @@ discard block |
||
| 576 | 576 | break; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - if ( !empty( $check ) ) { |
|
| 580 | - if( !empty($no_btp) && $no_btp == 'yes' ) { |
|
| 579 | + if (!empty($check)) { |
|
| 580 | + if (!empty($no_btp) && $no_btp == 'yes') { |
|
| 581 | 581 | $min = 'minimum'; |
| 582 | 582 | $max = 'maximum'; |
| 583 | 583 | } else { |
| 584 | - $min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum'; |
|
| 585 | - $max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum'; |
|
| 584 | + $min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum'; |
|
| 585 | + $max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum'; |
|
| 586 | 586 | } |
| 587 | 587 | $results = $wpdb->get_results($sql_query); |
| 588 | 588 | $post_id_list = array(); |
| 589 | 589 | $i = 0; |
| 590 | - foreach($results as $item){ |
|
| 590 | + foreach ($results as $item) { |
|
| 591 | 591 | $meta_value = get_post_meta($item->ID, '_order_postmeta'); |
| 592 | - $price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 593 | - if( $price >= $min || $min == 'minimum' ) { |
|
| 594 | - if( $price <= $max || $max == 'maximum' ) { |
|
| 592 | + $price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 593 | + if ($price >= $min || $min == 'minimum') { |
|
| 594 | + if ($price <= $max || $max == 'maximum') { |
|
| 595 | 595 | $post_id_list[] = $item->ID; |
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | - if( empty($post_id_list) ) { |
|
| 599 | + if (empty($post_id_list)) { |
|
| 600 | 600 | $post_id_list[] = 'no_result'; |
| 601 | 601 | } |
| 602 | 602 | $query->query_vars[$check] = $post_id_list; |
@@ -607,67 +607,67 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | |
| 609 | 609 | |
| 610 | - function latest_products_ordered ( $orders ) { |
|
| 610 | + function latest_products_ordered($orders) { |
|
| 611 | 611 | global $wpdb; |
| 612 | 612 | $product_id = $output = ''; |
| 613 | 613 | $products = array(); |
| 614 | 614 | $display_option = get_option('wpshop_display_option'); |
| 615 | - if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) { |
|
| 616 | - foreach( $orders as $order ) { |
|
| 617 | - $order_content = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
| 618 | - if ( !empty($order_content) && !empty( $order_content['order_items']) ) { |
|
| 615 | + if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) { |
|
| 616 | + foreach ($orders as $order) { |
|
| 617 | + $order_content = get_post_meta($order->ID, '_order_postmeta', true); |
|
| 618 | + if (!empty($order_content) && !empty($order_content['order_items'])) { |
|
| 619 | 619 | |
| 620 | - foreach( $order_content['order_items'] as $item ) { |
|
| 621 | - if ( count( $products) >= $display_option['latest_products_ordered'] ) { |
|
| 620 | + foreach ($order_content['order_items'] as $item) { |
|
| 621 | + if (count($products) >= $display_option['latest_products_ordered']) { |
|
| 622 | 622 | continue; |
| 623 | 623 | } |
| 624 | 624 | $product_id = $item['item_id']; |
| 625 | - if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) { |
|
| 626 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 627 | - if ( !empty( $parent_def ) ) { |
|
| 625 | + if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) { |
|
| 626 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 627 | + if (!empty($parent_def)) { |
|
| 628 | 628 | $parent_post = $parent_def['parent_post']; |
| 629 | 629 | $product_id = $parent_post->ID; |
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( !in_array($product_id, $products) ) { |
|
| 633 | + if (!in_array($product_id, $products)) { |
|
| 634 | 634 | $products[] = $product_id; |
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | - if ( !empty($products) ) { |
|
| 639 | + if (!empty($products)) { |
|
| 640 | 640 | $products_id = implode(",", $products); |
| 641 | - $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) ); |
|
| 641 | + $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]'))); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | return $output; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - function get_order_list_for_customer( $customer_id ) { |
|
| 647 | + function get_order_list_for_customer($customer_id) { |
|
| 648 | 648 | global $wpdb; |
| 649 | 649 | $output = ''; |
| 650 | 650 | |
| 651 | - if( !empty($customer_id) ) { |
|
| 652 | - $query = $wpdb->prepare( 'SELECT * |
|
| 653 | - FROM ' .$wpdb->posts. ' |
|
| 651 | + if (!empty($customer_id)) { |
|
| 652 | + $query = $wpdb->prepare('SELECT * |
|
| 653 | + FROM ' .$wpdb->posts . ' |
|
| 654 | 654 | WHERE post_author = %d |
| 655 | - AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 656 | - $orders = $wpdb->get_results( $query ); |
|
| 655 | + AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 656 | + $orders = $wpdb->get_results($query); |
|
| 657 | 657 | |
| 658 | - foreach( $orders as $order ) { |
|
| 658 | + foreach ($orders as $order) { |
|
| 659 | 659 | |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | return $output; |
| 664 | 664 | } |
| 665 | - static function display_customer_pay_quotation( $state, $oid ) { |
|
| 666 | - $label = ( ( $state ) ? __('Invalid quotation', 'wpshop') : __('Valid quotation', 'wpshop') ); |
|
| 667 | - $btn = '<p><a role="button" data-nonce="' . wp_create_nonce( 'wps_quotation_is_payable_by_customer' ) . '" class="wps-bton-' . ( ( $state ) ? 'third' : 'second' ) . '-mini-rounded quotation_is_payable_by_customer" href="#" >'.$label.'</a></p>'; |
|
| 668 | - if( $state ) { |
|
| 665 | + static function display_customer_pay_quotation($state, $oid) { |
|
| 666 | + $label = (($state) ? __('Invalid quotation', 'wpshop') : __('Valid quotation', 'wpshop')); |
|
| 667 | + $btn = '<p><a role="button" data-nonce="' . wp_create_nonce('wps_quotation_is_payable_by_customer') . '" class="wps-bton-' . (($state) ? 'third' : 'second') . '-mini-rounded quotation_is_payable_by_customer" href="#" >' . $label . '</a></p>'; |
|
| 668 | + if ($state) { |
|
| 669 | 669 | //$btn .= '<a target="_blank" href="' . admin_url( 'admin-ajax.php?action=wps_checkout_quotation&order_id=' . $oid . '&is_link=link' ) . '">' . __( 'Pay link', 'wpshop' ) . '</a>'; |
| 670 | - $btn .= '<span><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url( $oid ) . '"/><a class="button" data-copy-target="#wps_direct_link_url" title="' . __( 'Copy', 'wpshop' ) . '"><span class="dashicons dashicons-clipboard"></span></a><a data-nonce="' . wp_create_nonce( 'wps_send_direct_payment_link' ) . '" role="button" class="button" href="#" title="' . __( 'Send by mail', 'wpshop' ) . '"><span class="dashicons dashicons-email"></span></a></span><span>' . sprintf( __( 'Link is valid until %s', 'wpshop' ), mysql2date( get_option( 'date_format' ), date_format( date_create( date('Y-m') . ' + 2month - 1day' ), 'Y-m-d H:i:s' ), true ) ) . '</span>'; |
|
| 670 | + $btn .= '<span><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url($oid) . '"/><a class="button" data-copy-target="#wps_direct_link_url" title="' . __('Copy', 'wpshop') . '"><span class="dashicons dashicons-clipboard"></span></a><a data-nonce="' . wp_create_nonce('wps_send_direct_payment_link') . '" role="button" class="button" href="#" title="' . __('Send by mail', 'wpshop') . '"><span class="dashicons dashicons-email"></span></a></span><span>' . sprintf(__('Link is valid until %s', 'wpshop'), mysql2date(get_option('date_format'), date_format(date_create(date('Y-m') . ' + 2month - 1day'), 'Y-m-d H:i:s'), true)) . '</span>'; |
|
| 671 | 671 | } |
| 672 | 672 | return $btn; |
| 673 | 673 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Products management method file |
| 4 | 6 | * |
@@ -122,8 +124,7 @@ discard block |
||
| 122 | 124 | $order_main_info .= '<div class="wps-product-section">'; |
| 123 | 125 | if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
| 124 | 126 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
| 125 | - } |
|
| 126 | - else{ |
|
| 127 | + } else{ |
|
| 127 | 128 | if(!empty($order_postmeta['order_key'])){ |
| 128 | 129 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
| 129 | 130 | } |
@@ -136,8 +137,7 @@ discard block |
||
| 136 | 137 | $sub_tpl_component = array(); |
| 137 | 138 | $order_invoice_download = '<a href="' . admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_invoice_ref'] . '&mode=pdf' ) . '">' . __('Download invoice', 'wpshop') . '</a><br />'; |
| 138 | 139 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
| 139 | - } |
|
| 140 | - else { |
|
| 140 | + } else { |
|
| 141 | 141 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | if ( empty($credit_meta) && (float) 0 !== $total_received ) { |
| 192 | 192 | if( $order_postmeta['order_status'] == 'refunded') { |
| 193 | 193 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' .$order->ID. '&invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok' ). '" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>'; |
| 194 | - } |
|
| 195 | - else { |
|
| 194 | + } else { |
|
| 196 | 195 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
| 197 | 196 | } |
| 198 | 197 | } |
@@ -273,8 +272,7 @@ discard block |
||
| 273 | 272 | |
| 274 | 273 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 275 | 274 | /* If the counter doesn't exist, we initiate it */ |
| 276 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 277 | - else { $order_current_number++; } |
|
| 275 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 278 | 276 | update_option('wpshop_order_current_number', $order_current_number); |
| 279 | 277 | |
| 280 | 278 | $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
@@ -294,8 +292,7 @@ discard block |
||
| 294 | 292 | |
| 295 | 293 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 296 | 294 | /* If the counter doesn't exist, we initiate it */ |
| 297 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 298 | - else { $order_current_number++; } |
|
| 295 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 299 | 296 | if($save){ |
| 300 | 297 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 301 | 298 | } |
@@ -329,8 +326,7 @@ discard block |
||
| 329 | 326 | $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 330 | 327 | } |
| 331 | 328 | } |
| 332 | - } |
|
| 333 | - else { |
|
| 329 | + } else { |
|
| 334 | 330 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 335 | 331 | $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 336 | 332 | $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
@@ -393,8 +389,7 @@ discard block |
||
| 393 | 389 | case "order_billing": |
| 394 | 390 | if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
| 395 | 391 | $billing = $addresses['billing']['address']; |
| 396 | - } |
|
| 397 | - else if ( !empty($addresses['billing']) ) { |
|
| 392 | + } else if ( !empty($addresses['billing']) ) { |
|
| 398 | 393 | $billing = $addresses['billing']; |
| 399 | 394 | } |
| 400 | 395 | if ( !empty($billing) ) { |
@@ -405,8 +400,7 @@ discard block |
||
| 405 | 400 | echo !empty($billing['city']) ? $billing['city'] . ', ' : null; |
| 406 | 401 | echo !empty($billing['country']) ? $billing['country'] : null; |
| 407 | 402 | echo (!empty($billing['phone']) ? '<br /><b>' . $billing['phone'] . '</b>' : ''); |
| 408 | - } |
|
| 409 | - else { |
|
| 403 | + } else { |
|
| 410 | 404 | echo __('No information available for user billing', 'wpshop'); |
| 411 | 405 | } |
| 412 | 406 | break; |
@@ -414,8 +408,7 @@ discard block |
||
| 414 | 408 | case "order_shipping": |
| 415 | 409 | if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
| 416 | 410 | $shipping = $addresses['shipping']['address']; |
| 417 | - } |
|
| 418 | - else if ( !empty($addresses['shipping']) ) { |
|
| 411 | + } else if ( !empty($addresses['shipping']) ) { |
|
| 419 | 412 | $shipping = $addresses['shipping']; |
| 420 | 413 | } |
| 421 | 414 | if ( !empty($shipping) ) { |
@@ -425,8 +418,7 @@ discard block |
||
| 425 | 418 | echo !empty($billing['postcode']) ? '<br />' . $billing['postcode'] . ' ' : null; |
| 426 | 419 | echo !empty($billing['city']) ? $billing['city'] . ', ' : null; |
| 427 | 420 | echo !empty($billing['country']) ? $billing['country'] : null; |
| 428 | - } |
|
| 429 | - else{ |
|
| 421 | + } else{ |
|
| 430 | 422 | echo __('No information available for user shipping', 'wpshop'); |
| 431 | 423 | } |
| 432 | 424 | break; |
@@ -439,8 +431,7 @@ discard block |
||
| 439 | 431 | // Marquer comme envoy� |
| 440 | 432 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 441 | 433 | $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader" data-nonce="' . wp_create_nonce("wpshop_dialog_inform_shipping_number") . '">'.__('Mark as shipped', 'wpshop').'</a> '; |
| 442 | - } |
|
| 443 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 434 | + } else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 444 | 435 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 445 | 436 | } |
| 446 | 437 | $buttons .= '</p>'; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Manage Customer administration functions |
| 4 | 4 | * @author ALLEGRE Jérôme - EOXIA |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | // Template loading |
| 9 | 9 | $this->template_dir = WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . "/templates/"; |
| 10 | 10 | // WP General actions |
| 11 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes') ); |
|
| 12 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts') ); |
|
| 11 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
| 12 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts')); |
|
| 13 | 13 | // Ajax Actions |
| 14 | - add_action( 'wp_ajax_wps_order_refresh_customer_informations', array( $this, 'wps_order_refresh_customer_informations') ); |
|
| 15 | - add_action( 'wp_ajax_wps_load_customer_creation_form_in_admin', array( $this, 'wps_load_customer_creation_form_in_admin') ); |
|
| 16 | - add_action( 'wp_ajax_wps_order_refresh_customer_list', array( $this, 'wps_order_refresh_customer_list') ); |
|
| 14 | + add_action('wp_ajax_wps_order_refresh_customer_informations', array($this, 'wps_order_refresh_customer_informations')); |
|
| 15 | + add_action('wp_ajax_wps_load_customer_creation_form_in_admin', array($this, 'wps_load_customer_creation_form_in_admin')); |
|
| 16 | + add_action('wp_ajax_wps_order_refresh_customer_list', array($this, 'wps_order_refresh_customer_list')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | $module_folder = WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/modules/'; |
| 25 | 25 | |
| 26 | 26 | /** Check if the defined directory exists for reading and including the different modules */ |
| 27 | - if( is_dir( $module_folder ) ) { |
|
| 28 | - $parent_folder_content = scandir( $module_folder ); |
|
| 29 | - foreach ( $parent_folder_content as $folder ) { |
|
| 30 | - if ( $folder && substr( $folder, 0, 1) != '.' && is_dir( $module_folder . $folder ) ) { |
|
| 31 | - $child_folder_content = scandir( $module_folder . $folder ); |
|
| 32 | - if ( file_exists( $module_folder . $folder . '/' . $folder . '.php') ) { |
|
| 33 | - $f = $module_folder . $folder . '/' . $folder . '.php'; |
|
| 34 | - include( $f ); |
|
| 27 | + if (is_dir($module_folder)) { |
|
| 28 | + $parent_folder_content = scandir($module_folder); |
|
| 29 | + foreach ($parent_folder_content as $folder) { |
|
| 30 | + if ($folder && substr($folder, 0, 1) != '.' && is_dir($module_folder . $folder)) { |
|
| 31 | + $child_folder_content = scandir($module_folder . $folder); |
|
| 32 | + if (file_exists($module_folder . $folder . '/' . $folder . '.php')) { |
|
| 33 | + $f = $module_folder . $folder . '/' . $folder . '.php'; |
|
| 34 | + include($f); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function add_meta_boxes() { |
| 45 | 45 | /** Box with order customer information */ |
| 46 | - add_meta_box('wpshop_order_customer_information_box', '<span class="dashicons dashicons-businessman"></span> '.__('Customer information', 'wpshop'),array($this, 'display_order_customer_informations_in_administration'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'high'); |
|
| 46 | + add_meta_box('wpshop_order_customer_information_box', '<span class="dashicons dashicons-businessman"></span> ' . __('Customer information', 'wpshop'), array($this, 'display_order_customer_informations_in_administration'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'high'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function add_scripts() { |
| 53 | 53 | global $current_screen; |
| 54 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
| 54 | + if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER), true)) |
|
| 55 | 55 | return; |
| 56 | 56 | |
| 57 | - wp_enqueue_script( 'wps_customer_admin_js', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/js/wps_customer_backend.js', '', WPSHOP_VERSION ); |
|
| 57 | + wp_enqueue_script('wps_customer_admin_js', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/js/wps_customer_backend.js', '', WPSHOP_VERSION); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -67,64 +67,64 @@ discard block |
||
| 67 | 67 | $wps_customer = new wps_customer_ctr(); |
| 68 | 68 | |
| 69 | 69 | // Check if post is an order |
| 70 | - if( !empty($post_id) && get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
|
| 70 | + if (!empty($post_id) && get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
| 71 | 71 | // Order informations |
| 72 | - $order_metadata = get_post_meta( $post_id, '_order_postmeta', true ); |
|
| 73 | - $order_infos = get_post_meta( $post_id, '_order_info', true ); |
|
| 72 | + $order_metadata = get_post_meta($post_id, '_order_postmeta', true); |
|
| 73 | + $order_infos = get_post_meta($post_id, '_order_info', true); |
|
| 74 | 74 | |
| 75 | - if( !empty($order_metadata['customer_id']) ) { |
|
| 76 | - $customer_lists = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' ), ( ( !empty($order_metadata['customer_id']) ) ? $order_metadata['customer_id'] : '' ) ); |
|
| 75 | + if (!empty($order_metadata['customer_id'])) { |
|
| 76 | + $customer_lists = $wps_customer->custom_user_list(array('name'=>'user[customer_id]', 'id' => 'user_customer_id'), ((!empty($order_metadata['customer_id'])) ? $order_metadata['customer_id'] : '')); |
|
| 77 | 77 | // Selected customer informations |
| 78 | 78 | $wps_account = new wps_account_ctr(); |
| 79 | - $customer_id = ( !empty($order_metadata['customer_id']) ) ? $order_metadata['customer_id'] : ''; |
|
| 79 | + $customer_id = (!empty($order_metadata['customer_id'])) ? $order_metadata['customer_id'] : ''; |
|
| 80 | 80 | $customer_datas = $wps_account->display_account_informations($customer_id, false, true); |
| 81 | 81 | |
| 82 | 82 | // Selected customer address informations |
| 83 | 83 | // Billing datas |
| 84 | - $billing_address_option = get_option( 'wpshop_billing_address' ); |
|
| 85 | - $billing_address_option = ( !empty($billing_address_option) && !empty($billing_address_option['choice']) ) ? $billing_address_option['choice'] : ''; |
|
| 84 | + $billing_address_option = get_option('wpshop_billing_address'); |
|
| 85 | + $billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : ''; |
|
| 86 | 86 | |
| 87 | 87 | // Shipping datas |
| 88 | 88 | $shipping_address_content = ''; |
| 89 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 89 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
| 90 | 90 | |
| 91 | - if( ( !empty($order_metadata) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) || empty($order_metadata) || empty($order_metadata['order_status']) ) { |
|
| 91 | + if ((!empty($order_metadata) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') || empty($order_metadata) || empty($order_metadata['order_status'])) { |
|
| 92 | 92 | $wps_address = new wps_address(); |
| 93 | - $addresses = $wps_address->display_addresses_interface( $customer_id, true ); |
|
| 93 | + $addresses = $wps_address->display_addresses_interface($customer_id, true); |
|
| 94 | 94 | } |
| 95 | 95 | else { |
| 96 | 96 | $wps_address_admin = new wps_address_admin(); |
| 97 | - $addresses = $wps_address_admin->display_customer_address_in_order( $customer_id, $post_id, $billing_address_option ); |
|
| 98 | - if( !empty($shipping_address_option['activate']) ) { |
|
| 99 | - $addresses .= $wps_address_admin->display_customer_address_in_order( $customer_id, $post_id, $shipping_address_option['choice'] ); |
|
| 97 | + $addresses = $wps_address_admin->display_customer_address_in_order($customer_id, $post_id, $billing_address_option); |
|
| 98 | + if (!empty($shipping_address_option['activate'])) { |
|
| 99 | + $addresses .= $wps_address_admin->display_customer_address_in_order($customer_id, $post_id, $shipping_address_option['choice']); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | else { |
| 104 | - $customer_lists = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' )); |
|
| 104 | + $customer_lists = $wps_customer->custom_user_list(array('name'=>'user[customer_id]', 'id' => 'user_customer_id')); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | else { |
| 108 | 108 | // Create order & set customer id if is in request |
| 109 | - $customer_id = !empty($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : ''; |
|
| 110 | - $customer_lists = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' ), $customer_id ); |
|
| 111 | - if( !empty( $customer_id ) ) { |
|
| 109 | + $customer_id = !empty($_REQUEST['customer_id']) ? (int)$_REQUEST['customer_id'] : ''; |
|
| 110 | + $customer_lists = $wps_customer->custom_user_list(array('name'=>'user[customer_id]', 'id' => 'user_customer_id'), $customer_id); |
|
| 111 | + if (!empty($customer_id)) { |
|
| 112 | 112 | $wps_account = new wps_account_ctr(); |
| 113 | 113 | $customer_datas = $wps_account->display_account_informations($customer_id, false, true); |
| 114 | 114 | $wps_address = new wps_address(); |
| 115 | - $addresses = $wps_address->display_addresses_interface( $customer_id, true ); |
|
| 115 | + $addresses = $wps_address->display_addresses_interface($customer_id, true); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, $this->template_dir, "backend", "customer-informations/wps_order_customer_informations") ); |
|
| 118 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, $this->template_dir, "backend", "customer-informations/wps_order_customer_informations")); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * AJAX - Customer creation form |
| 123 | 123 | */ |
| 124 | 124 | function wps_load_customer_creation_form_in_admin() { |
| 125 | - check_ajax_referer( 'wps_load_customer_creation_form_in_admin' ); |
|
| 125 | + check_ajax_referer('wps_load_customer_creation_form_in_admin'); |
|
| 126 | 126 | |
| 127 | - echo do_shortcode( '[wps_signup display="admin"]' ); |
|
| 127 | + echo do_shortcode('[wps_signup display="admin"]'); |
|
| 128 | 128 | wp_die(); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,19 +132,19 @@ discard block |
||
| 132 | 132 | * AJAX - Refresh customer informations |
| 133 | 133 | */ |
| 134 | 134 | function wps_order_refresh_customer_informations() { |
| 135 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 135 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 136 | 136 | |
| 137 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_informations' ) ) |
|
| 137 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_refresh_customer_informations')) |
|
| 138 | 138 | wp_die(); |
| 139 | 139 | |
| 140 | 140 | $status = false; $account = $addresses = ''; |
| 141 | - $customer_id = ( !empty($_POST['customer_id']) ) ? intval($_POST['customer_id']) : null; |
|
| 142 | - $order_id = ( !empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null; |
|
| 143 | - if( !empty($customer_id) ) { |
|
| 144 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 145 | - if( !empty($order_metadata) ) { |
|
| 141 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 142 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 143 | + if (!empty($customer_id)) { |
|
| 144 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 145 | + if (!empty($order_metadata)) { |
|
| 146 | 146 | $order_metadata['customer_id'] = $customer_id; |
| 147 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
| 147 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Selected customer informations |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | $account = $wps_account->display_account_informations($customer_id); |
| 153 | 153 | |
| 154 | 154 | $wps_address = new wps_address(); |
| 155 | - $addresses = $wps_address->display_addresses_interface( $customer_id, true, $order_id ); |
|
| 155 | + $addresses = $wps_address->display_addresses_interface($customer_id, true, $order_id); |
|
| 156 | 156 | $status = true; |
| 157 | 157 | } |
| 158 | - echo json_encode( array( 'status' => $status, 'account' => $account, 'addresses' => $addresses ) ); |
|
| 158 | + echo json_encode(array('status' => $status, 'account' => $account, 'addresses' => $addresses)); |
|
| 159 | 159 | wp_die(); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | * AJAX - Reload Customer list |
| 164 | 164 | */ |
| 165 | 165 | function wps_order_refresh_customer_list() { |
| 166 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 166 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 167 | 167 | |
| 168 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_list' ) ) |
|
| 168 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_refresh_customer_list')) |
|
| 169 | 169 | wp_die(); |
| 170 | 170 | |
| 171 | 171 | $status = false; $response = ''; |
| 172 | - $customer_id = ( !empty($_POST['customer_id']) ) ? intval( $_POST['customer_id'] ) : null; |
|
| 173 | - if( !empty($customer_id) ) { |
|
| 172 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 173 | + if (!empty($customer_id)) { |
|
| 174 | 174 | $wps_customer = new wps_customer_ctr(); |
| 175 | - $response = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' ), $customer_id ); |
|
| 175 | + $response = $wps_customer->custom_user_list(array('name'=>'user[customer_id]', 'id' => 'user_customer_id'), $customer_id); |
|
| 176 | 176 | $status = true; |
| 177 | 177 | } |
| 178 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
| 178 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 179 | 179 | wp_die(); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Manage Customer administration functions |
| 4 | 6 | * @author ALLEGRE Jérôme - EOXIA |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | */ |
| 52 | 54 | function add_scripts() { |
| 53 | 55 | global $current_screen; |
| 54 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
| 55 | - return; |
|
| 56 | + if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | wp_enqueue_script( 'wps_customer_admin_js', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/js/wps_customer_backend.js', '', WPSHOP_VERSION ); |
| 58 | 61 | } |
@@ -91,20 +94,17 @@ discard block |
||
| 91 | 94 | if( ( !empty($order_metadata) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) || empty($order_metadata) || empty($order_metadata['order_status']) ) { |
| 92 | 95 | $wps_address = new wps_address(); |
| 93 | 96 | $addresses = $wps_address->display_addresses_interface( $customer_id, true ); |
| 94 | - } |
|
| 95 | - else { |
|
| 97 | + } else { |
|
| 96 | 98 | $wps_address_admin = new wps_address_admin(); |
| 97 | 99 | $addresses = $wps_address_admin->display_customer_address_in_order( $customer_id, $post_id, $billing_address_option ); |
| 98 | 100 | if( !empty($shipping_address_option['activate']) ) { |
| 99 | 101 | $addresses .= $wps_address_admin->display_customer_address_in_order( $customer_id, $post_id, $shipping_address_option['choice'] ); |
| 100 | 102 | } |
| 101 | 103 | } |
| 102 | - } |
|
| 103 | - else { |
|
| 104 | + } else { |
|
| 104 | 105 | $customer_lists = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' )); |
| 105 | 106 | } |
| 106 | - } |
|
| 107 | - else { |
|
| 107 | + } else { |
|
| 108 | 108 | // Create order & set customer id if is in request |
| 109 | 109 | $customer_id = !empty($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : ''; |
| 110 | 110 | $customer_lists = $wps_customer->custom_user_list( array( 'name'=>'user[customer_id]', 'id' => 'user_customer_id' ), $customer_id ); |
@@ -134,8 +134,9 @@ discard block |
||
| 134 | 134 | function wps_order_refresh_customer_informations() { |
| 135 | 135 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 136 | 136 | |
| 137 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_informations' ) ) |
|
| 138 | - wp_die(); |
|
| 137 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_informations' ) ) { |
|
| 138 | + wp_die(); |
|
| 139 | + } |
|
| 139 | 140 | |
| 140 | 141 | $status = false; $account = $addresses = ''; |
| 141 | 142 | $customer_id = ( !empty($_POST['customer_id']) ) ? intval($_POST['customer_id']) : null; |
@@ -165,8 +166,9 @@ discard block |
||
| 165 | 166 | function wps_order_refresh_customer_list() { |
| 166 | 167 | $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
| 167 | 168 | |
| 168 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_list' ) ) |
|
| 169 | - wp_die(); |
|
| 169 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_order_refresh_customer_list' ) ) { |
|
| 170 | + wp_die(); |
|
| 171 | + } |
|
| 170 | 172 | |
| 171 | 173 | $status = false; $response = ''; |
| 172 | 174 | $customer_id = ( !empty($_POST['customer_id']) ) ? intval( $_POST['customer_id'] ) : null; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Fichier du controleur des metaboxes pour l'administration des clients dans wpshop / Controller file for managing metaboxes into customer administration interface |
| 4 | 4 | * |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * Instanciation de la gestion des metaboxes / Insctanciate metaboxes management |
| 19 | 19 | */ |
| 20 | 20 | function __construct() { |
| 21 | - add_action( 'add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array( $this, 'add_meta_box' ) ); |
|
| 21 | + add_action('add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array($this, 'add_meta_box')); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param WP_Post $customer Le client actuel / The current customer |
| 29 | 29 | */ |
| 30 | - function add_meta_box( $customer ) { |
|
| 31 | - remove_meta_box( 'submitdiv', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal' ); |
|
| 32 | - add_meta_box( 'submitdiv', __( 'Save' ), array( $this, 'wps_customer_informations_save' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'high' ); |
|
| 33 | - add_meta_box( 'wps_customer_informations', __( 'Customer\'s account informations', 'wpshop' ), array( $this, 'wps_customer_account_informations' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high' ); |
|
| 34 | - if ( 'auto-draft' !== $customer->post_status ) { |
|
| 35 | - add_meta_box( 'wps_customer_orders', __( 'Customer\'s orders', 'wpshop' ), array( $this, 'wps_customer_orders_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' ); |
|
| 36 | - add_meta_box( 'wps_customer_messages_list', __( 'Customer\'s send messages', 'wpshop' ), array( $this, 'wps_customer_messages_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
| 37 | - add_meta_box( 'wps_customer_coupons_list', __( 'Customer\'s coupons list', 'wpshop' ), array( $this, 'wps_customer_coupons_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
| 38 | - add_meta_box( 'wps_customer_addresses_list', __( 'Customer\'s addresses', 'wpshop' ), array( $this, 'wps_customer_addresses_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' ); |
|
| 30 | + function add_meta_box($customer) { |
|
| 31 | + remove_meta_box('submitdiv', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal'); |
|
| 32 | + add_meta_box('submitdiv', __('Save'), array($this, 'wps_customer_informations_save'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'high'); |
|
| 33 | + add_meta_box('wps_customer_informations', __('Customer\'s account informations', 'wpshop'), array($this, 'wps_customer_account_informations'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high'); |
|
| 34 | + if ('auto-draft' !== $customer->post_status) { |
|
| 35 | + add_meta_box('wps_customer_orders', __('Customer\'s orders', 'wpshop'), array($this, 'wps_customer_orders_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low'); |
|
| 36 | + add_meta_box('wps_customer_messages_list', __('Customer\'s send messages', 'wpshop'), array($this, 'wps_customer_messages_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
| 37 | + add_meta_box('wps_customer_coupons_list', __('Customer\'s coupons list', 'wpshop'), array($this, 'wps_customer_coupons_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
| 38 | + add_meta_box('wps_customer_addresses_list', __('Customer\'s addresses', 'wpshop'), array($this, 'wps_customer_addresses_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low'); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,50 +43,50 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * META-BOX CONTENT - Display customer's order list in customer back-office interface |
| 45 | 45 | */ |
| 46 | - function wps_customer_orders_list( $post ) { |
|
| 46 | + function wps_customer_orders_list($post) { |
|
| 47 | 47 | $output = ''; |
| 48 | - $output .= '<p><a class="button" href="' . admin_url( 'post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) . '&customer_id=' . $post->post_author . '">' . __('Add quotation', 'wpshop') . '</a></p>'; |
|
| 48 | + $output .= '<p><a class="button" href="' . admin_url('post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER) . '&customer_id=' . $post->post_author . '">' . __('Add quotation', 'wpshop') . '</a></p>'; |
|
| 49 | 49 | $wps_orders = new wps_orders_ctr(); |
| 50 | - $output .= $wps_orders->display_orders_in_account( $post->post_author); |
|
| 50 | + $output .= $wps_orders->display_orders_in_account($post->post_author); |
|
| 51 | 51 | echo $output; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * META-BOX CONTENT - Display Customer's addresses in customer back-office interface |
| 56 | 56 | */ |
| 57 | - function wps_customer_addresses_list( $post ) { |
|
| 57 | + function wps_customer_addresses_list($post) { |
|
| 58 | 58 | global $wpdb; |
| 59 | 59 | |
| 60 | 60 | $wps_addresses = new wps_address(); |
| 61 | - $output = $wps_addresses->display_addresses_interface( $post->post_author, true ); |
|
| 61 | + $output = $wps_addresses->display_addresses_interface($post->post_author, true); |
|
| 62 | 62 | echo '<input type="hidden" name="wps_customer_id" id="wps_orders_selected_customer" value="' . $post->post_author . '">'; |
| 63 | - echo '<div data-nonce="' . wp_create_nonce( 'reload_addresses_for_customer' ) . '" id="wps_customer_addresses" class="wps-gridwrapper2-padded">' . $output . '</div>'; |
|
| 63 | + echo '<div data-nonce="' . wp_create_nonce('reload_addresses_for_customer') . '" id="wps_customer_addresses" class="wps-gridwrapper2-padded">' . $output . '</div>'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * META-BOX CONTENT - Display customer's send messages |
| 68 | 68 | */ |
| 69 | - function wps_customer_messages_list( $post ) { |
|
| 69 | + function wps_customer_messages_list($post) { |
|
| 70 | 70 | $wps_messages = new wps_message_ctr(); |
| 71 | - $output = $wps_messages->display_message_histo_per_customer( array(),$post->post_author); |
|
| 71 | + $output = $wps_messages->display_message_histo_per_customer(array(), $post->post_author); |
|
| 72 | 72 | echo $output; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * META-BOX CONTENT - Display wps_customer's coupons list |
| 77 | 77 | */ |
| 78 | - function wps_customer_coupons_list( $post ) { |
|
| 78 | + function wps_customer_coupons_list($post) { |
|
| 79 | 79 | $wps_customer = new wps_coupon_ctr(); |
| 80 | - $output = $wps_customer->display_coupons( $post->post_author ); |
|
| 80 | + $output = $wps_customer->display_coupons($post->post_author); |
|
| 81 | 81 | echo $output; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * META-BOX CONTENT - Display Customer's account informations in administration panel |
| 86 | 86 | */ |
| 87 | - function wps_customer_account_informations( $post ) { |
|
| 87 | + function wps_customer_account_informations($post) { |
|
| 88 | 88 | $wps_account = new wps_account_ctr(); |
| 89 | - $output = $wps_account->display_account_informations( $post->post_author ); |
|
| 89 | + $output = $wps_account->display_account_informations($post->post_author); |
|
| 90 | 90 | echo $output; |
| 91 | 91 | } |
| 92 | 92 | |