@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | /** Constructor of the class |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - function __construct () { |
|
| 28 | + function __construct() { |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - public static function process_checkout($paymentMethod='paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) { |
|
| 32 | + public static function process_checkout($paymentMethod = 'paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) { |
|
| 33 | 33 | |
| 34 | 34 | global $wpdb, $wpshop, $wpshop_cart; |
| 35 | 35 | $wps_message = new wps_message_ctr(); |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | if (is_user_logged_in()) : |
| 39 | 39 | $user_id = get_current_user_id(); |
| 40 | 40 | |
| 41 | - if ( $customer_id != 0 ) { |
|
| 41 | + if ($customer_id != 0) { |
|
| 42 | 42 | $user_id = $customer_id; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // If the order is already created in the db |
| 46 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 46 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 47 | 47 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 48 | 48 | |
| 49 | - if(!empty($order)) { |
|
| 50 | - if($order['customer_id'] == $user_id) { |
|
| 49 | + if (!empty($order)) { |
|
| 50 | + if ($order['customer_id'] == $user_id) { |
|
| 51 | 51 | $order['payment_method'] = $paymentMethod; |
| 52 | - $_SESSION['order_id'] = (int) $order_id; |
|
| 52 | + $_SESSION['order_id'] = (int)$order_id; |
|
| 53 | 53 | // Store cart in session |
| 54 | 54 | //wpshop_cart::store_cart_in_session($order); |
| 55 | 55 | // Add a payment |
| 56 | - $order['order_payment']['received'][] = array( 'method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id() ); |
|
| 56 | + $order['order_payment']['received'][] = array('method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id()); |
|
| 57 | 57 | |
| 58 | 58 | // On enregistre la commande |
| 59 | 59 | update_post_meta($order_id, '_order_postmeta', $order); |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
| 65 | 65 | } |
| 66 | - else{ |
|
| 66 | + else { |
|
| 67 | 67 | $order_data = array( |
| 68 | 68 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
| 69 | - 'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
|
| 69 | + 'post_title' => sprintf(__('Order - %s', 'wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
|
| 70 | 70 | 'post_status' => 'publish', |
| 71 | - 'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field( $_POST['wps-customer-comment'] ) : '', |
|
| 71 | + 'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field($_POST['wps-customer-comment']) : '', |
|
| 72 | 72 | 'post_author' => $user_id, |
| 73 | 73 | 'comment_status' => 'closed' |
| 74 | 74 | ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $order_tva = array(); |
| 79 | 79 | |
| 80 | 80 | //$cart = (array)$wpshop_cart->cart; |
| 81 | - if ( !empty($_SESSION['cart']) && !empty( $_SESSION['cart']['shipping_method']) ) { |
|
| 81 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['shipping_method'])) { |
|
| 82 | 82 | $_SESSION['cart']['shipping_method'] = __('Standard shipping method', 'wpshop'); |
| 83 | 83 | } |
| 84 | 84 | $cart = (array)$_SESSION['cart']; |
@@ -90,35 +90,35 @@ discard block |
||
| 90 | 90 | $_SESSION['order_id'] = $order_id; |
| 91 | 91 | |
| 92 | 92 | // Cr�ation des codes de t�l�chargement si il y a des produits t�l�chargeable dans le panier |
| 93 | - if ( !empty( $cart['order_items'] ) ) { |
|
| 94 | - foreach($cart['order_items'] as $c) { |
|
| 93 | + if (!empty($cart['order_items'])) { |
|
| 94 | + foreach ($cart['order_items'] as $c) { |
|
| 95 | 95 | $product_id = $c['item_id']; |
| 96 | 96 | $product = null; |
| 97 | - if( isset( $c['item_meta']['variations'] ) ) { |
|
| 98 | - foreach ( $c['item_meta']['variations'] as $variation_id => $variation ) { |
|
| 99 | - if( isset( $variation['item_meta']['is_downloadable_'] ) ) { |
|
| 97 | + if (isset($c['item_meta']['variations'])) { |
|
| 98 | + foreach ($c['item_meta']['variations'] as $variation_id => $variation) { |
|
| 99 | + if (isset($variation['item_meta']['is_downloadable_'])) { |
|
| 100 | 100 | $product_id = $c['item_id'] . '__' . $variation_id; |
| 101 | - $product = wpshop_products::get_product_data( $product_id ); |
|
| 101 | + $product = wpshop_products::get_product_data($product_id); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - if( !isset( $product ) ) { |
|
| 106 | - $product = wpshop_products::get_product_data( $c['item_id'] ); |
|
| 105 | + if (!isset($product)) { |
|
| 106 | + $product = wpshop_products::get_product_data($c['item_id']); |
|
| 107 | 107 | $product_id = $c['item_id']; |
| 108 | 108 | /** Check if it's a variation and check the parent product **/ |
| 109 | - if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 110 | - $parent_def = wpshop_products::get_parent_variation( $c['item_id'] ); |
|
| 111 | - if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) { |
|
| 109 | + if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 110 | + $parent_def = wpshop_products::get_parent_variation($c['item_id']); |
|
| 111 | + if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) { |
|
| 112 | 112 | $product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_']; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - if(!empty($product['is_downloadable_'])) { |
|
| 116 | + if (!empty($product['is_downloadable_'])) { |
|
| 117 | 117 | $download_codes[$product_id] = array('item_id' => $product_id, 'download_code' => uniqid('', true)); |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | - if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 121 | + if (!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_' . $order_id, $download_codes); |
|
| 122 | 122 | |
| 123 | 123 | // Informations de commande � stocker |
| 124 | 124 | $currency = wpshop_tools::wpshop_get_currency(true); |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | 'order_payment' => array( |
| 134 | 134 | 'customer_choice' => array('method' => $paymentMethod), |
| 135 | 135 | 'received' => array('0' => array('method' => $paymentMethod, 'waited_amount' => $cart['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => $user_id)), |
| 136 | - 'shipping_method' => ( ( !empty( $_SESSION['shipping_method']) ) ? wpshop_tools::varSanitizer( $_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop') ) |
|
| 136 | + 'shipping_method' => ((!empty($_SESSION['shipping_method'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop')) |
|
| 137 | 137 | ), |
| 138 | 138 | ), $cart); |
| 139 | 139 | |
| 140 | 140 | // Si c'est un devis |
| 141 | - if ( $paymentMethod == 'quotation' ) { |
|
| 141 | + if ($paymentMethod == 'quotation') { |
|
| 142 | 142 | $order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference(); |
| 143 | 143 | } |
| 144 | 144 | else { |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | //Round final amount |
| 149 | - $order['order_grand_total'] = number_format( round($order['order_grand_total'], 2), 2, '.', ''); |
|
| 150 | - $order['order_total_ttc'] = number_format( round($order['order_total_ttc'], 2), 2, '.', ''); |
|
| 151 | - $order['order_amount_to_pay_now'] = number_format( round($order['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 149 | + $order['order_grand_total'] = number_format(round($order['order_grand_total'], 2), 2, '.', ''); |
|
| 150 | + $order['order_total_ttc'] = number_format(round($order['order_total_ttc'], 2), 2, '.', ''); |
|
| 151 | + $order['order_amount_to_pay_now'] = number_format(round($order['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 152 | 152 | |
| 153 | 153 | /** On enregistre la commande */ |
| 154 | 154 | update_post_meta($order_id, '_order_postmeta', $order); |
@@ -157,75 +157,75 @@ discard block |
||
| 157 | 157 | update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); |
| 158 | 158 | |
| 159 | 159 | |
| 160 | - do_action( 'wps_order_extra_save', $order_id ); |
|
| 160 | + do_action('wps_order_extra_save', $order_id); |
|
| 161 | 161 | |
| 162 | 162 | //Add an action to extra actions on order save |
| 163 | 163 | // @TODO : REQUEST |
| 164 | - $args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST ); |
|
| 165 | - wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args ); |
|
| 164 | + $args = array('order_id' => $order_id, 'posted_data' => $_REQUEST); |
|
| 165 | + wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args); |
|
| 166 | 166 | |
| 167 | 167 | /** Set custmer information for the order */ |
| 168 | - $shipping_address = ( !empty($shipping_address_option) && !empty($shipping_address_option['activate']) ) ? ( ( !empty($_SESSION['shipping_address']) ) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id ) : ''; |
|
| 169 | - $billing_address = ( !empty($_SESSION['billing_address']) ) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id; |
|
| 168 | + $shipping_address = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? ((!empty($_SESSION['shipping_address'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id) : ''; |
|
| 169 | + $billing_address = (!empty($_SESSION['billing_address'])) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id; |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | - if ( !empty( $billing_address) ) { |
|
| 172 | + if (!empty($billing_address)) { |
|
| 173 | 173 | wpshop_orders::set_order_customer_addresses($user_id, $order_id, $shipping_address, $billing_address); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( !empty($_SESSION['shipping_address_to_save']) ) { |
|
| 176 | + if (!empty($_SESSION['shipping_address_to_save'])) { |
|
| 177 | 177 | $order_infos_postmeta = get_post_meta($order_id, '_order_info', true); |
| 178 | 178 | $order_infos_postmeta['shipping']['address'] = $_SESSION['shipping_address_to_save']; |
| 179 | 179 | $order_infos_postmeta['shipping']['address_id'] = ''; |
| 180 | 180 | update_post_meta($order_id, '_order_info', $order_infos_postmeta); |
| 181 | - unset( $_SESSION['shipping_address_to_save'] ); |
|
| 181 | + unset($_SESSION['shipping_address_to_save']); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | /** Save Coupon use **/ |
| 186 | - if ( !empty($_SESSION['cart']['coupon_id']) ) { |
|
| 186 | + if (!empty($_SESSION['cart']['coupon_id'])) { |
|
| 187 | 187 | $wps_coupon_mdl = new wps_coupon_model(); |
| 188 | - $wps_coupon_mdl->save_coupon_use( $_SESSION['cart']['coupon_id'] ); |
|
| 188 | + $wps_coupon_mdl->save_coupon_use($_SESSION['cart']['coupon_id']); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** Notify the customer as the case */ |
| 192 | 192 | $user_info = get_userdata($user_id); |
| 193 | 193 | $email = $user_info->user_email; |
| 194 | - $first_name = $user_info->user_firstname ; |
|
| 194 | + $first_name = $user_info->user_firstname; |
|
| 195 | 195 | $last_name = $user_info->user_lastname; |
| 196 | 196 | |
| 197 | 197 | // Envoie du message de confirmation de commande au client |
| 198 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true); |
|
| 198 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 199 | 199 | |
| 200 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 201 | - $shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' ); |
|
| 200 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 201 | + $shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : ''); |
|
| 202 | 202 | |
| 203 | - if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) { |
|
| 204 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') ); |
|
| 203 | + if (!empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key'])) { |
|
| 204 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); |
|
| 205 | 205 | } |
| 206 | 206 | else { |
| 207 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 208 | - if ( empty($email_option['send_confirmation_order_message']) ) { |
|
| 209 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 210 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 207 | + $email_option = get_option('wpshop_emails'); |
|
| 208 | + if (empty($email_option['send_confirmation_order_message'])) { |
|
| 209 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 210 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 211 | 211 | |
| 212 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ) ); |
|
| 212 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 216 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 217 | 217 | $email_option = get_option('wpshop_emails'); |
| 218 | - if( empty($email_option) || ( !empty($email_option) && empty($email_option['send_confirmation_order_message']) ) ){ |
|
| 219 | - self::send_order_email_to_administrator( $order_id, $user_info ); |
|
| 218 | + if (empty($email_option) || (!empty($email_option) && empty($email_option['send_confirmation_order_message']))) { |
|
| 219 | + self::send_order_email_to_administrator($order_id, $user_info); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | /** IF Order amount is 0, Finish the Order **/ |
| 225 | - if ( $cart['order_amount_to_pay_now'] == 0 ) { |
|
| 225 | + if ($cart['order_amount_to_pay_now'] == 0) { |
|
| 226 | 226 | $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
| 227 | 227 | $payment_status = 'completed'; |
| 228 | - $params_array = array ( |
|
| 228 | + $params_array = array( |
|
| 229 | 229 | 'method' =>'free', |
| 230 | 230 | 'waited_amount' => $order_meta['order_amount_to_pay_now'], |
| 231 | 231 | 'status' => 'payment_received', |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | ); |
| 237 | 237 | wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status); |
| 238 | 238 | } |
| 239 | - apply_filters( 'wpshop_finish_order_extra_actions', $order_id); |
|
| 239 | + apply_filters('wpshop_finish_order_extra_actions', $order_id); |
|
| 240 | 240 | } |
| 241 | 241 | endif; |
| 242 | 242 | return $order_id; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public static function send_order_email_to_administrator ( $order_id, $customer_infos = '' ) { |
|
| 246 | - if ( !empty($order_id) ) { |
|
| 245 | + public static function send_order_email_to_administrator($order_id, $customer_infos = '') { |
|
| 246 | + if (!empty($order_id)) { |
|
| 247 | 247 | $wps_message = new wps_message_ctr(); |
| 248 | 248 | $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
| 249 | 249 | //Send email to administrator(s) |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | $shop_admin_email = $shop_admin_email_option['contact_email']; |
| 252 | 252 | $order_tmp_key = ''; |
| 253 | 253 | |
| 254 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 255 | - $shipping_method = ( !empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ( (!empty($order_infos['order_payment']['shipping_method']) ) ? $order_infos['order_payment']['shipping_method'] : '' ); |
|
| 254 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 255 | + $shipping_method = (!empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ((!empty($order_infos['order_payment']['shipping_method'])) ? $order_infos['order_payment']['shipping_method'] : ''); |
|
| 256 | 256 | |
| 257 | 257 | |
| 258 | - if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){ |
|
| 258 | + if (!empty($order_infos) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key'])) { |
|
| 259 | 259 | $message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE'; |
| 260 | 260 | } |
| 261 | 261 | else { |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | $order_tmp_key = $order_infos['order_temporary_key']; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 267 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method']; |
|
| 266 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 267 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method']; |
|
| 268 | 268 | |
| 269 | - $data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => ( !empty($customer_infos) && !empty($customer_infos->user_email) ) ? $customer_infos->user_email : '' , 'customer_last_name' => ( !empty($customer_infos) && !empty($customer_infos->user_lastname) ) ? $customer_infos->user_lastname : '', 'customer_first_name' => ( !empty($customer_infos) && !empty($customer_infos->user_firstname) ) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '','order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ); |
|
| 269 | + $data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => (!empty($customer_infos) && !empty($customer_infos->user_email)) ? $customer_infos->user_email : '', 'customer_last_name' => (!empty($customer_infos) && !empty($customer_infos->user_lastname)) ? $customer_infos->user_lastname : '', 'customer_first_name' => (!empty($customer_infos) && !empty($customer_infos->user_firstname)) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''); |
|
| 270 | 270 | |
| 271 | - $wps_message->wpshop_prepared_email( $shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id)); |
|
| 271 | + $wps_message->wpshop_prepared_email($shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id)); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | * @param mixed $data Array or false. |
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | - public static function wps_direct_payment_link( $data = false ) { |
|
| 283 | - $data = empty( $data ) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 284 | - if ( (bool) $data ) { |
|
| 285 | - wps_orders_ctr::pay_quotation( $data['oid'] ); |
|
| 286 | - wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ) ) . '?order_step=5' ); |
|
| 282 | + public static function wps_direct_payment_link($data = false) { |
|
| 283 | + $data = empty($data) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 284 | + if ((bool)$data) { |
|
| 285 | + wps_orders_ctr::pay_quotation($data['oid']); |
|
| 286 | + wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . '?order_step=5'); |
|
| 287 | 287 | } else { |
| 288 | - wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' ) ) ) ); |
|
| 288 | + wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | /** |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | * @param mixed $data Array or false. |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | - public static function wps_direct_payment_link_nopriv( $data = false ) { |
|
| 299 | - $data = empty( $data ) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 300 | - if ( (bool) $data ) { |
|
| 301 | - wp_set_auth_cookie( $data['cid'], true, is_ssl() ); |
|
| 298 | + public static function wps_direct_payment_link_nopriv($data = false) { |
|
| 299 | + $data = empty($data) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 300 | + if ((bool)$data) { |
|
| 301 | + wp_set_auth_cookie($data['cid'], true, is_ssl()); |
|
| 302 | 302 | } |
| 303 | - self::wps_direct_payment_link( $data ); |
|
| 303 | + self::wps_direct_payment_link($data); |
|
| 304 | 304 | } |
| 305 | 305 | /** |
| 306 | 306 | * Verify token in request. |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | * @return mixed Customer id or false. |
| 310 | 310 | */ |
| 311 | 311 | public static function wps_direct_payment_link_verify_token() { |
| 312 | - $token = ! empty( $_GET['token'] ) ? sanitize_text_field( $_GET['token'] ) : ''; |
|
| 313 | - $order_id = ! empty( $_GET['order_id'] ) ? (int) $_GET['order_id'] : ''; |
|
| 314 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 315 | - $customer_id = ! empty( $order_metadata['customer_id'] ) ? (int) $order_metadata['customer_id'] : false; |
|
| 316 | - return ( (bool) $customer_id && wps_orders_ctr::wps_verify_token_order( $token, (int) $order_id ) ) ? array( 'oid' => $order_id, 'cid' => $customer_id ) : false; |
|
| 312 | + $token = !empty($_GET['token']) ? sanitize_text_field($_GET['token']) : ''; |
|
| 313 | + $order_id = !empty($_GET['order_id']) ? (int)$_GET['order_id'] : ''; |
|
| 314 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 315 | + $customer_id = !empty($order_metadata['customer_id']) ? (int)$order_metadata['customer_id'] : false; |
|
| 316 | + return ((bool)$customer_id && wps_orders_ctr::wps_verify_token_order($token, (int)$order_id)) ? array('oid' => $order_id, 'cid' => $customer_id) : false; |
|
| 317 | 317 | } |
| 318 | 318 | /** |
| 319 | 319 | * Get URL for wps_direct_link. |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param int $order_id OrderID. |
| 323 | 323 | * @return string Url or empty string. |
| 324 | 324 | */ |
| 325 | - public static function wps_direct_payment_link_url( $order_id ) { |
|
| 326 | - return ( (bool) ( $token = wps_orders_ctr::wps_token_order_customer( (int) $order_id ) ) ) ? admin_url( 'admin-post.php?action=wps_direct_payment_link&token=' . $token . '&order_id=' . (int) $order_id ) : ''; |
|
| 325 | + public static function wps_direct_payment_link_url($order_id) { |
|
| 326 | + return ((bool)($token = wps_orders_ctr::wps_token_order_customer((int)$order_id))) ? admin_url('admin-post.php?action=wps_direct_payment_link&token=' . $token . '&order_id=' . (int)$order_id) : ''; |
|
| 327 | 327 | } |
| 328 | 328 | } |
@@ -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,7 +70,7 @@ 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 | ); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param object $order The current order being edited |
| 112 | 112 | */ |
| 113 | - public static function order_actions( $order ) { |
|
| 113 | + public static function order_actions($order) { |
|
| 114 | 114 | $output = ''; |
| 115 | 115 | |
| 116 | 116 | $order_status = unserialize(WPSHOP_ORDER_STATUS); |
@@ -118,37 +118,37 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $tpl_component = array(); |
| 120 | 120 | |
| 121 | - $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'); |
|
| 122 | - $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : ''; |
|
| 121 | + $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'); |
|
| 122 | + $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : ''; |
|
| 123 | 123 | |
| 124 | 124 | /** Add an action list */ |
| 125 | 125 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = ''; |
| 126 | 126 | |
| 127 | 127 | /** Display main information about the order */ |
| 128 | 128 | $order_main_info = ''; |
| 129 | - if(!empty($order_postmeta['order_date'])){ |
|
| 130 | - $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>'; |
|
| 129 | + if (!empty($order_postmeta['order_date'])) { |
|
| 130 | + $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>'; |
|
| 131 | 131 | } |
| 132 | 132 | $order_main_info .= '<div class="wps-product-section">'; |
| 133 | - if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
|
| 134 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
|
| 133 | + if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) { |
|
| 134 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>'; |
|
| 135 | 135 | } |
| 136 | - else{ |
|
| 137 | - if(!empty($order_postmeta['order_key'])){ |
|
| 138 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
|
| 136 | + else { |
|
| 137 | + if (!empty($order_postmeta['order_key'])) { |
|
| 138 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>'; |
|
| 139 | 139 | } |
| 140 | - if(!empty($order_postmeta['order_temporary_key'])){ |
|
| 141 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>'; |
|
| 142 | - $post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; |
|
| 143 | - $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 />'; |
|
| 140 | + if (!empty($order_postmeta['order_temporary_key'])) { |
|
| 141 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>'; |
|
| 142 | + $post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0; |
|
| 143 | + $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 />'; |
|
| 144 | 144 | } |
| 145 | - if(!empty($order_postmeta['order_invoice_ref'])){ |
|
| 145 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 146 | 146 | $sub_tpl_component = array(); |
| 147 | 147 | $sub_tpl_component['ADMIN_ORDER_RECEIVED_PAYMENT_INVOICE_REF'] = $order_postmeta['order_invoice_ref']; |
| 148 | 148 | $sub_tpl_component['ADMIN_ORDER_PAYMENT_RECEIVED_LINE_CLASSES'] = ''; |
| 149 | - $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID ); |
|
| 149 | + $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID); |
|
| 150 | 150 | $order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin'); |
| 151 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
|
| 151 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . ''; |
|
| 152 | 152 | } |
| 153 | 153 | else { |
| 154 | 154 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | /*Add the current order status in display**/ |
| 161 | - $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')) ) : ''; |
|
| 161 | + $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'))) : ''; |
|
| 162 | 162 | |
| 163 | 163 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info; |
| 164 | 164 | |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | </div>'; |
| 177 | 177 | }*/ |
| 178 | 178 | |
| 179 | - 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 ) { |
|
| 180 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= self::display_customer_pay_quotation( isset( $order_postmeta['pay_quotation'] ), $order->ID ); |
|
| 179 | + 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) { |
|
| 180 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= self::display_customer_pay_quotation(isset($order_postmeta['pay_quotation']), $order->ID); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | }*/ |
| 189 | 189 | |
| 190 | 190 | /*Add the button regarding the order status**/ |
| 191 | - if ( !empty($order_postmeta['order_status']) ) { |
|
| 192 | - if( $order_postmeta['order_status'] == 'awaiting_payment' ) { |
|
| 193 | - $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>'; |
|
| 191 | + if (!empty($order_postmeta['order_status'])) { |
|
| 192 | + if ($order_postmeta['order_status'] == 'awaiting_payment') { |
|
| 193 | + $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>'; |
|
| 194 | 194 | } |
| 195 | - $credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true ); |
|
| 195 | + $credit_meta = get_post_meta($order->ID, '_wps_order_credit', true); |
|
| 196 | 196 | |
| 197 | - if ( empty($credit_meta) ) { |
|
| 198 | - if( $order_postmeta['order_status'] == 'refunded') { |
|
| 199 | - $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>'; |
|
| 197 | + if (empty($credit_meta)) { |
|
| 198 | + if ($order_postmeta['order_status'] == 'refunded') { |
|
| 199 | + $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>'; |
|
| 200 | 200 | } |
| 201 | 201 | else { |
| 202 | - $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>'; |
|
| 202 | + $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>'; |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | function order_container_in_admin() { |
| 212 | 212 | global $post; |
| 213 | 213 | $output = '<div id="wps_order_content_container">'; |
| 214 | - $output .= self::order_content( $post ); |
|
| 214 | + $output .= self::order_content($post); |
|
| 215 | 215 | $output .= '</div>'; |
| 216 | 216 | echo $output; |
| 217 | 217 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param order $post The complete order content |
| 224 | 224 | */ |
| 225 | - function order_content( $post ) { |
|
| 225 | + function order_content($post) { |
|
| 226 | 226 | $order_content = ''; |
| 227 | 227 | |
| 228 | 228 | $order = get_post_meta($post->ID, '_order_postmeta', true); |
| 229 | 229 | |
| 230 | 230 | $order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >'; |
| 231 | - if($order){/* Read the order content if the order has product */ |
|
| 231 | + if ($order) {/* Read the order content if the order has product */ |
|
| 232 | 232 | $order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin'); |
| 233 | 233 | if (empty($order['order_invoice_ref'])) { |
| 234 | 234 | $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>'; |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | /** Generate the billing reference regarding the order $order_id |
| 247 | 247 | * @return void |
| 248 | 248 | */ |
| 249 | - function order_generate_billing_number($order_id, $force_invoicing = false){ |
|
| 249 | + function order_generate_billing_number($order_id, $force_invoicing = false) { |
|
| 250 | 250 | global $wpdb, $wpshop_modules_billing; |
| 251 | 251 | |
| 252 | 252 | // Get the order from the db |
| 253 | 253 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 254 | 254 | |
| 255 | 255 | // If the payment is completed |
| 256 | - if(($order['order_status']=='completed') || $force_invoicing) { |
|
| 256 | + if (($order['order_status'] == 'completed') || $force_invoicing) { |
|
| 257 | 257 | |
| 258 | 258 | // If the reference hasn't been generated yet |
| 259 | - if(empty($order['order_invoice_ref'])) { |
|
| 260 | - $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id ); |
|
| 259 | + if (empty($order['order_invoice_ref'])) { |
|
| 260 | + $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id); |
|
| 261 | 261 | |
| 262 | 262 | update_post_meta($order_id, '_order_postmeta', $order); |
| 263 | 263 | } |
@@ -268,45 +268,45 @@ discard block |
||
| 268 | 268 | /** Renvoi une nouvelle r�f�rence unique pour une commande |
| 269 | 269 | * @return int |
| 270 | 270 | */ |
| 271 | - public static function get_new_order_reference(){ |
|
| 271 | + public static function get_new_order_reference() { |
|
| 272 | 272 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 273 | 273 | /* If the number doesn't exist, we create a default one */ |
| 274 | - if(!$number_figures){ |
|
| 274 | + if (!$number_figures) { |
|
| 275 | 275 | $number_figures = 5; |
| 276 | 276 | update_option('wpshop_order_number_figures', $number_figures); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 280 | 280 | /* If the counter doesn't exist, we initiate it */ |
| 281 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 281 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 282 | 282 | else { $order_current_number++; } |
| 283 | 283 | update_option('wpshop_order_current_number', $order_current_number); |
| 284 | 284 | |
| 285 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 286 | - return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref; |
|
| 285 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 286 | + return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** Renvoi une nouvelle r�f�rence unique pour un devis |
| 290 | 290 | * @return int |
| 291 | 291 | */ |
| 292 | - public static function get_new_pre_order_reference($save = true){ |
|
| 292 | + public static function get_new_pre_order_reference($save = true) { |
|
| 293 | 293 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 294 | 294 | /* If the number doesn't exist, we create a default one */ |
| 295 | - if(!$number_figures){ |
|
| 295 | + if (!$number_figures) { |
|
| 296 | 296 | $number_figures = 5; |
| 297 | 297 | update_option('wpshop_order_number_figures', $number_figures); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 301 | 301 | /* If the counter doesn't exist, we initiate it */ |
| 302 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 302 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 303 | 303 | else { $order_current_number++; } |
| 304 | - if($save){ |
|
| 304 | + if ($save) { |
|
| 305 | 305 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 309 | - return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref; |
|
| 308 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 309 | + return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | |
@@ -321,24 +321,24 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @return void |
| 323 | 323 | */ |
| 324 | - public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){ |
|
| 324 | + public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') { |
|
| 325 | 325 | /** Get order informations */ |
| 326 | 326 | $billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 327 | - $billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 328 | - $billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : ''; |
|
| 329 | - if ( !empty($_SESSION['shipping_partner_id']) ) { |
|
| 330 | - $partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 327 | + $billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 328 | + $billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : ''; |
|
| 329 | + if (!empty($_SESSION['shipping_partner_id'])) { |
|
| 330 | + $partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 331 | 331 | if (!empty($partner_address_id)) { |
| 332 | - foreach( $partner_address_id as $address_id ) { |
|
| 332 | + foreach ($partner_address_id as $address_id) { |
|
| 333 | 333 | $shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 334 | - $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 334 | + $shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | else { |
| 339 | 339 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 340 | - $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 341 | - $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
|
| 340 | + $shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 341 | + $shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : ''; |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $order_info = array('billing' => $billing_info, 'shipping' => $shipping_info); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | /** Set the custom colums |
| 352 | 352 | * @return array |
| 353 | 353 | */ |
| 354 | - static function orders_edit_columns($columns){ |
|
| 354 | + static function orders_edit_columns($columns) { |
|
| 355 | 355 | $columns = array( |
| 356 | 356 | 'cb' => '<input type="checkbox" />', |
| 357 | 357 | 'order_identifier' => __('Identifiers', 'wpshop'), |
@@ -371,42 +371,42 @@ discard block |
||
| 371 | 371 | * @return array |
| 372 | 372 | */ |
| 373 | 373 | public static function orders_custom_columns($column, $post_id) { |
| 374 | - if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
|
| 374 | + if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
| 375 | 375 | global $civility, $order_status; |
| 376 | 376 | |
| 377 | 377 | $metadata = get_post_custom(); |
| 378 | 378 | |
| 379 | - $order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):''; |
|
| 380 | - $addresses = get_post_meta($post_id,'_order_info', true); |
|
| 379 | + $order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : ''; |
|
| 380 | + $addresses = get_post_meta($post_id, '_order_info', true); |
|
| 381 | 381 | |
| 382 | - switch($column){ |
|
| 382 | + switch ($column) { |
|
| 383 | 383 | case "order_identifier": |
| 384 | - if( !empty( $order_postmeta['order_key'] ) ) { |
|
| 384 | + if (!empty($order_postmeta['order_key'])) { |
|
| 385 | 385 | echo '<b>' . $order_postmeta['order_key'] . '</b><br>'; |
| 386 | 386 | } |
| 387 | - if( !empty( $order_postmeta['order_invoice_ref'] ) ) { |
|
| 387 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 388 | 388 | echo '<i>' . $order_postmeta['order_invoice_ref'] . '</i>'; |
| 389 | - } elseif( !empty($order_postmeta['order_temporary_key'] ) ) { |
|
| 389 | + } elseif (!empty($order_postmeta['order_temporary_key'])) { |
|
| 390 | 390 | echo '<b>' . $order_postmeta['order_temporary_key'] . '</b>'; |
| 391 | 391 | } |
| 392 | 392 | break; |
| 393 | 393 | |
| 394 | 394 | case "order_status": |
| 395 | - 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'); |
|
| 395 | + 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'); |
|
| 396 | 396 | break; |
| 397 | 397 | |
| 398 | 398 | case "order_billing": |
| 399 | - if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
|
| 399 | + if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) { |
|
| 400 | 400 | $billing = $addresses['billing']['address']; |
| 401 | 401 | } |
| 402 | - else if ( !empty($addresses['billing']) ) { |
|
| 402 | + else if (!empty($addresses['billing'])) { |
|
| 403 | 403 | $billing = $addresses['billing']; |
| 404 | 404 | } |
| 405 | - if ( !empty($billing) ) { |
|
| 406 | - 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>'; |
|
| 407 | - echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />'; |
|
| 408 | - echo (!empty($billing['address']) ? $billing['address'] : null).'<br />'; |
|
| 409 | - echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null); |
|
| 405 | + if (!empty($billing)) { |
|
| 406 | + 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>'; |
|
| 407 | + echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />'; |
|
| 408 | + echo (!empty($billing['address']) ? $billing['address'] : null) . '<br />'; |
|
| 409 | + echo (!empty($billing['postcode']) ? $billing['postcode'] : null) . ' ' . (!empty($billing['city']) ? $billing['city'] : null) . ', ' . (!empty($billing['country']) ? $billing['country'] : null); |
|
| 410 | 410 | echo (!empty($billing['phone']) ? '<br />' . $billing['phone'] : ''); |
| 411 | 411 | } |
| 412 | 412 | else { |
@@ -415,33 +415,33 @@ discard block |
||
| 415 | 415 | break; |
| 416 | 416 | |
| 417 | 417 | case "order_shipping": |
| 418 | - if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
|
| 418 | + if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) { |
|
| 419 | 419 | $shipping = $addresses['shipping']['address']; |
| 420 | 420 | } |
| 421 | - else if ( !empty($addresses['shipping']) ) { |
|
| 421 | + else if (!empty($addresses['shipping'])) { |
|
| 422 | 422 | $shipping = $addresses['shipping']; |
| 423 | 423 | } |
| 424 | - if ( !empty($shipping) ) { |
|
| 425 | - echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>'; |
|
| 426 | - echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
|
| 427 | - echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />'; |
|
| 428 | - echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null); |
|
| 424 | + if (!empty($shipping)) { |
|
| 425 | + echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>'; |
|
| 426 | + echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />'; |
|
| 427 | + echo (!empty($shipping['address']) ? $shipping['address'] : null) . '<br />'; |
|
| 428 | + echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null) . ' ' . (!empty($shipping['city']) ? $shipping['city'] : null) . ', ' . (!empty($shipping['country']) ? $shipping['country'] : null); |
|
| 429 | 429 | } |
| 430 | - else{ |
|
| 430 | + else { |
|
| 431 | 431 | echo __('No information available for user shipping', 'wpshop'); |
| 432 | 432 | } |
| 433 | 433 | break; |
| 434 | 434 | |
| 435 | 435 | case "order_type": |
| 436 | - 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 | + echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>'; |
|
| 437 | 437 | $buttons = '<p class="row-actions">'; |
| 438 | 438 | // Voir la commande |
| 439 | - $buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>'; |
|
| 439 | + $buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>'; |
|
| 440 | 440 | // Marquer comme envoy� |
| 441 | 441 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 442 | - $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> '; |
|
| 442 | + $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader">' . __('Mark as shipped', 'wpshop') . '</a> '; |
|
| 443 | 443 | } |
| 444 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 444 | + else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) { |
|
| 445 | 445 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 446 | 446 | } |
| 447 | 447 | $buttons .= '</p>'; |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | case "order_total": |
| 456 | 456 | $currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency'); |
| 457 | - echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '. wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 457 | + echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 458 | 458 | break; |
| 459 | 459 | |
| 460 | 460 | /*case "order_actions": |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | public static function list_table_filters() { |
| 485 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 486 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 487 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 488 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 485 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 486 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 487 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 488 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 489 | 489 | |
| 490 | 490 | if (isset($post_type)) { |
| 491 | 491 | if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index'); |
| 498 | 498 | $min = $entity_filter_btpf; |
| 499 | 499 | $max = $entity_filter_btps; |
| 500 | - echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> '; |
|
| 501 | - echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null); |
|
| 502 | - echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null); |
|
| 500 | + echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> '; |
|
| 501 | + echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null); |
|
| 502 | + echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | public static function list_table_filter_parse_query($query) { |
| 508 | 508 | global $pagenow, $wpdb; |
| 509 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 510 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 511 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 512 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 509 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 510 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 511 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 512 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 513 | 513 | |
| 514 | - if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) { |
|
| 514 | + if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) { |
|
| 515 | 515 | $check = null; |
| 516 | - switch ( $entity_filter ) { |
|
| 516 | + switch ($entity_filter) { |
|
| 517 | 517 | case 'all': |
| 518 | 518 | $sql_query = $wpdb->prepare( |
| 519 | 519 | "SELECT ID |
@@ -577,27 +577,27 @@ discard block |
||
| 577 | 577 | break; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - if ( !empty( $check ) ) { |
|
| 581 | - if( !empty($no_btp) && $no_btp == 'yes' ) { |
|
| 580 | + if (!empty($check)) { |
|
| 581 | + if (!empty($no_btp) && $no_btp == 'yes') { |
|
| 582 | 582 | $min = 'minimum'; |
| 583 | 583 | $max = 'maximum'; |
| 584 | 584 | } else { |
| 585 | - $min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum'; |
|
| 586 | - $max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum'; |
|
| 585 | + $min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum'; |
|
| 586 | + $max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum'; |
|
| 587 | 587 | } |
| 588 | 588 | $results = $wpdb->get_results($sql_query); |
| 589 | 589 | $post_id_list = array(); |
| 590 | 590 | $i = 0; |
| 591 | - foreach($results as $item){ |
|
| 591 | + foreach ($results as $item) { |
|
| 592 | 592 | $meta_value = get_post_meta($item->ID, '_order_postmeta'); |
| 593 | - $price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 594 | - if( $price >= $min || $min == 'minimum' ) { |
|
| 595 | - if( $price <= $max || $max == 'maximum' ) { |
|
| 593 | + $price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 594 | + if ($price >= $min || $min == 'minimum') { |
|
| 595 | + if ($price <= $max || $max == 'maximum') { |
|
| 596 | 596 | $post_id_list[] = $item->ID; |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | - if( empty($post_id_list) ) { |
|
| 600 | + if (empty($post_id_list)) { |
|
| 601 | 601 | $post_id_list[] = 'no_result'; |
| 602 | 602 | } |
| 603 | 603 | $query->query_vars[$check] = $post_id_list; |
@@ -608,66 +608,66 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | |
| 610 | 610 | |
| 611 | - function latest_products_ordered ( $orders ) { |
|
| 611 | + function latest_products_ordered($orders) { |
|
| 612 | 612 | global $wpdb; |
| 613 | 613 | $product_id = $output = ''; |
| 614 | 614 | $products = array(); |
| 615 | 615 | $display_option = get_option('wpshop_display_option'); |
| 616 | - if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) { |
|
| 617 | - foreach( $orders as $order ) { |
|
| 618 | - $order_content = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
| 619 | - if ( !empty($order_content) && !empty( $order_content['order_items']) ) { |
|
| 616 | + if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) { |
|
| 617 | + foreach ($orders as $order) { |
|
| 618 | + $order_content = get_post_meta($order->ID, '_order_postmeta', true); |
|
| 619 | + if (!empty($order_content) && !empty($order_content['order_items'])) { |
|
| 620 | 620 | |
| 621 | - foreach( $order_content['order_items'] as $item ) { |
|
| 622 | - if ( count( $products) >= $display_option['latest_products_ordered'] ) { |
|
| 621 | + foreach ($order_content['order_items'] as $item) { |
|
| 622 | + if (count($products) >= $display_option['latest_products_ordered']) { |
|
| 623 | 623 | continue; |
| 624 | 624 | } |
| 625 | 625 | $product_id = $item['item_id']; |
| 626 | - if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) { |
|
| 627 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 628 | - if ( !empty( $parent_def ) ) { |
|
| 626 | + if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) { |
|
| 627 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 628 | + if (!empty($parent_def)) { |
|
| 629 | 629 | $parent_post = $parent_def['parent_post']; |
| 630 | 630 | $product_id = $parent_post->ID; |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if ( !in_array($product_id, $products) ) { |
|
| 634 | + if (!in_array($product_id, $products)) { |
|
| 635 | 635 | $products[] = $product_id; |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | - if ( !empty($products) ) { |
|
| 640 | + if (!empty($products)) { |
|
| 641 | 641 | $products_id = implode(",", $products); |
| 642 | - $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) ); |
|
| 642 | + $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]'))); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | return $output; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - function get_order_list_for_customer( $customer_id ) { |
|
| 648 | + function get_order_list_for_customer($customer_id) { |
|
| 649 | 649 | global $wpdb; |
| 650 | 650 | $output = ''; |
| 651 | 651 | |
| 652 | - if( !empty($customer_id) ) { |
|
| 653 | - $query = $wpdb->prepare( 'SELECT * |
|
| 654 | - FROM ' .$wpdb->posts. ' |
|
| 652 | + if (!empty($customer_id)) { |
|
| 653 | + $query = $wpdb->prepare('SELECT * |
|
| 654 | + FROM ' .$wpdb->posts . ' |
|
| 655 | 655 | WHERE post_author = %d |
| 656 | - AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 657 | - $orders = $wpdb->get_results( $query ); |
|
| 656 | + AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 657 | + $orders = $wpdb->get_results($query); |
|
| 658 | 658 | |
| 659 | - foreach( $orders as $order ) { |
|
| 659 | + foreach ($orders as $order) { |
|
| 660 | 660 | |
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | return $output; |
| 665 | 665 | } |
| 666 | - static function display_customer_pay_quotation( $state, $oid ) { |
|
| 667 | - $btn = '<div class="wps-product-section"><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="#" >'.__('Customer can pay', 'wpshop').'</a>'; |
|
| 668 | - if( $state ) { |
|
| 666 | + static function display_customer_pay_quotation($state, $oid) { |
|
| 667 | + $btn = '<div class="wps-product-section"><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="#" >' . __('Customer can pay', 'wpshop') . '</a>'; |
|
| 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 .= '<input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url( $oid ) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __( 'Copy', 'wpshop' ) . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce( 'wps_send_direct_payment_link' ) . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __( 'Send by mail', 'wpshop' ) . '"><span class="dashicons dashicons-email"></span></a><p>' . 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 ) ) . '</p>'; |
|
| 670 | + $btn .= '<input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url($oid) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __('Copy', 'wpshop') . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce('wps_send_direct_payment_link') . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __('Send by mail', 'wpshop') . '"><span class="dashicons dashicons-email"></span></a><p>' . 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)) . '</p>'; |
|
| 671 | 671 | } |
| 672 | 672 | return $btn . '</div>'; |
| 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 | * |
@@ -132,8 +134,7 @@ discard block |
||
| 132 | 134 | $order_main_info .= '<div class="wps-product-section">'; |
| 133 | 135 | if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
| 134 | 136 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
| 135 | - } |
|
| 136 | - else{ |
|
| 137 | + } else{ |
|
| 137 | 138 | if(!empty($order_postmeta['order_key'])){ |
| 138 | 139 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
| 139 | 140 | } |
@@ -149,8 +150,7 @@ discard block |
||
| 149 | 150 | $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID ); |
| 150 | 151 | $order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin'); |
| 151 | 152 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
| 152 | - } |
|
| 153 | - else { |
|
| 153 | + } else { |
|
| 154 | 154 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -197,8 +197,7 @@ discard block |
||
| 197 | 197 | if ( empty($credit_meta) ) { |
| 198 | 198 | if( $order_postmeta['order_status'] == 'refunded') { |
| 199 | 199 | $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>'; |
| 200 | - } |
|
| 201 | - else { |
|
| 200 | + } else { |
|
| 202 | 201 | $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>'; |
| 203 | 202 | } |
| 204 | 203 | } |
@@ -278,8 +277,7 @@ discard block |
||
| 278 | 277 | |
| 279 | 278 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 280 | 279 | /* If the counter doesn't exist, we initiate it */ |
| 281 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 282 | - else { $order_current_number++; } |
|
| 280 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 283 | 281 | update_option('wpshop_order_current_number', $order_current_number); |
| 284 | 282 | |
| 285 | 283 | $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
@@ -299,8 +297,7 @@ discard block |
||
| 299 | 297 | |
| 300 | 298 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 301 | 299 | /* If the counter doesn't exist, we initiate it */ |
| 302 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 303 | - else { $order_current_number++; } |
|
| 300 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 304 | 301 | if($save){ |
| 305 | 302 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 306 | 303 | } |
@@ -334,8 +331,7 @@ discard block |
||
| 334 | 331 | $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 335 | 332 | } |
| 336 | 333 | } |
| 337 | - } |
|
| 338 | - else { |
|
| 334 | + } else { |
|
| 339 | 335 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 340 | 336 | $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 341 | 337 | $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
@@ -398,8 +394,7 @@ discard block |
||
| 398 | 394 | case "order_billing": |
| 399 | 395 | if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
| 400 | 396 | $billing = $addresses['billing']['address']; |
| 401 | - } |
|
| 402 | - else if ( !empty($addresses['billing']) ) { |
|
| 397 | + } else if ( !empty($addresses['billing']) ) { |
|
| 403 | 398 | $billing = $addresses['billing']; |
| 404 | 399 | } |
| 405 | 400 | if ( !empty($billing) ) { |
@@ -408,8 +403,7 @@ discard block |
||
| 408 | 403 | echo (!empty($billing['address']) ? $billing['address'] : null).'<br />'; |
| 409 | 404 | echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null); |
| 410 | 405 | echo (!empty($billing['phone']) ? '<br />' . $billing['phone'] : ''); |
| 411 | - } |
|
| 412 | - else { |
|
| 406 | + } else { |
|
| 413 | 407 | echo __('No information available for user billing', 'wpshop'); |
| 414 | 408 | } |
| 415 | 409 | break; |
@@ -417,8 +411,7 @@ discard block |
||
| 417 | 411 | case "order_shipping": |
| 418 | 412 | if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
| 419 | 413 | $shipping = $addresses['shipping']['address']; |
| 420 | - } |
|
| 421 | - else if ( !empty($addresses['shipping']) ) { |
|
| 414 | + } else if ( !empty($addresses['shipping']) ) { |
|
| 422 | 415 | $shipping = $addresses['shipping']; |
| 423 | 416 | } |
| 424 | 417 | if ( !empty($shipping) ) { |
@@ -426,8 +419,7 @@ discard block |
||
| 426 | 419 | echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
| 427 | 420 | echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />'; |
| 428 | 421 | echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null); |
| 429 | - } |
|
| 430 | - else{ |
|
| 422 | + } else{ |
|
| 431 | 423 | echo __('No information available for user shipping', 'wpshop'); |
| 432 | 424 | } |
| 433 | 425 | break; |
@@ -440,8 +432,7 @@ discard block |
||
| 440 | 432 | // Marquer comme envoy� |
| 441 | 433 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 442 | 434 | $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> '; |
| 443 | - } |
|
| 444 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 435 | + } else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 445 | 436 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 446 | 437 | } |
| 447 | 438 | $buttons .= '</p>'; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | class wps_orders_ctr { |
| 4 | 4 | |
@@ -20,24 +20,24 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | /** Template Load */ |
| 22 | 22 | // add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) ); |
| 23 | - add_shortcode( 'order_customer_informations', array( &$this, 'display_order_customer_informations' ) ); |
|
| 24 | - add_shortcode( 'wps_orders_in_customer_account', array( $this, 'display_orders_in_account' ) ); |
|
| 25 | - add_action( 'wp_enqueue_scripts', array( $this, 'wps_orders_scripts' ) ); |
|
| 23 | + add_shortcode('order_customer_informations', array(&$this, 'display_order_customer_informations')); |
|
| 24 | + add_shortcode('wps_orders_in_customer_account', array($this, 'display_orders_in_account')); |
|
| 25 | + add_action('wp_enqueue_scripts', array($this, 'wps_orders_scripts')); |
|
| 26 | 26 | /** Include the different javascript */ |
| 27 | - add_action( 'admin_init', array( &$this, 'admin_js' ) ); |
|
| 27 | + add_action('admin_init', array(&$this, 'admin_js')); |
|
| 28 | 28 | |
| 29 | 29 | /** Ajax Actions */ |
| 30 | 30 | // add_action( 'wp_ajax_wps_add_product_to_quotation', array( &$this, 'wps_add_product_to_quotation') ); |
| 31 | 31 | // add_action( 'wap_ajax_wps_change_product_list', array( &$this, 'wps_change_product_list') ); |
| 32 | 32 | // add_action( 'wap_ajax_wps_orders_load_variations_container', array( &$this, 'wps_orders_load_variations_container') ); |
| 33 | 33 | // add_action( 'wap_ajax_wps_order_refresh_in_admin', array( &$this, 'wps_order_refresh_in_admin') ); |
| 34 | - add_action( 'wp_ajax_wps_orders_load_details', array( $this, 'wps_orders_load_details' ) ); |
|
| 34 | + add_action('wp_ajax_wps_orders_load_details', array($this, 'wps_orders_load_details')); |
|
| 35 | 35 | // Add a product sale historic in administration product panel |
| 36 | - add_action( 'wp_ajax_wps_order_choose_customer', array( $this, 'wps_order_choose_customer' ) ); |
|
| 36 | + add_action('wp_ajax_wps_order_choose_customer', array($this, 'wps_order_choose_customer')); |
|
| 37 | 37 | /** For delete order */ |
| 38 | - add_action( 'wp_ajax_wps_delete_order', array( $this, 'wps_delete_order' ) ); |
|
| 38 | + add_action('wp_ajax_wps_delete_order', array($this, 'wps_delete_order')); |
|
| 39 | 39 | /** Invoice Page */ |
| 40 | - add_action( 'admin_post_wps_invoice', array( $this, 'wps_invoice_output' ) ); |
|
| 40 | + add_action('admin_post_wps_invoice', array($this, 'wps_invoice_output')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function wps_orders_scripts() { |
| 56 | 56 | |
| 57 | - wp_enqueue_script( 'wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js' ); |
|
| 57 | + wp_enqueue_script('wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function display_order_customer_informations() { |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | global $post_id; |
| 63 | 63 | global $wpdb; |
| 64 | 64 | $output = ''; |
| 65 | - if ( ! empty( $post_id ) ) { |
|
| 66 | - $order_postmeta = get_post_meta( $post_id, '_order_postmeta', true ); |
|
| 67 | - $order_info = get_post_meta( $post_id, '_order_info', true ); |
|
| 65 | + if (!empty($post_id)) { |
|
| 66 | + $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
|
| 67 | + $order_info = get_post_meta($post_id, '_order_info', true); |
|
| 68 | 68 | /** Check the order status */ |
| 69 | - if ( ! empty( $order_postmeta ) ) { |
|
| 70 | - if ( ! empty( $order_postmeta['order_status'] ) && $order_postmeta['order_status'] != 'awaiting_payment' ) { |
|
| 71 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
| 72 | - $output .= wps_address::display_an_address( $order_info['shipping']['address'] ); |
|
| 69 | + if (!empty($order_postmeta)) { |
|
| 70 | + if (!empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'awaiting_payment') { |
|
| 71 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
| 72 | + $output .= wps_address::display_an_address($order_info['shipping']['address']); |
|
| 73 | 73 | } else { |
| 74 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
| 74 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } else { |
| 78 | 78 | /** Display "Choose customer or create one" Interface */ |
| 79 | 79 | $tpl_component = array(); |
| 80 | 80 | $args = array( |
| 81 | - 'show_option_all' => __( 'Choose a customer', 'wpshop' ), |
|
| 81 | + 'show_option_all' => __('Choose a customer', 'wpshop'), |
|
| 82 | 82 | 'orderby' => 'display_name', |
| 83 | 83 | 'order' => 'ASC', |
| 84 | 84 | 'include' => null, // string |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | 'id' => null, // integer |
| 93 | 93 | 'class' => 'chosen_select', // string |
| 94 | 94 | 'blog_id' => $GLOBALS['blog_id'], |
| 95 | - 'who' => null,// string |
|
| 95 | + 'who' => null, // string |
|
| 96 | 96 | ); |
| 97 | - $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users( $args ); |
|
| 98 | - $output = wpshop_display::display_template_element( 'wps_orders_choose_customer_interface', $tpl_component, array(), 'admin' ); |
|
| 97 | + $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users($args); |
|
| 98 | + $output = wpshop_display::display_template_element('wps_orders_choose_customer_interface', $tpl_component, array(), 'admin'); |
|
| 99 | 99 | } |
| 100 | 100 | return $output; |
| 101 | 101 | } |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | * @param integer $customer_id |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - function display_orders_in_account( $customer_id = '' ) { |
|
| 109 | + function display_orders_in_account($customer_id = '') { |
|
| 110 | 110 | |
| 111 | 111 | $output = ''; |
| 112 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : get_current_user_id(); |
|
| 113 | - $from_admin = ( ! empty( $customer_id ) ) ? true : false; |
|
| 112 | + $customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id(); |
|
| 113 | + $from_admin = (!empty($customer_id)) ? true : false; |
|
| 114 | 114 | $wps_orders_mdl = new wps_orders_mdl(); |
| 115 | - $orders = $wps_orders_mdl->get_customer_orders( $customer_id ); |
|
| 115 | + $orders = $wps_orders_mdl->get_customer_orders($customer_id); |
|
| 116 | 116 | // Display orders |
| 117 | 117 | ob_start(); |
| 118 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account' ) ); |
|
| 118 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account')); |
|
| 119 | 119 | $output = ob_get_contents(); |
| 120 | 120 | ob_end_clean(); |
| 121 | 121 | return $output; |
@@ -128,102 +128,102 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @return array $item_list The item to add to order |
| 130 | 130 | */ |
| 131 | - function add_product_to_order( $product ) { |
|
| 131 | + function add_product_to_order($product) { |
|
| 132 | 132 | |
| 133 | 133 | global $wpdb; |
| 134 | - if ( ! empty( $product ) && empty( $product['price_ttc_before_discount'] ) && empty( $product['price_ht_before_discount'] ) ) { |
|
| 135 | - $price_infos = wpshop_prices::check_product_price( $product, true ); |
|
| 136 | - $product['price_ht'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
| 137 | - $product['product_price'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
| 138 | - $product['tva'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
| 134 | + if (!empty($product) && empty($product['price_ttc_before_discount']) && empty($product['price_ht_before_discount'])) { |
|
| 135 | + $price_infos = wpshop_prices::check_product_price($product, true); |
|
| 136 | + $product['price_ht'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
| 137 | + $product['product_price'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
| 138 | + $product['tva'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $price_piloting = get_option( 'wpshop_shop_price_piloting' ); |
|
| 142 | - if ( ! empty( $price_piloting ) && $price_piloting == 'HT' ) { |
|
| 141 | + $price_piloting = get_option('wpshop_shop_price_piloting'); |
|
| 142 | + if (!empty($price_piloting) && $price_piloting == 'HT') { |
|
| 143 | 143 | $total_ht = $product['price_ht'] * $product['product_qty']; |
| 144 | - $tva_total_amount = $total_ht * ( $product['tx_tva'] / 100 ); |
|
| 144 | + $tva_total_amount = $total_ht * ($product['tx_tva'] / 100); |
|
| 145 | 145 | $total_ttc = $total_ht + $tva_total_amount; |
| 146 | 146 | } else { |
| 147 | 147 | $total_ttc = $product['product_price'] * $product['product_qty']; |
| 148 | - $total_ht = $total_ttc / ( 1 + ( $product['tx_tva'] / 100 ) ); |
|
| 148 | + $total_ht = $total_ttc / (1 + ($product['tx_tva'] / 100)); |
|
| 149 | 149 | $tva_total_amount = $total_ttc - $total_ht; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $tva = ! empty( $product[ WPSHOP_PRODUCT_PRICE_TAX ] ) ? $product[ WPSHOP_PRODUCT_PRICE_TAX ] : null; |
|
| 152 | + $tva = !empty($product[WPSHOP_PRODUCT_PRICE_TAX]) ? $product[WPSHOP_PRODUCT_PRICE_TAX] : null; |
|
| 153 | 153 | $item_discount_type = $item_discount_value = $item_discount_amount = 0; |
| 154 | - $d_amount = ! empty( $product ) && ! empty( $product['discount_amount'] ) ? wpshop_tools::formate_number( $product['discount_amount'] ) : null; |
|
| 155 | - $d_rate = ! empty( $product ) && ! empty( $product['discount_rate'] ) ? wpshop_tools::formate_number( $product['discount_rate'] ) : null; |
|
| 156 | - $d_special = ! empty( $product ) && ! empty( $product['special_price'] ) ? wpshop_tools::formate_number( $product['special_price'] ) : null; |
|
| 157 | - if ( ! empty( $d_amount ) ) { |
|
| 154 | + $d_amount = !empty($product) && !empty($product['discount_amount']) ? wpshop_tools::formate_number($product['discount_amount']) : null; |
|
| 155 | + $d_rate = !empty($product) && !empty($product['discount_rate']) ? wpshop_tools::formate_number($product['discount_rate']) : null; |
|
| 156 | + $d_special = !empty($product) && !empty($product['special_price']) ? wpshop_tools::formate_number($product['special_price']) : null; |
|
| 157 | + if (!empty($d_amount)) { |
|
| 158 | 158 | $item_discount_type = 'discount_amount'; |
| 159 | 159 | $item_discount_amount = $product['discount_amount']; |
| 160 | 160 | $item_discount_value = $product['discount_amount']; |
| 161 | - } elseif ( ! empty( $d_rate ) ) { |
|
| 161 | + } elseif (!empty($d_rate)) { |
|
| 162 | 162 | $item_discount_type = 'discount_rate'; |
| 163 | 163 | $item_discount_amount = $product['discount_rate']; |
| 164 | 164 | $item_discount_value = $product['discount_rate']; |
| 165 | - } elseif ( ! empty( $d_special ) ) { |
|
| 165 | + } elseif (!empty($d_special)) { |
|
| 166 | 166 | $item_discount_type = 'special_price'; |
| 167 | 167 | $item_discount_amount = $product['special_price']; |
| 168 | 168 | $item_discount_value = $product['special_price']; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $item = array( 'item_id' => $product['product_id'], 'item_ref' => ! empty( $product['product_reference'] ) ? $product['product_reference'] : null, 'item_name' => ! empty( $product['product_name'] ) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], 'item_qty' => $product['product_qty'], 'item_pu_ht' => $product['price_ht'], 'item_pu_ttc' => $product['product_price'], 'item_ecotaxe_ht' => 0, 'item_ecotaxe_tva' => 19.6, 'item_ecotaxe_ttc' => 0, 'item_discount_type' => $item_discount_type, 'item_discount_value' => $item_discount_value, 'item_discount_amount' => $item_discount_amount, 'item_tva_rate' => $tva, 'item_tva_amount' => $product['tva'], 'item_total_ht' => $total_ht, 'item_tva_total_amount' => $tva_total_amount, 'item_total_ttc' => $total_ttc, 'item_meta' => ! empty( $product['item_meta'] ) ? $product['item_meta'] : array() ); |
|
| 172 | - $array_not_to_do = array( WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations' ); |
|
| 173 | - if ( ! empty( $product['item_meta'] ) ) { |
|
| 174 | - foreach ( $product['item_meta'] as $key => $value ) { |
|
| 175 | - if ( ! isset( $item[ 'item_' . $key ] ) && ! in_array( $key, $array_not_to_do ) && ! empty( $product[ $key ] ) ) { |
|
| 176 | - $item[ 'item_' . $key ] = $product[ $key ]; |
|
| 171 | + $item = array('item_id' => $product['product_id'], 'item_ref' => !empty($product['product_reference']) ? $product['product_reference'] : null, 'item_name' => !empty($product['product_name']) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], 'item_qty' => $product['product_qty'], 'item_pu_ht' => $product['price_ht'], 'item_pu_ttc' => $product['product_price'], 'item_ecotaxe_ht' => 0, 'item_ecotaxe_tva' => 19.6, 'item_ecotaxe_ttc' => 0, 'item_discount_type' => $item_discount_type, 'item_discount_value' => $item_discount_value, 'item_discount_amount' => $item_discount_amount, 'item_tva_rate' => $tva, 'item_tva_amount' => $product['tva'], 'item_total_ht' => $total_ht, 'item_tva_total_amount' => $tva_total_amount, 'item_total_ttc' => $total_ttc, 'item_meta' => !empty($product['item_meta']) ? $product['item_meta'] : array()); |
|
| 172 | + $array_not_to_do = array(WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations'); |
|
| 173 | + if (!empty($product['item_meta'])) { |
|
| 174 | + foreach ($product['item_meta'] as $key => $value) { |
|
| 175 | + if (!isset($item['item_' . $key]) && !in_array($key, $array_not_to_do) && !empty($product[$key])) { |
|
| 176 | + $item['item_' . $key] = $product[$key]; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** Check if it's a variation product */ |
| 182 | - if ( ! empty( $product ) && ! empty( $product['item_meta'] ) && ! empty( $product['item_meta']['variations'] ) ) { |
|
| 183 | - foreach ( $product['item_meta']['variations'] as $k => $variation ) { |
|
| 184 | - $product_variation_def = get_post_meta( $k, '_wpshop_variations_attribute_def', true ); |
|
| 185 | - if ( ! empty( $product_variation_def ) ) { |
|
| 186 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
| 187 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
| 188 | - if ( ! empty( $variation_attribute_def ) ) { |
|
| 189 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 190 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
| 191 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
| 192 | - $variation_name = $wpdb->get_var( $query ); |
|
| 182 | + if (!empty($product) && !empty($product['item_meta']) && !empty($product['item_meta']['variations'])) { |
|
| 183 | + foreach ($product['item_meta']['variations'] as $k => $variation) { |
|
| 184 | + $product_variation_def = get_post_meta($k, '_wpshop_variations_attribute_def', true); |
|
| 185 | + if (!empty($product_variation_def)) { |
|
| 186 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
| 187 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
| 188 | + if (!empty($variation_attribute_def)) { |
|
| 189 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 190 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
| 191 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
| 192 | + $variation_name = $wpdb->get_var($query); |
|
| 193 | 193 | } else { |
| 194 | - $variation_post = get_post( $variation_id ); |
|
| 194 | + $variation_post = get_post($variation_id); |
|
| 195 | 195 | $variation_name = $variation_post->post_title; |
| 196 | 196 | } |
| 197 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
| 198 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
| 197 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
| 198 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | } else { |
| 204 | 204 | /** Check if it's product with one variation */ |
| 205 | - $product_variation_def = get_post_meta( $product['product_id'], '_wpshop_variations_attribute_def', true ); |
|
| 206 | - if ( ! empty( $product_variation_def ) ) { |
|
| 207 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
| 208 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
| 209 | - if ( ! empty( $variation_attribute_def ) ) { |
|
| 210 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 211 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
| 212 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
| 213 | - $variation_name = $wpdb->get_var( $query ); |
|
| 205 | + $product_variation_def = get_post_meta($product['product_id'], '_wpshop_variations_attribute_def', true); |
|
| 206 | + if (!empty($product_variation_def)) { |
|
| 207 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
| 208 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
| 209 | + if (!empty($variation_attribute_def)) { |
|
| 210 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 211 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
| 212 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
| 213 | + $variation_name = $wpdb->get_var($query); |
|
| 214 | 214 | } else { |
| 215 | - $variation_post = get_post( $variation_id ); |
|
| 215 | + $variation_post = get_post($variation_id); |
|
| 216 | 216 | $variation_name = $variation_post->post_title; |
| 217 | 217 | } |
| 218 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
| 219 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
| 218 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
| 219 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** On ajoute la possibilité d'étendre les données produits ajoutées dans le panier / Add possibility to extends product data saved into cart */ |
| 226 | - $item = apply_filters( 'wpshop-add-product-to-order', $item, $product ); |
|
| 226 | + $item = apply_filters('wpshop-add-product-to-order', $item, $product); |
|
| 227 | 227 | return $item; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -232,40 +232,40 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | function wps_invoice_output() { |
| 234 | 234 | |
| 235 | - $order_id = ( ! empty( $_GET['order_id'] )) ? (int) $_GET['order_id'] : null; |
|
| 236 | - $invoice_ref = ( ! empty( $_GET['invoice_ref'] )) ? sanitize_text_field( $_GET['invoice_ref'] ) : null; |
|
| 237 | - $mode = ( ! empty( $_GET['mode'] )) ? sanitize_text_field( $_GET['mode'] ) : 'html'; |
|
| 238 | - $is_credit_slip = ( ! empty( $_GET['credit_slip'] )) ? sanitize_text_field( $_GET['credit_slip'] ) : null; |
|
| 235 | + $order_id = (!empty($_GET['order_id'])) ? (int)$_GET['order_id'] : null; |
|
| 236 | + $invoice_ref = (!empty($_GET['invoice_ref'])) ? sanitize_text_field($_GET['invoice_ref']) : null; |
|
| 237 | + $mode = (!empty($_GET['mode'])) ? sanitize_text_field($_GET['mode']) : 'html'; |
|
| 238 | + $is_credit_slip = (!empty($_GET['credit_slip'])) ? sanitize_text_field($_GET['credit_slip']) : null; |
|
| 239 | 239 | $user_id = get_current_user_id(); |
| 240 | - if ( ! empty( $order_id ) && $user_id != 0 ) { |
|
| 240 | + if (!empty($order_id) && $user_id != 0) { |
|
| 241 | 241 | /** Order reading */ |
| 242 | - $order_postmeta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 242 | + $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 243 | 243 | /** Start invoice display */ |
| 244 | - if ( ! empty( $is_credit_slip ) ) { |
|
| 245 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref, 'credit_slip' ); |
|
| 244 | + if (!empty($is_credit_slip)) { |
|
| 245 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref, 'credit_slip'); |
|
| 246 | 246 | } else { |
| 247 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref ); |
|
| 247 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if ( $mode == 'pdf' ) { |
|
| 251 | - require_once( WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php' ); |
|
| 250 | + if ($mode == 'pdf') { |
|
| 251 | + require_once(WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php'); |
|
| 252 | 252 | try { |
| 253 | 253 | // $html_content = wpshop_display::display_template_element('invoice_print_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
| 254 | - $html_content = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ) . '<page>' . $html_content . '</page>'; |
|
| 255 | - $html2pdf = new HTML2PDF( 'P', 'A4', 'fr' ); |
|
| 256 | - $html2pdf->setDefaultFont( 'Arial' ); |
|
| 257 | - $html2pdf->writeHTML( $html_content ); |
|
| 258 | - $html2pdf->Output( 'order_' . $order_id . '.pdf', 'D' ); |
|
| 254 | + $html_content = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
|
| 255 | + $html2pdf = new HTML2PDF('P', 'A4', 'fr'); |
|
| 256 | + $html2pdf->setDefaultFont('Arial'); |
|
| 257 | + $html2pdf->writeHTML($html_content); |
|
| 258 | + $html2pdf->Output('order_' . $order_id . '.pdf', 'D'); |
|
| 259 | 259 | } catch (HTML2PDF_exception $e) { |
| 260 | 260 | echo $e; |
| 261 | 261 | exit; |
| 262 | 262 | } |
| 263 | 263 | } else { |
| 264 | - $order_invoice_ref = ( ! empty( $order_postmeta['order_invoice_ref'] ) ) ? $order_postmeta['order_invoice_ref'] : ''; |
|
| 265 | - $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ); |
|
| 264 | + $order_invoice_ref = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ''; |
|
| 265 | + $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common'); |
|
| 266 | 266 | $tpl_component['INVOICE_MAIN_PAGE'] = $html_content; |
| 267 | - $tpl_component['INVOICE_TITLE_PAGE'] = sprintf( __( 'Invoice %1$s for order %3$s (#%2$s)', 'wpshop' ), $order_invoice_ref, $order_id, $order_postmeta['order_key'] ); |
|
| 268 | - echo wpshop_display::display_template_element( 'invoice_page', $tpl_component, array(), 'common' ); |
|
| 267 | + $tpl_component['INVOICE_TITLE_PAGE'] = sprintf(__('Invoice %1$s for order %3$s (#%2$s)', 'wpshop'), $order_invoice_ref, $order_id, $order_postmeta['order_key']); |
|
| 268 | + echo wpshop_display::display_template_element('invoice_page', $tpl_component, array(), 'common'); |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | die(); |
@@ -277,21 +277,21 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | function wps_orders_load_details() { |
| 279 | 279 | |
| 280 | - check_ajax_referer( 'wps_orders_load_details' ); |
|
| 281 | - $order_id = ( ! empty( $_POST['order_id'] ) ) ? wpshop_tools::varSanitizer( $_POST['order_id'] ) : ''; |
|
| 280 | + check_ajax_referer('wps_orders_load_details'); |
|
| 281 | + $order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : ''; |
|
| 282 | 282 | $user_id = get_current_user_id(); |
| 283 | 283 | $status = false; |
| 284 | 284 | $result = ''; |
| 285 | - if ( ! empty( $order_id ) ) { |
|
| 286 | - $order = get_post( $order_id ); |
|
| 287 | - $order_infos = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 288 | - $order_key = ( ! empty( $order_infos['order_key'] ) ) ? $order_infos['order_key'] : '-'; |
|
| 289 | - if ( ! empty( $order ) && ! empty( $user_id ) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id ) { |
|
| 290 | - $result = do_shortcode( '[wps_cart cart_type="summary" oid="' . $order_id . '"]' ); |
|
| 285 | + if (!empty($order_id)) { |
|
| 286 | + $order = get_post($order_id); |
|
| 287 | + $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
|
| 288 | + $order_key = (!empty($order_infos['order_key'])) ? $order_infos['order_key'] : '-'; |
|
| 289 | + if (!empty($order) && !empty($user_id) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id) { |
|
| 290 | + $result = do_shortcode('[wps_cart cart_type="summary" oid="' . $order_id . '"]'); |
|
| 291 | 291 | $status = true; |
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | - echo json_encode( array( 'status' => $status, 'title' => sprintf( __( 'Order n° %s details', 'wpshop' ), $order_key ), 'content' => $result ) ); |
|
| 294 | + echo json_encode(array('status' => $status, 'title' => sprintf(__('Order n° %s details', 'wpshop'), $order_key), 'content' => $result)); |
|
| 295 | 295 | wp_die(); |
| 296 | 296 | } |
| 297 | 297 | |
@@ -300,60 +300,60 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | function wps_order_choose_customer() { |
| 302 | 302 | |
| 303 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 304 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_order_choose_customer' ) ) { |
|
| 303 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 304 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_choose_customer')) { |
|
| 305 | 305 | wp_die(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | $status = false; |
| 309 | 309 | $billing_data = $shipping_data = ''; |
| 310 | - $customer_id = ( ! empty( $_POST['customer_id'] ) ) ? intval( $_POST['customer_id'] ): null; |
|
| 311 | - if ( ! empty( $customer_id ) ) { |
|
| 310 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 311 | + if (!empty($customer_id)) { |
|
| 312 | 312 | $wps_address = new wps_address(); |
| 313 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 314 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 313 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 314 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 315 | 315 | $billing_option = $billing_option['choice']; |
| 316 | - $customer_addresses_list = wps_address::get_addresses_list( $customer_id ); |
|
| 316 | + $customer_addresses_list = wps_address::get_addresses_list($customer_id); |
|
| 317 | 317 | $status = true; |
| 318 | - $billing_data = '<div class="wps-alert-info">' . sprintf( __( 'No Billing address created, <a href="%s" title="' . __( 'Create a new billing address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
| 319 | - if ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) { |
|
| 318 | + $billing_data = '<div class="wps-alert-info">' . sprintf(__('No Billing address created, <a href="%s" title="' . __('Create a new billing address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
| 319 | + if (!empty($shipping_option) && !empty($shipping_option['activate'])) { |
|
| 320 | 320 | $shipping_option = $shipping_option['choice']; |
| 321 | - $shipping_data = '<div class="wps-alert-info">' . sprintf( __( 'No shipping address created, <a href="%s" title="' . __( 'Create a new shipping address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
| 321 | + $shipping_data = '<div class="wps-alert-info">' . sprintf(__('No shipping address created, <a href="%s" title="' . __('Create a new shipping address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( ! empty( $customer_addresses_list ) ) { |
|
| 325 | - foreach ( $customer_addresses_list as $address_type => $customer_addresses ) { |
|
| 326 | - if ( $billing_option == $address_type ) { |
|
| 327 | - $billing_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
| 324 | + if (!empty($customer_addresses_list)) { |
|
| 325 | + foreach ($customer_addresses_list as $address_type => $customer_addresses) { |
|
| 326 | + if ($billing_option == $address_type) { |
|
| 327 | + $billing_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
| 328 | 328 | } else { |
| 329 | - $shipping_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
| 329 | + $shipping_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - echo json_encode( array( 'status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data ) ); |
|
| 334 | + echo json_encode(array('status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data)); |
|
| 335 | 335 | wp_die(); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - static function pay_quotation( $order_id ) { |
|
| 338 | + static function pay_quotation($order_id) { |
|
| 339 | 339 | |
| 340 | 340 | $status = true; |
| 341 | - $order_id = (int) $order_id; |
|
| 342 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 343 | - $order_info = get_post_meta( $order_id, '_order_info', true ); |
|
| 344 | - $_SESSION['shipping_method'] = isset( $order_meta['order_payment']['shipping_method'] ) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
| 345 | - if ( isset( $order_info['billing']['address_id'] ) ) { |
|
| 341 | + $order_id = (int)$order_id; |
|
| 342 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 343 | + $order_info = get_post_meta($order_id, '_order_info', true); |
|
| 344 | + $_SESSION['shipping_method'] = isset($order_meta['order_payment']['shipping_method']) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
| 345 | + if (isset($order_info['billing']['address_id'])) { |
|
| 346 | 346 | $_SESSION['billing_address'] = $order_info['billing']['address_id']; |
| 347 | 347 | $_SESSION['cart'] = $order_meta; |
| 348 | 348 | $_SESSION['cart']['order_id'] = $order_id; |
| 349 | 349 | $_SESSION['cart']['cart_type'] = 'cart'; |
| 350 | 350 | $_SESSION['cart']['order_shipping_cost_fixe'] = 'on'; |
| 351 | - $permalink = get_permalink( get_option( 'wpshop_cart_page_id' ) ) . '?order_step=5'; |
|
| 351 | + $permalink = get_permalink(get_option('wpshop_cart_page_id')) . '?order_step=5'; |
|
| 352 | 352 | } else { |
| 353 | - $status = self::add_order_to_session( $order_id ); |
|
| 354 | - $permalink = get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ) ); |
|
| 353 | + $status = self::add_order_to_session($order_id); |
|
| 354 | + $permalink = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))); |
|
| 355 | 355 | } |
| 356 | - return array( 'status' => $status, 'permalink' => $permalink ); |
|
| 356 | + return array('status' => $status, 'permalink' => $permalink); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -362,54 +362,54 @@ discard block |
||
| 362 | 362 | * @method add_order_to_session |
| 363 | 363 | * @param int $order_id Id of order. |
| 364 | 364 | */ |
| 365 | - public static function add_order_to_session( $order_id ) { |
|
| 365 | + public static function add_order_to_session($order_id) { |
|
| 366 | 366 | |
| 367 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 368 | - if ( $order_meta != false ) { |
|
| 367 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 368 | + if ($order_meta != false) { |
|
| 369 | 369 | $_SESSION['cart'] = array(); |
| 370 | 370 | $_SESSION['cart']['order_amount_to_pay_now'] = $order_meta['order_amount_to_pay_now']; |
| 371 | 371 | $_SESSION['cart']['order_items'] = array(); |
| 372 | - if ( ! empty( $order_meta ) && ! empty( $order_meta['order_items'] ) ) { |
|
| 372 | + if (!empty($order_meta) && !empty($order_meta['order_items'])) { |
|
| 373 | 373 | $wpshop_cart_type = 'cart'; |
| 374 | - foreach ( $order_meta['order_items'] as $item ) { |
|
| 375 | - $_SESSION['cart']['order_items'][ $item['item_id'] ] = $item; |
|
| 374 | + foreach ($order_meta['order_items'] as $item) { |
|
| 375 | + $_SESSION['cart']['order_items'][$item['item_id']] = $item; |
|
| 376 | 376 | } |
| 377 | 377 | $wps_cart_ctr = new wps_cart(); |
| 378 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
| 379 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
| 378 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
| 379 | + $wps_cart_ctr->store_cart_in_session($order); |
|
| 380 | 380 | } |
| 381 | 381 | $_SESSION['order_id'] = $order_id; |
| 382 | 382 | } |
| 383 | - return (bool) ($order_meta != false); |
|
| 383 | + return (bool)($order_meta != false); |
|
| 384 | 384 | } |
| 385 | 385 | /** |
| 386 | 386 | * AJAX - Delete order by order_id |
| 387 | 387 | */ |
| 388 | 388 | public function wps_delete_order() { |
| 389 | 389 | |
| 390 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 391 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_delete_order' ) ) { |
|
| 390 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 391 | + if (!wp_verify_nonce($_wpnonce, 'wps_delete_order')) { |
|
| 392 | 392 | wp_die(); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $status = false; |
| 396 | 396 | $output = ''; |
| 397 | - $order_id = ! empty( $_POST['order_id'] ) ? (int) $_POST['order_id'] : 0; |
|
| 398 | - if ( $order_id ) { |
|
| 399 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 397 | + $order_id = !empty($_POST['order_id']) ? (int)$_POST['order_id'] : 0; |
|
| 398 | + if ($order_id) { |
|
| 399 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 400 | 400 | $wps_credit = new wps_credit(); |
| 401 | - $wps_credit->create_an_credit( $order_id ); |
|
| 401 | + $wps_credit->create_an_credit($order_id); |
|
| 402 | 402 | $order_meta['order_status'] = 'canceled'; |
| 403 | - $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time( 'mysql', 0 ); |
|
| 403 | + $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time('mysql', 0); |
|
| 404 | 404 | $order_meta['order_payment']['refunded_action']['author'] = get_current_user_id(); |
| 405 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 405 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 406 | 406 | ob_start(); |
| 407 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account' ) ); |
|
| 407 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account')); |
|
| 408 | 408 | $output = ob_get_contents(); |
| 409 | 409 | ob_end_clean(); |
| 410 | 410 | $status = true; |
| 411 | 411 | } |
| 412 | - echo json_encode( array( 'status' => $status, 'row' => $output ) ); |
|
| 412 | + echo json_encode(array('status' => $status, 'row' => $output)); |
|
| 413 | 413 | wp_die(); |
| 414 | 414 | } |
| 415 | 415 | |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | * @param int $order_id OrderID. |
| 421 | 421 | * @return mixed sha1 or false. |
| 422 | 422 | */ |
| 423 | - public static function wps_token_order_customer( $order_id, $date = null ) { |
|
| 424 | - $date = isset( $date ) ? $date : date( 'Ym' ); |
|
| 425 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 426 | - if ( ! isset( $order_metadata['customer_id'] ) ) { |
|
| 423 | + public static function wps_token_order_customer($order_id, $date = null) { |
|
| 424 | + $date = isset($date) ? $date : date('Ym'); |
|
| 425 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 426 | + if (!isset($order_metadata['customer_id'])) { |
|
| 427 | 427 | return false; |
| 428 | 428 | } |
| 429 | - return sha1( site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date ); |
|
| 429 | + return sha1(site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | * @param int $order_id OrderID. |
| 438 | 438 | * @return boolean |
| 439 | 439 | */ |
| 440 | - public static function wps_verify_token_order( $token, $order_id ) { |
|
| 441 | - $current_month = self::wps_token_order_customer( $order_id ); |
|
| 442 | - $last_month = self::wps_token_order_customer( $order_id, date_format( date_create( date( 'Y-m' ) . ' - 1month' ), 'Ym' ) ); |
|
| 443 | - return (bool) ( (bool) $current_month && (bool) $last_month && ( $token === $current_month || $token === $last_month ) ); |
|
| 440 | + public static function wps_verify_token_order($token, $order_id) { |
|
| 441 | + $current_month = self::wps_token_order_customer($order_id); |
|
| 442 | + $last_month = self::wps_token_order_customer($order_id, date_format(date_create(date('Y-m') . ' - 1month'), 'Ym')); |
|
| 443 | + return (bool)((bool)$current_month && (bool)$last_month && ($token === $current_month || $token === $last_month)); |
|
| 444 | 444 | } |
| 445 | 445 | } |
@@ -20,18 +20,18 @@ discard block |
||
| 20 | 20 | ini_set('memory_limit', '512M'); |
| 21 | 21 | |
| 22 | 22 | /** Check if file is include. No direct access possible with file url */ |
| 23 | -if ( !defined( 'ABSPATH' ) ) { |
|
| 24 | - die( 'Access is not allowed by this way' ); |
|
| 23 | +if (!defined('ABSPATH')) { |
|
| 24 | + die('Access is not allowed by this way'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** Allows to refresh css and js file in final user browser */ |
| 28 | 28 | DEFINE('WPSHOP_VERSION', '1.4.3.1'); |
| 29 | 29 | |
| 30 | 30 | /** Allows to avoid problem with theme not supporting thumbnail for post */ |
| 31 | -add_theme_support( 'post-thumbnails' ); |
|
| 32 | -add_image_size( 'wpshop-product-galery', 270, 270, true ); |
|
| 33 | -add_image_size( 'wps-categorie-mini-display', 80, 80, true ); |
|
| 34 | -add_image_size( 'wps-categorie-display', 480, 340, true ); |
|
| 31 | +add_theme_support('post-thumbnails'); |
|
| 32 | +add_image_size('wpshop-product-galery', 270, 270, true); |
|
| 33 | +add_image_size('wps-categorie-mini-display', 80, 80, true); |
|
| 34 | +add_image_size('wps-categorie-display', 480, 340, true); |
|
| 35 | 35 | |
| 36 | 36 | /** First thing we define the main directory for our plugin in a super global var */ |
| 37 | 37 | DEFINE('WPSHOP_PLUGIN_DIR', basename(dirname(__FILE__))); |
@@ -39,26 +39,26 @@ discard block |
||
| 39 | 39 | /** Get the current language to translate the different text in plugin */ |
| 40 | 40 | $locale = get_locale(); |
| 41 | 41 | global $wpdb; |
| 42 | -if ( defined("ICL_LANGUAGE_CODE") ) { |
|
| 42 | +if (defined("ICL_LANGUAGE_CODE")) { |
|
| 43 | 43 | $query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", ICL_LANGUAGE_CODE); |
| 44 | 44 | $local = $wpdb->get_var($query); |
| 45 | 45 | $locale = !empty($local) ? $local : $locale; |
| 46 | 46 | } |
| 47 | 47 | DEFINE('WPSHOP_CURRENT_LOCALE', $locale); |
| 48 | 48 | /** Load plugin translation */ |
| 49 | -load_plugin_textdomain( 'wpshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); |
|
| 49 | +load_plugin_textdomain('wpshop', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
| 50 | 50 | |
| 51 | 51 | /** Include the config file */ |
| 52 | 52 | require(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php'); |
| 53 | 53 | |
| 54 | 54 | /** Allow to get errors back when debug mode is set to true */ |
| 55 | -if ( WPSHOP_DEBUG_MODE && (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP)) ) ) { |
|
| 55 | +if (WPSHOP_DEBUG_MODE && (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP)))) { |
|
| 56 | 56 | ini_set('display_errors', true); |
| 57 | 57 | error_reporting(E_ALL); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | include_once(WPSHOP_LIBRAIRIES_DIR . 'init.class.php'); |
| 61 | -$current_installation_step = get_option( 'wps-installation-current-step', 1 ); |
|
| 61 | +$current_installation_step = get_option('wps-installation-current-step', 1); |
|
| 62 | 62 | |
| 63 | 63 | /** Get current plugin version */ |
| 64 | 64 | $current_db_version = get_option('wpshop_db_options', 0); |
@@ -76,32 +76,32 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | /** Call function to create the main left menu */ |
| 78 | 78 | //if ( ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $_GET ) && !empty( $_GET[ 'installation_state' ] ) && ( "ignored" == $_GET[ 'installation_state' ] ) ) ) { |
| 79 | - add_action('admin_menu', array( 'wpshop_init', 'admin_menu' ) ); |
|
| 80 | - add_action( 'menu_order', array( 'wpshop_init', 'admin_menu_order' ) ); |
|
| 81 | - add_action( 'custom_menu_order', array( 'wpshop_init', 'admin_custom_menu_order' ) ); |
|
| 79 | + add_action('admin_menu', array('wpshop_init', 'admin_menu')); |
|
| 80 | + add_action('menu_order', array('wpshop_init', 'admin_menu_order')); |
|
| 81 | + add_action('custom_menu_order', array('wpshop_init', 'admin_custom_menu_order')); |
|
| 82 | 82 | |
| 83 | 83 | /* Call function for new wordpress element creating [term (product_category) / post (product)] */ |
| 84 | - add_action( 'init', array( 'wpshop_init', 'add_new_wp_type' ) ); |
|
| 84 | + add_action('init', array('wpshop_init', 'add_new_wp_type')); |
|
| 85 | 85 | |
| 86 | 86 | /* Call function allowing to change element front output */ |
| 87 | - add_action( 'the_content', array( 'wpshop_display', 'products_page' ), 1 ); |
|
| 87 | + add_action('the_content', array('wpshop_display', 'products_page'), 1); |
|
| 88 | 88 | // add_action('archive_template', array('wpshop_categories', 'category_template_switcher')); |
| 89 | 89 | //} |
| 90 | 90 | |
| 91 | 91 | /** On plugin activation create the default parameters to use the ecommerce */ |
| 92 | -register_activation_hook( __FILE__ , array('wpshop_install', 'install_on_activation') ); |
|
| 92 | +register_activation_hook(__FILE__, array('wpshop_install', 'install_on_activation')); |
|
| 93 | 93 | |
| 94 | 94 | /** On plugin deactivation call the function to clean the wordpress installation */ |
| 95 | -register_deactivation_hook( __FILE__ , array('wpshop_install', 'uninstall_wpshop') ); |
|
| 95 | +register_deactivation_hook(__FILE__, array('wpshop_install', 'uninstall_wpshop')); |
|
| 96 | 96 | |
| 97 | 97 | /** Get current plugin version */ |
| 98 | 98 | $current_db_version = get_option('wpshop_db_options', 0); |
| 99 | 99 | |
| 100 | 100 | /** Add the database content */ |
| 101 | 101 | add_action('admin_init', array('wpshop_install', 'update_wpshop')); |
| 102 | -if ( ( defined( 'WPSINSTALLER_STEPS_COUNT' ) && ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'installation_state' ] ) && ( "ignore" == $current_db_version[ 'installation_state' ] ) ) ) { |
|
| 103 | - if ( in_array( long2ip( ip2long($_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) ) ) { |
|
| 104 | - add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop_dev' ) ); |
|
| 102 | +if ((defined('WPSINSTALLER_STEPS_COUNT') && (WPSINSTALLER_STEPS_COUNT <= $current_installation_step)) || (!empty($current_db_version) && !empty($current_db_version['db_version']) && (51 < $current_db_version['db_version'])) || (!empty($current_db_version) && !empty($current_db_version['installation_state']) && ("ignore" == $current_db_version['installation_state']))) { |
|
| 103 | + if (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) { |
|
| 104 | + add_action('admin_init', array('wpshop_install', 'update_wpshop_dev')); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | // Start session |
@@ -138,24 +138,24 @@ discard block |
||
| 138 | 138 | /** Add specific messages for wpshop elements management */ |
| 139 | 139 | // add_filter('post_updated_messages', array('wpshop_messages', 'update_wp_message_list')); |
| 140 | 140 | |
| 141 | -$file = basename( __FILE__ ); |
|
| 142 | -$folder = basename( dirname( __FILE__ ) ); |
|
| 141 | +$file = basename(__FILE__); |
|
| 142 | +$folder = basename(dirname(__FILE__)); |
|
| 143 | 143 | $hook = "in_plugin_update_message-{$folder}/{$file}"; |
| 144 | -add_action( $hook, 'wps_update_message', 10, 2 ); // 10:priority, 2:arguments # |
|
| 145 | -function wps_update_message( $currentPluginMetadata, $newPluginMetadata){ |
|
| 144 | +add_action($hook, 'wps_update_message', 10, 2); // 10:priority, 2:arguments # |
|
| 145 | +function wps_update_message($currentPluginMetadata, $newPluginMetadata) { |
|
| 146 | 146 | $message = ''; |
| 147 | 147 | |
| 148 | - if ( '1.4.1.6' == $currentPluginMetadata[ 'Version' ] ) { |
|
| 149 | - $message = sprintf( __( 'For security reason %splease read this post%s', 'wpshop' ), '<a href="" >', '</a>'); |
|
| 148 | + if ('1.4.1.6' == $currentPluginMetadata['Version']) { |
|
| 149 | + $message = sprintf(__('For security reason %splease read this post%s', 'wpshop'), '<a href="" >', '</a>'); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // check "upgrade_notice" |
| 153 | - if (isset( $newPluginMetadata->upgrade_notice) && strlen(trim($newPluginMetadata->upgrade_notice)) > 0 ) { |
|
| 154 | - $message = esc_html( $newPluginMetadata->upgrade_notice ); |
|
| 153 | + if (isset($newPluginMetadata->upgrade_notice) && strlen(trim($newPluginMetadata->upgrade_notice)) > 0) { |
|
| 154 | + $message = esc_html($newPluginMetadata->upgrade_notice); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( !empty( $message ) ) { |
|
| 158 | - echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __( 'Important upgrade notice', 'wpshop' ) . ': </strong>' . $message . '</p>'; |
|
| 157 | + if (!empty($message)) { |
|
| 158 | + echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __('Important upgrade notice', 'wpshop') . ': </strong>' . $message . '</p>'; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |