@@ -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 | /** |
@@ -20,29 +20,29 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $wpshop_paypal = new wpshop_paypal(); |
| 22 | 22 | // If the CIC payment method is active |
| 23 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 24 | - if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) { |
|
| 23 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 24 | + if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) { |
|
| 25 | 25 | $wpshop_cic = new wpshop_CIC(); |
| 26 | 26 | } |
| 27 | - wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse'); |
|
| 27 | + wpshop_tools::create_custom_hook('wpshop_bankserver_reponse'); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function get_success_payment_url() { |
| 32 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) ); |
|
| 32 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id'))); |
|
| 33 | 33 | return self::construct_url_parameters($url, 'paymentResult', 'success'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public static function get_cancel_payment_url() { |
| 37 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) ); |
|
| 37 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id'))); |
|
| 38 | 38 | return $url; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 42 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | - if($interoguation_marker_pos===false) |
|
| 44 | - return $url.'?'.$param.'='.$value; |
|
| 45 | - else return $url.'&'.$param.'='.$value; |
|
| 43 | + if ($interoguation_marker_pos === false) |
|
| 44 | + return $url . '?' . $param . '=' . $value; |
|
| 45 | + else return $url . '&' . $param . '=' . $value; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -51,23 +51,23 @@ discard block |
||
| 51 | 51 | public static function wpshop_payment_result() { |
| 52 | 52 | global $wpdb; |
| 53 | 53 | $user_ID = get_current_user_id(); |
| 54 | - $query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | - $order_post_id = $wpdb->get_var( $query ); |
|
| 56 | - if ( !empty($order_post_id) ) { |
|
| 57 | - $order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true); |
|
| 58 | - if ( !empty($order_postmeta) ) { |
|
| 59 | - switch ( $order_postmeta ) { |
|
| 54 | + $query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | + $order_post_id = $wpdb->get_var($query); |
|
| 56 | + if (!empty($order_post_id)) { |
|
| 57 | + $order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true); |
|
| 58 | + if (!empty($order_postmeta)) { |
|
| 59 | + switch ($order_postmeta) { |
|
| 60 | 60 | case 'awaiting_payment': |
| 61 | - echo __('We wait your payment.','wpshop'); |
|
| 61 | + echo __('We wait your payment.', 'wpshop'); |
|
| 62 | 62 | break; |
| 63 | 63 | case 'completed': |
| 64 | - echo __('Thank you ! Your payment has been recorded.','wpshop'); |
|
| 64 | + echo __('Thank you ! Your payment has been recorded.', 'wpshop'); |
|
| 65 | 65 | break; |
| 66 | 66 | case 'partially_paid': |
| 67 | - echo __('Thank you ! Your first payment has been recorded.','wpshop'); |
|
| 67 | + echo __('Thank you ! Your first payment has been recorded.', 'wpshop'); |
|
| 68 | 68 | break; |
| 69 | 69 | default: |
| 70 | - echo __('Your payment and your order has been cancelled.','wpshop'); |
|
| 70 | + echo __('Your payment and your order has been cancelled.', 'wpshop'); |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -88,56 +88,56 @@ discard block |
||
| 88 | 88 | * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later |
| 89 | 89 | * @return string The different payment method |
| 90 | 90 | */ |
| 91 | - function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 91 | + function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 92 | 92 | $output = ''; |
| 93 | 93 | /** Get available payment method */ |
| 94 | 94 | $paymentMethod = get_option('wpshop_paymentMethod', array()); |
| 95 | 95 | |
| 96 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 96 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ($cart_type == 'cart') { |
| 101 | 101 | $payment_methods = array(); |
| 102 | - if(!empty($paymentMethod['paypal'])) { |
|
| 102 | + if (!empty($paymentMethod['paypal'])) { |
|
| 103 | 103 | $payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'), |
| 104 | 104 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png', |
| 105 | - 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop') |
|
| 105 | + 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop') |
|
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | - if(!empty($paymentMethod['checks'])) { |
|
| 108 | + if (!empty($paymentMethod['checks'])) { |
|
| 109 | 109 | $payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'), |
| 110 | 110 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 111 | - 'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop') |
|
| 111 | + 'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop') |
|
| 112 | 112 | ); |
| 113 | 113 | } |
| 114 | - if(!empty($paymentMethod['banktransfer'])) { |
|
| 114 | + if (!empty($paymentMethod['banktransfer'])) { |
|
| 115 | 115 | $payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'), |
| 116 | 116 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 117 | - 'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop') |
|
| 117 | + 'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop') |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | - if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 120 | + if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 121 | 121 | $payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'), |
| 122 | 122 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg', |
| 123 | - 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop') |
|
| 123 | + 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop') |
|
| 124 | 124 | ); |
| 125 | 125 | } |
| 126 | 126 | $payment_methods = apply_filters('wpshop_payment_method', $payment_methods); |
| 127 | 127 | |
| 128 | 128 | $payment_method_table = array(); |
| 129 | 129 | |
| 130 | - if ( !empty( $paymentMethod['display_position'] ) ) { |
|
| 130 | + if (!empty($paymentMethod['display_position'])) { |
|
| 131 | 131 | $position_determinated = false; |
| 132 | - foreach ( $paymentMethod['display_position'] as $key => $position) { |
|
| 133 | - if ( $position != null) { |
|
| 132 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 133 | + if ($position != null) { |
|
| 134 | 134 | $position_determinated = true; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ( $position_determinated ) { |
|
| 138 | - for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) { |
|
| 139 | - foreach ( $paymentMethod['display_position'] as $key => $position ) { |
|
| 140 | - if ( $position == $i && !empty($paymentMethod[$key])) { |
|
| 137 | + if ($position_determinated) { |
|
| 138 | + for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) { |
|
| 139 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 140 | + if ($position == $i && !empty($paymentMethod[$key])) { |
|
| 141 | 141 | if ($key == 'checks') { |
| 142 | 142 | $key = 'check'; |
| 143 | 143 | } |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | $payment_methods = $payment_method_table; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | - if (!empty($payment_methods) ) { |
|
| 151 | + if (!empty($payment_methods)) { |
|
| 152 | 152 | |
| 153 | - foreach( $payment_methods as $payment_method_identifier => $payment_method_def ) { |
|
| 153 | + foreach ($payment_methods as $payment_method_identifier => $payment_method_def) { |
|
| 154 | 154 | $tpl_component = array(); |
| 155 | 155 | $checked = $active = ''; |
| 156 | 156 | $payment_identifier_for_test = $payment_method_identifier; |
| 157 | 157 | if ($payment_method_identifier == 'check') { |
| 158 | 158 | $payment_identifier_for_test = 'checks'; |
| 159 | 159 | } |
| 160 | - if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 160 | + if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 161 | 161 | $checked = ' checked="checked"'; |
| 162 | 162 | $active = ' active'; |
| 163 | 163 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active; |
| 166 | 166 | $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked; |
| 167 | 167 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier; |
| 168 | - if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) { |
|
| 169 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : ''; |
|
| 168 | + if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) { |
|
| 169 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : ''; |
|
| 170 | 170 | } |
| 171 | 171 | else { |
| 172 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : ''; |
|
| 172 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : ''; |
|
| 173 | 173 | } |
| 174 | 174 | //$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon']; |
| 175 | 175 | $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name']; |
@@ -180,32 +180,32 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return array( $output, $paymentMethod['mode'] ); |
|
| 183 | + return array($output, $paymentMethod['mode']); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
| 187 | - public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 188 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 187 | + public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 188 | + $payment_option = get_option('wps_payment_mode'); |
|
| 189 | 189 | $output = ''; |
| 190 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 190 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 192 | 192 | } |
| 193 | - if( $cart_type == 'cart' ) { |
|
| 194 | - if ( !empty($payment_option) && !empty($payment_option['mode']) ) { |
|
| 195 | - foreach( $payment_option['mode'] as $payment_id => $payment_config ) { |
|
| 196 | - if( !empty($payment_config['active']) ) { |
|
| 197 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : ''); |
|
| 198 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : ''); |
|
| 193 | + if ($cart_type == 'cart') { |
|
| 194 | + if (!empty($payment_option) && !empty($payment_option['mode'])) { |
|
| 195 | + foreach ($payment_option['mode'] as $payment_id => $payment_config) { |
|
| 196 | + if (!empty($payment_config['active'])) { |
|
| 197 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : ''); |
|
| 198 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : ''); |
|
| 199 | 199 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id; |
| 200 | 200 | |
| 201 | - if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) { |
|
| 202 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : ''; |
|
| 201 | + if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) { |
|
| 202 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : ''; |
|
| 203 | 203 | } |
| 204 | 204 | else { |
| 205 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : ''; |
|
| 205 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : ''; |
|
| 206 | 206 | } |
| 207 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : ''; |
|
| 208 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : ''; |
|
| 207 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : ''; |
|
| 208 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : ''; |
|
| 209 | 209 | $output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id)); |
| 210 | 210 | unset($tpl_component); |
| 211 | 211 | } |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $wps_message = new wps_message_ctr(); |
| 229 | 229 | |
| 230 | - if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | - $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' ); |
|
| 232 | - $first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 233 | - $last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 230 | + if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | + $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : ''); |
|
| 232 | + $first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 233 | + $last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 234 | 234 | |
| 235 | 235 | // Envoie du message de confirmation de paiement au client |
| 236 | - switch($order['payment_method']) { |
|
| 236 | + switch ($order['payment_method']) { |
|
| 237 | 237 | case 'check': |
| 238 | 238 | $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date'])); |
| 239 | 239 | break; |
@@ -250,24 +250,24 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| 253 | - function setOrderPaymentStatus( $order_id, $payment_status ) { |
|
| 253 | + function setOrderPaymentStatus($order_id, $payment_status) { |
|
| 254 | 254 | /** Get order main information */ |
| 255 | 255 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 256 | 256 | $send_email = false; |
| 257 | 257 | |
| 258 | - if ( !empty($order) ) { |
|
| 258 | + if (!empty($order)) { |
|
| 259 | 259 | /** Change order status to given status */ |
| 260 | 260 | $order['order_status'] = strtolower($payment_status); |
| 261 | 261 | /** Put order status into a single meta, allowing to use it easily later */ |
| 262 | 262 | update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); |
| 263 | 263 | |
| 264 | 264 | /** In case the set status is completed, make specific treatment: add the completed date */ |
| 265 | - if ( $payment_status == 'completed' ) { |
|
| 265 | + if ($payment_status == 'completed') { |
|
| 266 | 266 | /** Read order items list, if not empty and check if each item is set to manage stock or not */ |
| 267 | 267 | if (!empty($order['order_items'])) { |
| 268 | 268 | foreach ($order['order_items'] as $o) { |
| 269 | - $product = wpshop_products::get_product_data( $o['item_id'] ); |
|
| 270 | - if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) { |
|
| 269 | + $product = wpshop_products::get_product_data($o['item_id']); |
|
| 270 | + if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) { |
|
| 271 | 271 | wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** Send email to customer when specific case need it */ |
| 284 | - if ( $send_email ) { |
|
| 284 | + if ($send_email) { |
|
| 285 | 285 | /** Get information about customer that make the order */ |
| 286 | 286 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 287 | 287 | $mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']); |
@@ -295,25 +295,25 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * Get payment method |
| 297 | 297 | */ |
| 298 | - function get_payment_method($post_id){ |
|
| 299 | - $pm = __('Nc','wpshop'); |
|
| 298 | + function get_payment_method($post_id) { |
|
| 299 | + $pm = __('Nc', 'wpshop'); |
|
| 300 | 300 | $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
| 301 | - if ( !empty($order_postmeta['payment_method']) ) { |
|
| 302 | - switch($order_postmeta['payment_method']){ |
|
| 301 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 302 | + switch ($order_postmeta['payment_method']) { |
|
| 303 | 303 | case 'check': |
| 304 | - $pm = __('Check','wpshop'); |
|
| 304 | + $pm = __('Check', 'wpshop'); |
|
| 305 | 305 | break; |
| 306 | 306 | case 'paypal': |
| 307 | - $pm = __('Paypal','wpshop'); |
|
| 307 | + $pm = __('Paypal', 'wpshop'); |
|
| 308 | 308 | break; |
| 309 | 309 | case 'banktransfer': |
| 310 | - $pm = __('Bank transfer','wpshop'); |
|
| 310 | + $pm = __('Bank transfer', 'wpshop'); |
|
| 311 | 311 | break; |
| 312 | 312 | case 'cic': |
| 313 | - $pm = __('Credit card','wpshop'); |
|
| 313 | + $pm = __('Credit card', 'wpshop'); |
|
| 314 | 314 | break; |
| 315 | 315 | default: |
| 316 | - $pm = __('Nc','wpshop'); |
|
| 316 | + $pm = __('Nc', 'wpshop'); |
|
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -333,38 +333,38 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $paymentMethod = $paymentMethod['mode']; |
| 335 | 335 | $payment_validation .= ' |
| 336 | -<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" > |
|
| 337 | - <input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | - <input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 336 | +<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" > |
|
| 337 | + <input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | + <input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 339 | 339 | |
| 340 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 340 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 341 | 341 | $payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>'; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 344 | + if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 345 | 345 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>'; |
| 346 | 346 | $display_button = true; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 349 | + if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 350 | 350 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>'; |
| 351 | 351 | $display_button = true; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 355 | - if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) { |
|
| 354 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 355 | + if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) { |
|
| 356 | 356 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>'; |
| 357 | 357 | $display_button = true; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if(empty($payment_transaction)){ |
|
| 361 | - $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />'; |
|
| 360 | + if (empty($payment_transaction)) { |
|
| 361 | + $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />'; |
|
| 362 | 362 | $display_button = true; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if($display_button){ |
|
| 365 | + if ($display_button) { |
|
| 366 | 366 | $payment_validation .= ' |
| 367 | - <br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>'; |
|
| 367 | + <br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>'; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $payment_validation .= ' |
@@ -379,21 +379,21 @@ discard block |
||
| 379 | 379 | * @param float $current_order_total The current order total to pay before partial amount calcul |
| 380 | 380 | * @return array The amount to pay / A html output with amount to pay and different information |
| 381 | 381 | */ |
| 382 | - function partial_payment_calcul( $current_order_total, $for = 'for_all' ) { |
|
| 382 | + function partial_payment_calcul($current_order_total, $for = 'for_all') { |
|
| 383 | 383 | $output = ''; |
| 384 | 384 | $tpl_component = array(); |
| 385 | 385 | |
| 386 | 386 | /** Get current configuration */ |
| 387 | 387 | $partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array())); |
| 388 | - if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) { |
|
| 388 | + if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) { |
|
| 389 | 389 | $amount_of_partial_payment = 0; |
| 390 | - if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) { |
|
| 390 | + if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) { |
|
| 391 | 391 | $amount_of_partial_payment = $partial_payment_configuration[$for]['value']; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $partial_amount_to_pay = 0; |
| 395 | 395 | $type_of_partial_payment = null; |
| 396 | - if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) { |
|
| 396 | + if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) { |
|
| 397 | 397 | switch ($partial_payment_configuration[$for]['type']) { |
| 398 | 398 | case 'percentage': |
| 399 | 399 | $type_of_partial_payment = '%'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | function set_payment_transaction_number($order_id, $transaction_number) { |
| 454 | 454 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 455 | 455 | |
| 456 | - if ( !empty($order_postmeta['order_payment']['received']) ) { |
|
| 456 | + if (!empty($order_postmeta['order_payment']['received'])) { |
|
| 457 | 457 | if (count($order_postmeta['order_payment']['received']) == 1) { |
| 458 | 458 | $order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number; |
| 459 | 459 | } |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | * |
| 468 | 468 | * @param integer $order_id |
| 469 | 469 | */ |
| 470 | - function save_payment_return_data( $order_id ) { |
|
| 470 | + function save_payment_return_data($order_id) { |
|
| 471 | 471 | $data = wpshop_tools::getMethode(); |
| 472 | 472 | |
| 473 | - $current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true); |
|
| 473 | + $current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true); |
|
| 474 | 474 | $current_payment_return[] = $data; |
| 475 | 475 | |
| 476 | 476 | update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return); |
@@ -484,23 +484,23 @@ discard block |
||
| 484 | 484 | * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount') |
| 485 | 485 | * @return array The order new meta informations |
| 486 | 486 | */ |
| 487 | - public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) { |
|
| 488 | - |
|
| 489 | - $order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null; |
|
| 490 | - $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null; |
|
| 491 | - $order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null; |
|
| 492 | - $order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id(); |
|
| 493 | - $order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null; |
|
| 494 | - $order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null; |
|
| 495 | - $order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null; |
|
| 487 | + public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) { |
|
| 488 | + |
|
| 489 | + $order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null; |
|
| 490 | + $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null; |
|
| 491 | + $order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null; |
|
| 492 | + $order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id(); |
|
| 493 | + $order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null; |
|
| 494 | + $order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null; |
|
| 495 | + $order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null; |
|
| 496 | 496 | $order_meta['order_payment']['received'][$payment_index]['comment'] = ''; |
| 497 | 497 | |
| 498 | 498 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 499 | - if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 499 | + if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 500 | 500 | |
| 501 | 501 | /** Generate an invoice number for the current payment. Check if the payment is complete or not */ |
| 502 | - if ( empty($order_meta['order_invoice_ref']) ) { |
|
| 503 | - $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 502 | + if (empty($order_meta['order_invoice_ref'])) { |
|
| 503 | + $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | * @param string $payment_method |
| 514 | 514 | * @return integer $key : array id of [order_payment][received] in the order postmeta |
| 515 | 515 | */ |
| 516 | - public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) { |
|
| 516 | + public static function get_order_waiting_payment_array_id($oid, $payment_method) { |
|
| 517 | 517 | $key = 0; |
| 518 | - $order_meta = get_post_meta( $oid, '_order_postmeta', true); |
|
| 519 | - if ( !empty($order_meta) ) { |
|
| 520 | - $key = count( $order_meta['order_payment']['received'] ); |
|
| 521 | - foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | - if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) { |
|
| 518 | + $order_meta = get_post_meta($oid, '_order_postmeta', true); |
|
| 519 | + if (!empty($order_meta)) { |
|
| 520 | + $key = count($order_meta['order_payment']['received']); |
|
| 521 | + foreach ($order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | + if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) { |
|
| 523 | 523 | $key = $k; |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -534,52 +534,52 @@ discard block |
||
| 534 | 534 | * @param array $params_array |
| 535 | 535 | * @return string |
| 536 | 536 | */ |
| 537 | - public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) { |
|
| 537 | + public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) { |
|
| 538 | 538 | global $wpshop_payment; global $wpdb; |
| 539 | - $order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true); |
|
| 539 | + $order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true); |
|
| 540 | 540 | |
| 541 | 541 | $wps_message = new wps_message_ctr(); |
| 542 | - if ( !empty($order_meta) ) { |
|
| 542 | + if (!empty($order_meta)) { |
|
| 543 | 543 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 544 | - $user_data = get_userdata( $order_meta['customer_id'] ); |
|
| 545 | - $email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : ''; |
|
| 544 | + $user_data = get_userdata($order_meta['customer_id']); |
|
| 545 | + $email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : ''; |
|
| 546 | 546 | // $email = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ; |
| 547 | - $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 548 | - $last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 547 | + $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 548 | + $last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 549 | 549 | |
| 550 | - $key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']); |
|
| 550 | + $key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']); |
|
| 551 | 551 | $order_grand_total = $order_meta['order_grand_total']; |
| 552 | - $total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 ); |
|
| 553 | - foreach ( $order_meta['order_payment']['received'] as $received ) { |
|
| 554 | - $total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 ); |
|
| 552 | + $total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0); |
|
| 553 | + foreach ($order_meta['order_payment']['received'] as $received) { |
|
| 554 | + $total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0); |
|
| 555 | 555 | } |
| 556 | 556 | $order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received; |
| 557 | - $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response ); |
|
| 557 | + $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response); |
|
| 558 | 558 | |
| 559 | 559 | if ($bank_response == 'completed') { |
| 560 | 560 | |
| 561 | - if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) { |
|
| 561 | + if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) { |
|
| 562 | 562 | $payment_status = 'completed'; |
| 563 | 563 | |
| 564 | - $order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : ( empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref'] ) ; |
|
| 564 | + $order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : (empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref']); |
|
| 565 | 565 | $order_meta['order_invoice_date'] = current_time('mysql', 0); |
| 566 | 566 | |
| 567 | 567 | if (!empty($order_meta['order_items'])) { |
| 568 | 568 | foreach ($order_meta['order_items'] as $item_id => $o) { |
| 569 | 569 | $pid = $o['item_id']; |
| 570 | - if (strpos($item_id,'__') !== false) { |
|
| 571 | - $product_data_id = explode( '__', $item_id ); |
|
| 572 | - $pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid; |
|
| 570 | + if (strpos($item_id, '__') !== false) { |
|
| 571 | + $product_data_id = explode('__', $item_id); |
|
| 572 | + $pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid; |
|
| 573 | 573 | } |
| 574 | - $product = wpshop_products::get_product_data( $pid ); |
|
| 575 | - if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 576 | - $parent_def = wpshop_products::get_parent_variation ( $pid ); |
|
| 574 | + $product = wpshop_products::get_product_data($pid); |
|
| 575 | + if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 576 | + $parent_def = wpshop_products::get_parent_variation($pid); |
|
| 577 | 577 | $parent_post = $parent_def['parent_post']; |
| 578 | - $product = wpshop_products::get_product_data( $parent_post->ID ); |
|
| 578 | + $product = wpshop_products::get_product_data($parent_post->ID); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) { |
|
| 582 | - wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid ); |
|
| 581 | + if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 582 | + wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -588,15 +588,15 @@ discard block |
||
| 588 | 588 | update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0)); |
| 589 | 589 | |
| 590 | 590 | // Send confirmation e-mail to administrator |
| 591 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 591 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 592 | 592 | $email_option = get_option('wpshop_emails'); |
| 593 | - if( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){ |
|
| 594 | - wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data ); |
|
| 593 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) { |
|
| 594 | + wpshop_checkout::send_order_email_to_administrator($order_id, $user_data); |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | // POS Status |
| 599 | - if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
|
| 599 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') { |
|
| 600 | 600 | $payment_status = 'pos'; |
| 601 | 601 | } |
| 602 | 602 | } |
@@ -605,27 +605,27 @@ discard block |
||
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | $order_meta['order_status'] = $payment_status; |
| 608 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 608 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 609 | 609 | $save_metadata = false; |
| 610 | 610 | |
| 611 | - $allow_send_invoice = get_option( 'wpshop_send_invoice' ); |
|
| 612 | - $invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, empty( $order_meta['order_payment']['received'][$key]['invoice_ref'] ) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : ''; |
|
| 611 | + $allow_send_invoice = get_option('wpshop_send_invoice'); |
|
| 612 | + $invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref']) : ''; |
|
| 613 | 613 | |
| 614 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 614 | + $email_option = get_option('wpshop_emails'); |
|
| 615 | 615 | |
| 616 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 617 | - $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'] : '' ); |
|
| 616 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 617 | + $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'] : ''); |
|
| 618 | 618 | |
| 619 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 620 | - $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']; |
|
| 619 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 620 | + $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']; |
|
| 621 | 621 | |
| 622 | - if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed' |
|
| 623 | - && ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) { |
|
| 624 | - $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 ) ); |
|
| 622 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' |
|
| 623 | + && (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) { |
|
| 624 | + $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)); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
|
| 628 | - $wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 627 | + if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) { |
|
| 628 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | else { |
@@ -634,15 +634,15 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | $order_meta['order_status'] = $payment_status; |
| 636 | 636 | |
| 637 | - if( !$save_metadata ) { |
|
| 637 | + if (!$save_metadata) { |
|
| 638 | 638 | return $order_meta; |
| 639 | 639 | } |
| 640 | 640 | else { |
| 641 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 641 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 642 | 642 | } |
| 643 | - update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
|
| 643 | + update_post_meta($order_id, '_wpshop_order_status', $payment_status); |
|
| 644 | 644 | } |
| 645 | - do_action( 'wps_after_check_order_payment_total_amount', $order_id ); |
|
| 645 | + do_action('wps_after_check_order_payment_total_amount', $order_id); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | /** |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | * @param integer $order_id The order identifier we want to get the old transaction reference for |
| 654 | 654 | * @return integer |
| 655 | 655 | */ |
| 656 | - public static function get_payment_transaction_number_old_way($order_id){ |
|
| 656 | + public static function get_payment_transaction_number_old_way($order_id) { |
|
| 657 | 657 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 658 | 658 | $transaction_indentifier = 0; |
| 659 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 660 | - switch($order_postmeta['payment_method']){ |
|
| 659 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 660 | + switch ($order_postmeta['payment_method']) { |
|
| 661 | 661 | case 'check': |
| 662 | 662 | $transaction_indentifier = get_post_meta($order_id, '_order_check_number', true); |
| 663 | 663 | break; |
@@ -676,26 +676,26 @@ discard block |
||
| 676 | 676 | return $transaction_indentifier; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - public static function reverify_payment_invoice_ref( $order_id, $index_payment ) { |
|
| 679 | + public static function reverify_payment_invoice_ref($order_id, $index_payment) { |
|
| 680 | 680 | $status = false; |
| 681 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 682 | - if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) { |
|
| 681 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 682 | + if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) { |
|
| 683 | 683 | $order_invoice = $invoice_ref = false; |
| 684 | 684 | |
| 685 | - end( $order_meta['order_payment']['received'] ); |
|
| 686 | - $last_payment = key( $order_meta['order_payment']['received'] ); |
|
| 687 | - if( $last_payment == $index_payment ) { |
|
| 685 | + end($order_meta['order_payment']['received']); |
|
| 686 | + $last_payment = key($order_meta['order_payment']['received']); |
|
| 687 | + if ($last_payment == $index_payment) { |
|
| 688 | 688 | $payments = 0; |
| 689 | - foreach( $order_meta['order_payment']['received'] as $payment ) { |
|
| 690 | - $payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0; |
|
| 689 | + foreach ($order_meta['order_payment']['received'] as $payment) { |
|
| 690 | + $payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0; |
|
| 691 | 691 | } |
| 692 | - if( $order_meta['order_grand_total'] <= $payments ) { |
|
| 693 | - if( $order_meta['order_status'] == 'partially_paid' ) { |
|
| 694 | - $order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
| 692 | + if ($order_meta['order_grand_total'] <= $payments) { |
|
| 693 | + if ($order_meta['order_status'] == 'partially_paid') { |
|
| 694 | + $order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
| 695 | 695 | $order_meta['order_status'] = 'completed'; |
| 696 | - $status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' ); |
|
| 696 | + $status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed'); |
|
| 697 | 697 | } |
| 698 | - if( !empty( $order_meta['order_invoice_ref'] ) ) { |
|
| 698 | + if (!empty($order_meta['order_invoice_ref'])) { |
|
| 699 | 699 | $invoice_ref = $order_meta['order_invoice_ref']; |
| 700 | 700 | $status = true; |
| 701 | 701 | } else { |
@@ -706,16 +706,16 @@ discard block |
||
| 706 | 706 | $status = true; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if( $status ) { |
|
| 710 | - if( empty( $invoice_ref ) ) { |
|
| 711 | - $invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 712 | - if( $order_invoice ) { |
|
| 709 | + if ($status) { |
|
| 710 | + if (empty($invoice_ref)) { |
|
| 711 | + $invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 712 | + if ($order_invoice) { |
|
| 713 | 713 | $order_meta['order_invoice_ref'] = $invoice_ref; |
| 714 | 714 | } |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref; |
| 718 | - $status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 718 | + $status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | return $status; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -40,9 +42,11 @@ discard block |
||
| 40 | 42 | |
| 41 | 43 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 44 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | - if($interoguation_marker_pos===false) |
|
| 44 | - return $url.'?'.$param.'='.$value; |
|
| 45 | - else return $url.'&'.$param.'='.$value; |
|
| 45 | + if($interoguation_marker_pos===false) { |
|
| 46 | + return $url.'?'.$param.'='.$value; |
|
| 47 | + } else { |
|
| 48 | + return $url.'&'.$param.'='.$value; |
|
| 49 | + } |
|
| 46 | 50 | } |
| 47 | 51 | |
| 48 | 52 | /** |
@@ -167,8 +171,7 @@ discard block |
||
| 167 | 171 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier; |
| 168 | 172 | if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) { |
| 169 | 173 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : ''; |
| 170 | - } |
|
| 171 | - else { |
|
| 174 | + } else { |
|
| 172 | 175 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : ''; |
| 173 | 176 | } |
| 174 | 177 | //$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon']; |
@@ -200,8 +203,7 @@ discard block |
||
| 200 | 203 | |
| 201 | 204 | if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) { |
| 202 | 205 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : ''; |
| 203 | - } |
|
| 204 | - else { |
|
| 206 | + } else { |
|
| 205 | 207 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : ''; |
| 206 | 208 | } |
| 207 | 209 | $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : ''; |
@@ -599,8 +601,7 @@ discard block |
||
| 599 | 601 | if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
| 600 | 602 | $payment_status = 'pos'; |
| 601 | 603 | } |
| 602 | - } |
|
| 603 | - else { |
|
| 604 | + } else { |
|
| 604 | 605 | $payment_status = 'partially_paid'; |
| 605 | 606 | } |
| 606 | 607 | |
@@ -627,8 +628,7 @@ discard block |
||
| 627 | 628 | if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
| 628 | 629 | $wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
| 629 | 630 | } |
| 630 | - } |
|
| 631 | - else { |
|
| 631 | + } else { |
|
| 632 | 632 | $payment_status = $bank_response; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -636,8 +636,7 @@ discard block |
||
| 636 | 636 | |
| 637 | 637 | if( !$save_metadata ) { |
| 638 | 638 | return $order_meta; |
| 639 | - } |
|
| 640 | - else { |
|
| 639 | + } else { |
|
| 641 | 640 | update_post_meta( $order_id, '_order_postmeta', $order_meta); |
| 642 | 641 | } |
| 643 | 642 | update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
@@ -9,41 +9,41 @@ discard block |
||
| 9 | 9 | * @version 1.4.4.3 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if (!defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | ?> |
| 16 | -<?php if ( ! empty( $signup_form_section ) ) : ?> |
|
| 17 | - <?php foreach ( $signup_form_section as $signup_section_name => $signup_fields ) : ?> |
|
| 18 | - <span class="wps-h4"><?php echo esc_html( $signup_section_name, 'wpshop' ); ?></span> |
|
| 16 | +<?php if (!empty($signup_form_section)) : ?> |
|
| 17 | + <?php foreach ($signup_form_section as $signup_section_name => $signup_fields) : ?> |
|
| 18 | + <span class="wps-h4"><?php echo esc_html($signup_section_name, 'wpshop'); ?></span> |
|
| 19 | 19 | <div class="customer-account-detail-group" > |
| 20 | - <?php foreach ( $signup_fields as $signup_field ) : ?> |
|
| 20 | + <?php foreach ($signup_fields as $signup_field) : ?> |
|
| 21 | 21 | <?php |
| 22 | - if ( isset( $signup_field->code ) && ( 'is_provider' === $signup_field->code ) ) : |
|
| 22 | + if (isset($signup_field->code) && ('is_provider' === $signup_field->code)) : |
|
| 23 | 23 | continue; |
| 24 | 24 | endif; |
| 25 | - $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.strtolower($signup_field->data_type). ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_type_id, $signup_field->id, $cid ); |
|
| 26 | - $value = $wpdb->get_var( $query ); |
|
| 27 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $signup_field, $value, array( 'from' => 'frontend', array( 'options' => array( 'original' => true, ), ) ) ); |
|
| 25 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($signup_field->data_type) . ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_type_id, $signup_field->id, $cid); |
|
| 26 | + $value = $wpdb->get_var($query); |
|
| 27 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($signup_field, $value, array('from' => 'frontend', array('options' => array('original' => true,),))); |
|
| 28 | 28 | ?> |
| 29 | 29 | <div class="wps-form-group"> |
| 30 | - <label for="<?php echo esc_attr( $signup_field->code ); ?>"><?php _e( stripslashes($signup_field->frontend_label), 'wpshop'); ?> <?php echo ( ( !empty($attribute_output_def['required']) && $attribute_output_def['required'] == 'yes' ) ? '<em>*</em>' : '' ); ?></label> |
|
| 31 | - <div id="<?php echo esc_attr( $signup_field->code ); ?>" class="wps-form"><?php |
|
| 32 | - echo ( $attribute_output_def['output'] ); // WPCS: XSS ok. |
|
| 33 | - echo ( $attribute_output_def['options'] ); // WPCS: XSS ok. |
|
| 30 | + <label for="<?php echo esc_attr($signup_field->code); ?>"><?php _e(stripslashes($signup_field->frontend_label), 'wpshop'); ?> <?php echo ((!empty($attribute_output_def['required']) && $attribute_output_def['required'] == 'yes') ? '<em>*</em>' : ''); ?></label> |
|
| 31 | + <div id="<?php echo esc_attr($signup_field->code); ?>" class="wps-form"><?php |
|
| 32 | + echo ($attribute_output_def['output']); // WPCS: XSS ok. |
|
| 33 | + echo ($attribute_output_def['options']); // WPCS: XSS ok. |
|
| 34 | 34 | ?></div> |
| 35 | 35 | </div> |
| 36 | 36 | <?php |
| 37 | 37 | /** Check confirmation field **/ |
| 38 | - if ( 'yes' === $signup_field->_need_verification ) : |
|
| 38 | + if ('yes' === $signup_field->_need_verification) : |
|
| 39 | 39 | $signup_field->code = $signup_field->code . '2'; |
| 40 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $signup_field, $value, array( 'from' => 'frontend' ) ); |
|
| 40 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($signup_field, $value, array('from' => 'frontend')); |
|
| 41 | 41 | ?> |
| 42 | 42 | <div class="wps-form-group"> |
| 43 | - <label for="<?php echo esc_attr( $signup_field->code ); ?>"><?php printf( __('Confirm %s', 'wpshop'), stripslashes( strtolower(__( $signup_field->frontend_label, 'wpshop')) ) ); ?> <?php echo ( ( !empty($attribute_output_def['required']) && $attribute_output_def['required'] == 'yes' ) ? '<em>*</em>' : '' ); ?></label> |
|
| 44 | - <div id="<?php echo esc_attr( $signup_field->code ); ?>" class="wps-form"><?php |
|
| 45 | - echo ( $attribute_output_def['output'] ); |
|
| 46 | - echo ( $attribute_output_def['options'] ); |
|
| 43 | + <label for="<?php echo esc_attr($signup_field->code); ?>"><?php printf(__('Confirm %s', 'wpshop'), stripslashes(strtolower(__($signup_field->frontend_label, 'wpshop')))); ?> <?php echo ((!empty($attribute_output_def['required']) && $attribute_output_def['required'] == 'yes') ? '<em>*</em>' : ''); ?></label> |
|
| 44 | + <div id="<?php echo esc_attr($signup_field->code); ?>" class="wps-form"><?php |
|
| 45 | + echo ($attribute_output_def['output']); |
|
| 46 | + echo ($attribute_output_def['options']); |
|
| 47 | 47 | ?></div> |
| 48 | 48 | </div> |
| 49 | 49 | <?php endif; ?> |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | <?php endif; |
| 54 | 54 | $content = ''; |
| 55 | 55 | ob_start(); |
| 56 | -do_action( 'signup_extra_fields' ); |
|
| 56 | +do_action('signup_extra_fields'); |
|
| 57 | 57 | $content = ob_get_clean(); |
| 58 | -if ( ! empty( $content ) ) { |
|
| 58 | +if (!empty($content)) { |
|
| 59 | 59 | ?> |
| 60 | 60 | <div class="wps-form-group"> |
| 61 | 61 | <?php echo $content; ?> |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @subpackage Customer |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -29,32 +29,32 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function __construct() { |
| 31 | 31 | /** Create customer entity type on wordpress initilisation */ |
| 32 | - add_action( 'init', array( $this, 'create_customer_entity' ) ); |
|
| 32 | + add_action('init', array($this, 'create_customer_entity')); |
|
| 33 | 33 | |
| 34 | 34 | // Redirection vers la page d'édition d'un utilisateur après sa création. |
| 35 | - add_filter( 'wp_redirect', array( $this, 'wp_redirect_after_user_new' ), 1 ); |
|
| 35 | + add_filter('wp_redirect', array($this, 'wp_redirect_after_user_new'), 1); |
|
| 36 | 36 | |
| 37 | - add_filter( 'wp_redirect', array( $this, 'wp_redirect_after_user_new' ), 1 ); |
|
| 37 | + add_filter('wp_redirect', array($this, 'wp_redirect_after_user_new'), 1); |
|
| 38 | 38 | |
| 39 | 39 | /** When a wordpress user is created, create a customer (post type) */ |
| 40 | - add_action( 'user_register', array( $this, 'create_entity_customer_when_user_is_created' ) ); |
|
| 41 | - add_action( 'edit_user_profile_update', array( $this, 'update_entity_customer_when_profile_user_is_update' ) ); |
|
| 40 | + add_action('user_register', array($this, 'create_entity_customer_when_user_is_created')); |
|
| 41 | + add_action('edit_user_profile_update', array($this, 'update_entity_customer_when_profile_user_is_update')); |
|
| 42 | 42 | |
| 43 | 43 | /** Add filters for customer list */ |
| 44 | - add_filter( 'bulk_actions-edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array( $this, 'customer_list_table_bulk_actions' ) ); |
|
| 45 | - add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_columns', array( $this, 'list_table_header' ) ); |
|
| 46 | - add_action( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_posts_custom_column', array( $this, 'list_table_column_content' ), 10, 2 ); |
|
| 47 | - add_action( 'restrict_manage_posts', array( &$this, 'list_table_filters' ) ); |
|
| 48 | - add_filter( 'parse_query', array( &$this, 'list_table_filter_parse_query' ) ); |
|
| 44 | + add_filter('bulk_actions-edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array($this, 'customer_list_table_bulk_actions')); |
|
| 45 | + add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_columns', array($this, 'list_table_header')); |
|
| 46 | + add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_posts_custom_column', array($this, 'list_table_column_content'), 10, 2); |
|
| 47 | + add_action('restrict_manage_posts', array(&$this, 'list_table_filters')); |
|
| 48 | + add_filter('parse_query', array(&$this, 'list_table_filter_parse_query')); |
|
| 49 | 49 | |
| 50 | 50 | /** Filter search for customers */ |
| 51 | 51 | //add_filter( 'pre_get_posts', array( $this, 'customer_search' ) ); |
| 52 | 52 | |
| 53 | 53 | /** Customer options for the shop */ |
| 54 | - add_action( 'wsphop_options', array( &$this, 'declare_options' ), 8 ); |
|
| 55 | - add_action( 'wp_ajax_wps_customer_search', array( $this, 'ajax_search_customer' ) ); |
|
| 54 | + add_action('wsphop_options', array(&$this, 'declare_options'), 8); |
|
| 55 | + add_action('wp_ajax_wps_customer_search', array($this, 'ajax_search_customer')); |
|
| 56 | 56 | |
| 57 | - add_action( 'wp_login', array( $this, 'hook_login_for_setting_customer_id' ), 10, 2 ); |
|
| 57 | + add_action('wp_login', array($this, 'hook_login_for_setting_customer_id'), 10, 2); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string L'affichage de la lsite déroulanet contenant les clients de la boutique / THe select list of customers |
| 68 | 68 | */ |
| 69 | - public static function customer_select( $selected_user = 0, $multiple = false, $disabled = false ) { |
|
| 69 | + public static function customer_select($selected_user = 0, $multiple = false, $disabled = false) { |
|
| 70 | 70 | $content_output = ''; |
| 71 | 71 | |
| 72 | 72 | $wps_customer_mdl = new wps_customer_mdl(); |
| 73 | 73 | $customers = $wps_customer_mdl->get_customer_list( -1 ); |
| 74 | 74 | |
| 75 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common', 'customer', 'select' ) ); |
|
| 75 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common', 'customer', 'select')); |
|
| 76 | 76 | |
| 77 | 77 | return $content_output; |
| 78 | 78 | } |
@@ -83,26 +83,26 @@ discard block |
||
| 83 | 83 | * @param string $user_login le nom d'utilisateur de l'utilisateur actuellement connecté / Username of current connected user. |
| 84 | 84 | * @param WP_Object $user l'objet WP_User correspond à l'utilisateur actuellement connecté / Current connected user WP_Object definition. |
| 85 | 85 | */ |
| 86 | - public function hook_login_for_setting_customer_id( $user_login, $user ) { |
|
| 87 | - $customer_id = wps_customer_ctr::get_customer_id_by_author_id( $user->ID ); |
|
| 88 | - if ( empty( $customer_id ) ) { |
|
| 89 | - $query = $GLOBALS['wpdb']->prepare( "SELECT post_id FROM {$GLOBALS['wpdb']->postmeta} WHERE meta_key = %s AND meta_value LIKE %s ORDER BY meta_id LIMIT 1", '_wpscrm_associated_user', "%;i:$user->ID;%" ); |
|
| 90 | - $customer_id = $GLOBALS['wpdb']->get_var( $query ); |
|
| 86 | + public function hook_login_for_setting_customer_id($user_login, $user) { |
|
| 87 | + $customer_id = wps_customer_ctr::get_customer_id_by_author_id($user->ID); |
|
| 88 | + if (empty($customer_id)) { |
|
| 89 | + $query = $GLOBALS['wpdb']->prepare("SELECT post_id FROM {$GLOBALS['wpdb']->postmeta} WHERE meta_key = %s AND meta_value LIKE %s ORDER BY meta_id LIMIT 1", '_wpscrm_associated_user', "%;i:$user->ID;%"); |
|
| 90 | + $customer_id = $GLOBALS['wpdb']->get_var($query); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - setcookie( 'wps_current_connected_customer', $customer_id, strtotime( '+30 days' ), SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl() ); |
|
| 93 | + setcookie('wps_current_connected_customer', $customer_id, strtotime('+30 days'), SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl()); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * AJAX callback for customer search |
| 98 | 98 | */ |
| 99 | 99 | public function ajax_search_customer() { |
| 100 | - check_ajax_referer( 'wps_customer_search' ); |
|
| 100 | + check_ajax_referer('wps_customer_search'); |
|
| 101 | 101 | |
| 102 | - $term = ! empty( $_GET ) && ! empty( $_GET['term'] ) && is_string( (string) $_GET['term'] ) ? (string) $_GET['term'] : $term; |
|
| 103 | - $list = $this->search_customer( $term ); |
|
| 102 | + $term = !empty($_GET) && !empty($_GET['term']) && is_string((string)$_GET['term']) ? (string)$_GET['term'] : $term; |
|
| 103 | + $list = $this->search_customer($term); |
|
| 104 | 104 | |
| 105 | - wp_die( wp_json_encode( $list ) ); |
|
| 105 | + wp_die(wp_json_encode($list)); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -110,23 +110,23 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param string $term The term we have to search into database for getting existing users / Le terme qu'il faut rechercher pour retrouver les utilisateurs dans la base de données. |
| 112 | 112 | */ |
| 113 | - public function search_customer( $term ) { |
|
| 113 | + public function search_customer($term) { |
|
| 114 | 114 | $users = array(); |
| 115 | - $search_users = new WP_User_Query( array( |
|
| 116 | - 'search' => '*' . esc_attr( $term ) . '*', |
|
| 117 | - 'search_columns' => array( 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name' ), |
|
| 118 | - ) ); |
|
| 115 | + $search_users = new WP_User_Query(array( |
|
| 116 | + 'search' => '*' . esc_attr($term) . '*', |
|
| 117 | + 'search_columns' => array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name'), |
|
| 118 | + )); |
|
| 119 | 119 | $user_query_results = $search_users->get_results(); |
| 120 | - if ( ! empty( $user_query_results ) ) { |
|
| 121 | - foreach ( $user_query_results as $user ) { |
|
| 122 | - $users[ $user->ID ]['id'] = $user->ID; |
|
| 123 | - $users[ $user->ID ]['display_name'] = $user->display_name; |
|
| 124 | - $users[ $user->ID ]['email'] = $user->user_email; |
|
| 125 | - $users[ $user->ID ]['last_name'] = $user->last_name; |
|
| 126 | - $users[ $user->ID ]['first_name'] = $user->first_name; |
|
| 120 | + if (!empty($user_query_results)) { |
|
| 121 | + foreach ($user_query_results as $user) { |
|
| 122 | + $users[$user->ID]['id'] = $user->ID; |
|
| 123 | + $users[$user->ID]['display_name'] = $user->display_name; |
|
| 124 | + $users[$user->ID]['email'] = $user->user_email; |
|
| 125 | + $users[$user->ID]['last_name'] = $user->last_name; |
|
| 126 | + $users[$user->ID]['first_name'] = $user->first_name; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - $search_users_in_meta = new WP_User_Query( array( |
|
| 129 | + $search_users_in_meta = new WP_User_Query(array( |
|
| 130 | 130 | 'meta_query' => array( |
| 131 | 131 | 'relation' => 'OR', |
| 132 | 132 | array( |
@@ -140,21 +140,21 @@ discard block |
||
| 140 | 140 | 'compare' => 'LIKE', |
| 141 | 141 | ), |
| 142 | 142 | ), |
| 143 | - ) ); |
|
| 143 | + )); |
|
| 144 | 144 | $user_query_results_2 = $search_users_in_meta->get_results(); |
| 145 | - if ( ! empty( $user_query_results_2 ) ) { |
|
| 146 | - foreach ( $user_query_results_2 as $user ) { |
|
| 147 | - $users[ $user->ID ]['id'] = $user->ID; |
|
| 148 | - $users[ $user->ID ]['display_name'] = $user->display_name; |
|
| 149 | - $users[ $user->ID ]['email'] = $user->user_email; |
|
| 150 | - $users[ $user->ID ]['last_name'] = $user->last_name; |
|
| 151 | - $users[ $user->ID ]['first_name'] = $user->first_name; |
|
| 145 | + if (!empty($user_query_results_2)) { |
|
| 146 | + foreach ($user_query_results_2 as $user) { |
|
| 147 | + $users[$user->ID]['id'] = $user->ID; |
|
| 148 | + $users[$user->ID]['display_name'] = $user->display_name; |
|
| 149 | + $users[$user->ID]['email'] = $user->user_email; |
|
| 150 | + $users[$user->ID]['last_name'] = $user->last_name; |
|
| 151 | + $users[$user->ID]['first_name'] = $user->first_name; |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | - if ( empty( $users ) ) { |
|
| 154 | + if (empty($users)) { |
|
| 155 | 155 | $users[] = array( |
| 156 | 156 | 'id' => null, |
| 157 | - 'label' => __( 'Create a new user', 'wpshop' ), |
|
| 157 | + 'label' => __('Create a new user', 'wpshop'), |
|
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return int $customer_id |
| 170 | 170 | */ |
| 171 | - public static function get_customer_id_by_author_id( $author_id ) { |
|
| 172 | - if ( ! isset( self::$customer_user_identifier_cache[ $author_id ] ) ) { |
|
| 173 | - $query = $GLOBALS['wpdb']->prepare( "SELECT ID FROM {$GLOBALS['wpdb']->posts} WHERE post_author = %d AND post_type = %s ORDER BY ID ASC", $author_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 174 | - self::$customer_user_identifier_cache[ $author_id ] = $GLOBALS['wpdb']->get_var( $query ); |
|
| 171 | + public static function get_customer_id_by_author_id($author_id) { |
|
| 172 | + if (!isset(self::$customer_user_identifier_cache[$author_id])) { |
|
| 173 | + $query = $GLOBALS['wpdb']->prepare("SELECT ID FROM {$GLOBALS['wpdb']->posts} WHERE post_author = %d AND post_type = %s ORDER BY ID ASC", $author_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 174 | + self::$customer_user_identifier_cache[$author_id] = $GLOBALS['wpdb']->get_var($query); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - return self::$customer_user_identifier_cache[ $author_id ]; |
|
| 177 | + return self::$customer_user_identifier_cache[$author_id]; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return int |
| 187 | 187 | */ |
| 188 | - public static function get_author_id_by_customer_id( $customer_id ) { |
|
| 189 | - $flipped = ! empty( self::$customer_user_identifier_cache ) ? array_flip( self::$customer_user_identifier_cache ) : ''; |
|
| 190 | - if ( ! isset( $flipped[ $customer_id ] ) ) { |
|
| 191 | - $author_id = $GLOBALS['wpdb']->get_var( $GLOBALS['wpdb']->prepare( "SELECT post_author FROM {$GLOBALS['wpdb']->posts} WHERE ID = %d", $customer_id ) ); |
|
| 192 | - self::$customer_user_identifier_cache[ $author_id ] = $customer_id; |
|
| 193 | - $flipped[ $customer_id ] = $author_id; |
|
| 188 | + public static function get_author_id_by_customer_id($customer_id) { |
|
| 189 | + $flipped = !empty(self::$customer_user_identifier_cache) ? array_flip(self::$customer_user_identifier_cache) : ''; |
|
| 190 | + if (!isset($flipped[$customer_id])) { |
|
| 191 | + $author_id = $GLOBALS['wpdb']->get_var($GLOBALS['wpdb']->prepare("SELECT post_author FROM {$GLOBALS['wpdb']->posts} WHERE ID = %d", $customer_id)); |
|
| 192 | + self::$customer_user_identifier_cache[$author_id] = $customer_id; |
|
| 193 | + $flipped[$customer_id] = $author_id; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - return $flipped[ $customer_id ]; |
|
| 196 | + return $flipped[$customer_id]; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -201,26 +201,26 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function create_customer_entity() { |
| 203 | 203 | global $wpdb; |
| 204 | - $query = $wpdb->prepare( "SELECT P.post_title, PM.meta_value FROM {$wpdb->posts} AS P INNER JOIN {$wpdb->postmeta} AS PM ON (PM.post_id = P.ID) WHERE P.post_name = %s AND PM.meta_key = %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, '_wpshop_entity_params' ); |
|
| 205 | - $customer_entity_definition = $wpdb->get_row( $query ); // WPCS: unprepared sql ok. |
|
| 206 | - $current_entity_params = ! empty( $customer_entity_definition ) && ! empty( $customer_entity_definition->meta_value ) ? unserialize( $customer_entity_definition->meta_value ) : null; |
|
| 204 | + $query = $wpdb->prepare("SELECT P.post_title, PM.meta_value FROM {$wpdb->posts} AS P INNER JOIN {$wpdb->postmeta} AS PM ON (PM.post_id = P.ID) WHERE P.post_name = %s AND PM.meta_key = %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, '_wpshop_entity_params'); |
|
| 205 | + $customer_entity_definition = $wpdb->get_row($query); // WPCS: unprepared sql ok. |
|
| 206 | + $current_entity_params = !empty($customer_entity_definition) && !empty($customer_entity_definition->meta_value) ? unserialize($customer_entity_definition->meta_value) : null; |
|
| 207 | 207 | |
| 208 | 208 | $post_type_params = array( |
| 209 | 209 | 'labels' => array( |
| 210 | - 'name' => __( 'Customers', 'wpshop' ), |
|
| 211 | - 'singular_name' => __( 'Customer', 'wpshop' ), |
|
| 212 | - 'add_new_item' => __( 'New customer', 'wpshop' ), |
|
| 213 | - 'add_new' => __( 'New customer', 'wpshop' ), |
|
| 214 | - 'edit_item' => __( 'Edit customer', 'wpshop' ), |
|
| 215 | - 'new_item' => __( 'New customer', 'wpshop' ), |
|
| 216 | - 'view_item' => __( 'View customer', 'wpshop' ), |
|
| 217 | - 'search_items' => __( 'Search in customers', 'wpshop' ), |
|
| 218 | - 'not_found' => __( 'No customer found', 'wpshop' ), |
|
| 219 | - 'not_found_in_trash' => __( 'No customer founded in trash', 'wpshop' ), |
|
| 210 | + 'name' => __('Customers', 'wpshop'), |
|
| 211 | + 'singular_name' => __('Customer', 'wpshop'), |
|
| 212 | + 'add_new_item' => __('New customer', 'wpshop'), |
|
| 213 | + 'add_new' => __('New customer', 'wpshop'), |
|
| 214 | + 'edit_item' => __('Edit customer', 'wpshop'), |
|
| 215 | + 'new_item' => __('New customer', 'wpshop'), |
|
| 216 | + 'view_item' => __('View customer', 'wpshop'), |
|
| 217 | + 'search_items' => __('Search in customers', 'wpshop'), |
|
| 218 | + 'not_found' => __('No customer found', 'wpshop'), |
|
| 219 | + 'not_found_in_trash' => __('No customer founded in trash', 'wpshop'), |
|
| 220 | 220 | 'parent_item_colon' => '', |
| 221 | 221 | ), |
| 222 | 222 | 'description' => '', |
| 223 | - 'supports' => ! empty( $current_entity_params['support'] ) ? $current_entity_params['support'] : array( 'title' ), |
|
| 223 | + 'supports' => !empty($current_entity_params['support']) ? $current_entity_params['support'] : array('title'), |
|
| 224 | 224 | 'hierarchical' => false, |
| 225 | 225 | 'public' => false, |
| 226 | 226 | 'show_ui' => true, |
@@ -245,22 +245,22 @@ discard block |
||
| 245 | 245 | ), |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $post_type_params ); |
|
| 248 | + register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $post_type_params); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * Customer options for the shop |
| 253 | 253 | */ |
| 254 | 254 | public static function declare_options() { |
| 255 | - if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) { |
|
| 256 | - $wpshop_shop_type = ! empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
|
| 257 | - $old_wpshop_shop_type = ! empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
|
| 255 | + if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') { |
|
| 256 | + $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
| 257 | + $old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : ''; |
|
| 258 | 258 | |
| 259 | - if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' ) |
|
| 260 | - && ( $old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation' ) ) { |
|
| 259 | + if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation') |
|
| 260 | + && ($old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation')) { |
|
| 261 | 261 | /** Add module option to wpshop general options */ |
| 262 | - register_setting( 'wpshop_options', 'wpshop_cart_option', array( 'wps_customer_ctr', 'wpshop_options_validate_customers_newsleters' ) ); |
|
| 263 | - add_settings_field( 'display_newsletters_subscriptions', __( 'Display newsletters subscriptions', 'wpshop' ), array( 'wps_customer_ctr', 'display_newsletters_subscriptions' ), 'wpshop_cart_info', 'wpshop_cart_info' ); |
|
| 262 | + register_setting('wpshop_options', 'wpshop_cart_option', array('wps_customer_ctr', 'wpshop_options_validate_customers_newsleters')); |
|
| 263 | + add_settings_field('display_newsletters_subscriptions', __('Display newsletters subscriptions', 'wpshop'), array('wps_customer_ctr', 'display_newsletters_subscriptions'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return array Les réglages des clients qui ont été vérifiés |
| 274 | 274 | */ |
| 275 | - public static function wpshop_options_validate_customers_newsleters( $input ) { |
|
| 275 | + public static function wpshop_options_validate_customers_newsleters($input) { |
|
| 276 | 276 | return $input; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * Affichage des champs permettant les réglages concernant les newsletters des clients dans les réglages de la boutique |
| 281 | 281 | */ |
| 282 | 282 | public static function display_newsletters_subscriptions() { |
| 283 | - $cart_option = get_option( 'wpshop_cart_option', array() ); |
|
| 283 | + $cart_option = get_option('wpshop_cart_option', array()); |
|
| 284 | 284 | $output = ''; |
| 285 | 285 | |
| 286 | 286 | $input_def = array(); |
@@ -288,18 +288,18 @@ discard block |
||
| 288 | 288 | $input_def['id'] = 'wpshop_cart_option_display_newsletter_site_subscription'; |
| 289 | 289 | $input_def['type'] = 'checkbox'; |
| 290 | 290 | $input_def['valueToPut'] = 'index'; |
| 291 | - $input_def['value'] = ! empty( $cart_option['display_newsletter']['site_subscription'] ) ? $cart_option['display_newsletter']['site_subscription'][0] : 'no'; |
|
| 291 | + $input_def['value'] = !empty($cart_option['display_newsletter']['site_subscription']) ? $cart_option['display_newsletter']['site_subscription'][0] : 'no'; |
|
| 292 | 292 | $input_def['possible_value'] = 'yes'; |
| 293 | - $output .= wpshop_form::check_input_type( $input_def, 'wpshop_cart_option[display_newsletter][site_subscription]' ) . '<label for="' . $input_def['id'] . '">' . __( 'Newsletters of the site', 'wpshop' ) . '</label><a href="#" title="' . __( 'Check this box if you want display newsletter site subscription', 'wpshop' ) . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
| 293 | + $output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[display_newsletter][site_subscription]') . '<label for="' . $input_def['id'] . '">' . __('Newsletters of the site', 'wpshop') . '</label><a href="#" title="' . __('Check this box if you want display newsletter site subscription', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
| 294 | 294 | |
| 295 | 295 | $input_def = array(); |
| 296 | 296 | $input_def['name'] = ''; |
| 297 | 297 | $input_def['id'] = 'wpshop_cart_option_display_newsletter_partner_subscription'; |
| 298 | 298 | $input_def['type'] = 'checkbox'; |
| 299 | 299 | $input_def['valueToPut'] = 'index'; |
| 300 | - $input_def['value'] = ! empty( $cart_option['display_newsletter']['partner_subscription'] ) ? $cart_option['display_newsletter']['partner_subscription'][0] : 'no'; |
|
| 300 | + $input_def['value'] = !empty($cart_option['display_newsletter']['partner_subscription']) ? $cart_option['display_newsletter']['partner_subscription'][0] : 'no'; |
|
| 301 | 301 | $input_def['possible_value'] = 'yes'; |
| 302 | - $output .= wpshop_form::check_input_type( $input_def, 'wpshop_cart_option[display_newsletter][partner_subscription]' ) . '<label for="' . $input_def['id'] . '">' . __( 'Newsletters of the partners', 'wpshop' ) . '</label><a href="#" title="' . __( 'Check this box if you want display newsletter partners subscription', 'wpshop' ) . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
| 302 | + $output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[display_newsletter][partner_subscription]') . '<label for="' . $input_def['id'] . '">' . __('Newsletters of the partners', 'wpshop') . '</label><a href="#" title="' . __('Check this box if you want display newsletter partners subscription', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
| 303 | 303 | |
| 304 | 304 | echo $output; // WPCS: XSS ok. |
| 305 | 305 | } |
@@ -313,15 +313,15 @@ discard block |
||
| 313 | 313 | * |
| 314 | 314 | * @return string La nouvelle url pour la redirection. |
| 315 | 315 | */ |
| 316 | - public function wp_redirect_after_user_new( $location ) { |
|
| 316 | + public function wp_redirect_after_user_new($location) { |
|
| 317 | 317 | global $pagenow; |
| 318 | 318 | |
| 319 | - if ( is_admin() && $pagenow === 'user-new.php' ) { |
|
| 320 | - $user_details = get_user_by( 'email', $_REQUEST[ 'email' ] ); |
|
| 319 | + if (is_admin() && $pagenow === 'user-new.php') { |
|
| 320 | + $user_details = get_user_by('email', $_REQUEST['email']); |
|
| 321 | 321 | $user_id = $user_details->ID; |
| 322 | 322 | |
| 323 | - if( $location == 'users.php?update=add&id=' . $user_id ) |
|
| 324 | - return add_query_arg( array( 'user_id' => $user_id ), 'user-edit.php' ); |
|
| 323 | + if ($location == 'users.php?update=add&id=' . $user_id) |
|
| 324 | + return add_query_arg(array('user_id' => $user_id), 'user-edit.php'); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | return $location; |
@@ -339,25 +339,25 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @param integer $user_id L'identifiant de l'utilisateur qui vient d'être créé et pour qui on va créer le client. |
| 341 | 341 | */ |
| 342 | - public static function create_entity_customer_when_user_is_created( $user_id ) { |
|
| 343 | - if ( ! is_admin() || strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) ) { |
|
| 344 | - $user_data = get_userdata( $user_id ); |
|
| 345 | - $user_info = array_merge( get_object_vars( $user_data->data ), array_map( 'self::array_map_create_entity_customer_when_user_is_created', get_user_meta( $user_id ) ) ); |
|
| 346 | - $customer_post_ID = wp_insert_post( array( 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'post_author' => $user_id, 'post_title' => $user_data->user_nicename ) ); |
|
| 347 | - self::save_customer_synchronize( $customer_post_ID, $user_id, $user_info ); |
|
| 342 | + public static function create_entity_customer_when_user_is_created($user_id) { |
|
| 343 | + if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) { |
|
| 344 | + $user_data = get_userdata($user_id); |
|
| 345 | + $user_info = array_merge(get_object_vars($user_data->data), array_map('self::array_map_create_entity_customer_when_user_is_created', get_user_meta($user_id))); |
|
| 346 | + $customer_post_ID = wp_insert_post(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'post_author' => $user_id, 'post_title' => $user_data->user_nicename)); |
|
| 347 | + self::save_customer_synchronize($customer_post_ID, $user_id, $user_info); |
|
| 348 | 348 | |
| 349 | 349 | /** Change metabox Hidden Nav Menu Definition to display WPShop categories' metabox */ |
| 350 | - $usermeta = get_post_meta( $user_id, 'metaboxhidden_nav-menus', true ); |
|
| 351 | - if ( ! empty( $usermeta ) && is_array( $usermeta ) ) { |
|
| 352 | - $data_to_delete = array_search( 'add-wpshop_product_category', $usermeta ); |
|
| 353 | - if ( false !== $data_to_delete ) { |
|
| 354 | - unset( $usermeta[ $data_to_delete ] ); |
|
| 355 | - update_user_meta( $user_id, 'metaboxhidden_nav-menus', $usermeta ); |
|
| 350 | + $usermeta = get_post_meta($user_id, 'metaboxhidden_nav-menus', true); |
|
| 351 | + if (!empty($usermeta) && is_array($usermeta)) { |
|
| 352 | + $data_to_delete = array_search('add-wpshop_product_category', $usermeta); |
|
| 353 | + if (false !== $data_to_delete) { |
|
| 354 | + unset($usermeta[$data_to_delete]); |
|
| 355 | + update_user_meta($user_id, 'metaboxhidden_nav-menus', $usermeta); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | - private static function array_map_create_entity_customer_when_user_is_created( $a ) { |
|
| 360 | + private static function array_map_create_entity_customer_when_user_is_created($a) { |
|
| 361 | 361 | return $a[0]; |
| 362 | 362 | } |
| 363 | 363 | |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @param integer $user_id |
| 368 | 368 | */ |
| 369 | - public static function update_entity_customer_when_profile_user_is_update( $user_id ) { |
|
| 370 | - if ( ! is_admin() || strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) ) { |
|
| 369 | + public static function update_entity_customer_when_profile_user_is_update($user_id) { |
|
| 370 | + if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) { |
|
| 371 | 371 | $user_data = get_userdata($user_id); |
| 372 | 372 | $user_info = array_merge(get_object_vars($user_data->data), array_map('self::array_map_create_entity_customer_when_user_is_created', get_user_meta($user_id))); |
| 373 | 373 | $customer_post_ID = self::get_customer_id_by_author_id($user_id); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | return false; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - public static function save_customer_synchronize( $customer_post_ID, $user_id, $user_info ) { |
|
| 383 | + public static function save_customer_synchronize($customer_post_ID, $user_id, $user_info) { |
|
| 384 | 384 | global $wpdb; |
| 385 | 385 | global $wpshop; |
| 386 | 386 | $exclude_user_meta = array('user_login', 'user_nicename', 'user_email', 'user_pass', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name'); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
| 390 | 390 | $attribute_set_id = $wpdb->get_var($query); |
| 391 | 391 | $attributes_default = array(); |
| 392 | - if (! empty($attribute_set_id)) { |
|
| 392 | + if (!empty($attribute_set_id)) { |
|
| 393 | 393 | $group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
| 394 | 394 | foreach ($group as $attribute_sets) { |
| 395 | 395 | foreach ($attribute_sets as $attribute_set_field) { |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | $user_info = array_merge($attributes_default, $user_info); |
| 412 | - add_filter( 'send_password_change_email', array( get_class(), 'prevent_send_mail_from_wordpress' ) ); |
|
| 412 | + add_filter('send_password_change_email', array(get_class(), 'prevent_send_mail_from_wordpress')); |
|
| 413 | 413 | foreach ($user_info as $user_meta => $user_meta_value) { |
| 414 | 414 | $attribute_def = wpshop_attributes::getElement($user_meta, "'valid'", 'code'); |
| 415 | - if (! empty($attribute_def)) { |
|
| 415 | + if (!empty($attribute_def)) { |
|
| 416 | 416 | //Save data in user meta |
| 417 | 417 | if (in_array($user_meta, $exclude_user_meta)) { |
| 418 | 418 | if ($user_meta == 'user_pass') { |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | //Save data in attribute tables, ckeck first if exist to know if Insert or Update |
| 429 | 429 | $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type) . ' WHERE entity_type_id = %d AND entity_id = %d AND attribute_id = %d', $element_id, $customer_post_ID, $attribute_def->id); |
| 430 | 430 | $checking_attribute_exist = $wpdb->get_results($query); |
| 431 | - if (! empty($checking_attribute_exist)) { |
|
| 431 | + if (!empty($checking_attribute_exist)) { |
|
| 432 | 432 | $wpdb->update( |
| 433 | 433 | WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type), |
| 434 | 434 | array( |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | - remove_filter( 'send_password_change_email', array( get_class(), 'prevent_send_mail_from_wordpress' ) ); |
|
| 458 | + remove_filter('send_password_change_email', array(get_class(), 'prevent_send_mail_from_wordpress')); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -465,17 +465,17 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @return array The new header to display |
| 467 | 467 | */ |
| 468 | - public function list_table_header( $current_header ) { |
|
| 469 | - unset( $current_header['title'] ); |
|
| 470 | - unset( $current_header['date'] ); |
|
| 468 | + public function list_table_header($current_header) { |
|
| 469 | + unset($current_header['title']); |
|
| 470 | + unset($current_header['date']); |
|
| 471 | 471 | |
| 472 | - $current_header['customer_identifier'] = __( 'Customer ID', 'wpshop' ); |
|
| 473 | - $current_header['customer-name'] = __( 'Customer name', 'wpshop' ); |
|
| 472 | + $current_header['customer_identifier'] = __('Customer ID', 'wpshop'); |
|
| 473 | + $current_header['customer-name'] = __('Customer name', 'wpshop'); |
|
| 474 | 474 | // $current_header['customer_name'] = '<span class="wps-customer-last_name" >' . __('Last-name', 'wpshop') . '</span><span class="wps-customer-first_name" >' . __('First-name', 'wpshop') . '</span>'; |
| 475 | 475 | // $current_header['customer_email'] = __('E-mail', 'wpshop'); |
| 476 | - $current_header['customer-contacts'] = __( 'Contacts', 'wpshop' ); |
|
| 477 | - $current_header['customer-orders'] = __( 'Customer last order', 'wpshop' ); |
|
| 478 | - $current_header['customer_date_subscription'] = __( 'Subscription', 'wpshop' ); |
|
| 476 | + $current_header['customer-contacts'] = __('Contacts', 'wpshop'); |
|
| 477 | + $current_header['customer-orders'] = __('Customer last order', 'wpshop'); |
|
| 478 | + $current_header['customer_date_subscription'] = __('Subscription', 'wpshop'); |
|
| 479 | 479 | // $current_header['customer_date_lastlogin'] = __( 'Last login date', 'wpshop' ); |
| 480 | 480 | |
| 481 | 481 | return $current_header; |
@@ -487,43 +487,43 @@ discard block |
||
| 487 | 487 | * @param string $column THe column identifier to modify output for. |
| 488 | 488 | * @param integer $post_id The current post identifier. |
| 489 | 489 | */ |
| 490 | - public function list_table_column_content( $column, $post_id ) { |
|
| 490 | + public function list_table_column_content($column, $post_id) { |
|
| 491 | 491 | global $wpdb; |
| 492 | 492 | |
| 493 | 493 | /** Get wp_users identifier from customer id */ |
| 494 | - $customer_post_author = self::get_author_id_by_customer_id( $post_id ); |
|
| 494 | + $customer_post_author = self::get_author_id_by_customer_id($post_id); |
|
| 495 | 495 | |
| 496 | 496 | /** Get current post informations */ |
| 497 | - $customer_post = get_post( $post_id ); |
|
| 497 | + $customer_post = get_post($post_id); |
|
| 498 | 498 | |
| 499 | 499 | /** Switch current column for custom case */ |
| 500 | 500 | $use_template = true; |
| 501 | - switch ( $column ) { |
|
| 501 | + switch ($column) { |
|
| 502 | 502 | case 'customer_identifier' : |
| 503 | 503 | echo $post_id; |
| 504 | 504 | $use_template = false; |
| 505 | 505 | break; |
| 506 | 506 | |
| 507 | 507 | case 'customer_date_subscription' : |
| 508 | - echo mysql2date( get_option( 'date_format' ), $customer_post->post_date, true ); |
|
| 508 | + echo mysql2date(get_option('date_format'), $customer_post->post_date, true); |
|
| 509 | 509 | $use_template = false; |
| 510 | 510 | break; |
| 511 | 511 | |
| 512 | 512 | case 'customer_date_lastlogin' : |
| 513 | - $last_login = get_user_meta( $customer_post_author, 'last_login_time', true ); |
|
| 514 | - if ( ! empty( $last_login ) ) : |
|
| 515 | - echo mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $last_login, true ); |
|
| 513 | + $last_login = get_user_meta($customer_post_author, 'last_login_time', true); |
|
| 514 | + if (!empty($last_login)) : |
|
| 515 | + echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $last_login, true); |
|
| 516 | 516 | else : |
| 517 | - _e( 'Never logged in', 'wpshop' ); |
|
| 517 | + _e('Never logged in', 'wpshop'); |
|
| 518 | 518 | endif; |
| 519 | 519 | $use_template = false; |
| 520 | 520 | break; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /** Require the template for displaying the current column */ |
| 524 | - if ( $use_template ) { |
|
| 525 | - $template = wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/templates/', 'backend', 'customer_listtable/' . $column ); |
|
| 526 | - if ( is_file( $template ) ) { |
|
| 524 | + if ($use_template) { |
|
| 525 | + $template = wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/templates/', 'backend', 'customer_listtable/' . $column); |
|
| 526 | + if (is_file($template)) { |
|
| 527 | 527 | require $template; |
| 528 | 528 | } |
| 529 | 529 | } |
@@ -536,33 +536,33 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return array The new action list to use into customer list table |
| 538 | 538 | */ |
| 539 | - public function customer_list_table_bulk_actions( $actions ) { |
|
| 540 | - unset( $actions['edit'] ); |
|
| 541 | - unset( $actions['trash'] ); |
|
| 539 | + public function customer_list_table_bulk_actions($actions) { |
|
| 540 | + unset($actions['edit']); |
|
| 541 | + unset($actions['trash']); |
|
| 542 | 542 | |
| 543 | 543 | return $actions; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | public function list_table_filters() { |
| 547 | - $post_type = ! empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 547 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 548 | 548 | if (isset($post_type)) { |
| 549 | 549 | if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS)) { |
| 550 | 550 | $filter_possibilities = array(); |
| 551 | 551 | $filter_possibilities[''] = __('-- Select Filter --', 'wpshop'); |
| 552 | 552 | $filter_possibilities['orders'] = __('List customers with orders', 'wpshop'); |
| 553 | 553 | $filter_possibilities['no_orders'] = __('List customers without orders', 'wpshop'); |
| 554 | - echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, (! empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''), '', 'index'); |
|
| 554 | + echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, (!empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''), '', 'index'); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - public function list_table_filter_parse_query( $query ) { |
|
| 559 | + public function list_table_filter_parse_query($query) { |
|
| 560 | 560 | global $pagenow, $wpdb; |
| 561 | - $post_type = ! empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 562 | - $entity_filter = ! empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 563 | - if ( is_admin() && ( $pagenow == 'edit.php' ) && ! empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) && ! empty( $entity_filter ) ) { |
|
| 561 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 562 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 563 | + if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) && !empty($entity_filter)) { |
|
| 564 | 564 | $check = null; |
| 565 | - switch ( $entity_filter ) { |
|
| 565 | + switch ($entity_filter) { |
|
| 566 | 566 | case 'orders': |
| 567 | 567 | $sql_query = $wpdb->prepare( |
| 568 | 568 | "SELECT ID |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | break; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - if ( ! empty( $check ) ) { |
|
| 595 | - $results = $wpdb->get_results( $sql_query ); |
|
| 594 | + if (!empty($check)) { |
|
| 595 | + $results = $wpdb->get_results($sql_query); |
|
| 596 | 596 | $user_id_list = array(); |
| 597 | - foreach ( $results as $item ) { |
|
| 597 | + foreach ($results as $item) { |
|
| 598 | 598 | $user_id_list[] = $item->ID; |
| 599 | 599 | } |
| 600 | - if ( empty( $post_id_list ) ) { |
|
| 600 | + if (empty($post_id_list)) { |
|
| 601 | 601 | $post_id_list[] = 'no_result'; |
| 602 | 602 | } |
| 603 | - $query->query_vars[ $check ] = $user_id_list; |
|
| 603 | + $query->query_vars[$check] = $user_id_list; |
|
| 604 | 604 | } |
| 605 | 605 | $query->query_vars['post_type'] = WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS; |
| 606 | 606 | $query->query_vars['post_status'] = 'any'; |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * |
| 613 | 613 | * @return array |
| 614 | 614 | */ |
| 615 | - public static function get_all_customer( $post_status = 'publish' ) { |
|
| 615 | + public static function get_all_customer($post_status = 'publish') { |
|
| 616 | 616 | global $wpdb; |
| 617 | 617 | |
| 618 | 618 | $query = $wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $post_status); |
@@ -627,15 +627,15 @@ discard block |
||
| 627 | 627 | * @param array $form Passer directement le $_POST pour créer un client. |
| 628 | 628 | * @return array ou int : 1 = Aucun mail, 2 = L'utilisateur existe déjà |
| 629 | 629 | */ |
| 630 | - public static function quick_add_customer( $form ) { |
|
| 630 | + public static function quick_add_customer($form) { |
|
| 631 | 631 | $return = 1; |
| 632 | - if ( ! empty( $form ) ) { |
|
| 632 | + if (!empty($form)) { |
|
| 633 | 633 | global $wpdb; |
| 634 | 634 | $customer_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
| 635 | 635 | $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $customer_type_id); |
| 636 | 636 | $customer_entity_id = $wpdb->get_var($query); |
| 637 | 637 | $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
| 638 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails((! empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 638 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 639 | 639 | |
| 640 | 640 | $customer_attributes_to_save = $customer_attributes_to_save_temp = array(); |
| 641 | 641 | |
@@ -1,62 +1,62 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | ?> |
| 3 | 3 | <div class="changelog" > |
| 4 | 4 | |
| 5 | 5 | <div class="feature-section changelog three-col"> |
| 6 | 6 | <div class="col"> |
| 7 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/paiement.jpg'; ?>" alt="<?php _e( 'Payment methods', 'wpshop'); ?>" title="<?php _e( 'Payment methods', 'wpshop'); ?>" /> |
|
| 8 | - <h3><?php _e( 'Payment methods', 'wpshop'); ?></h3> |
|
| 9 | - <p><?php printf( __( 'When installing WPShop you will have included by default, checks and paypal payment gateway. However there are more %spayment method%s developped for WPShop. If you are interested by a non existant payment method. You can contact us on our %sforum%s', 'wpshop'), '<a href="http://www.wpshop.fr/boutique/extensions/paiement/" target="_wps_about_extra">', '</a>', '<a href="http://forums.eoxia.com/" target="_eoxia_form">', '</a>' ); ?></p> |
|
| 10 | - <a href="<?php echo admin_url( 'options-general.php?page=wpshop_option#wpshop_payments_option' ); ?>" class="button button-large button-primary"><?php _e( 'Manage payment methods', 'wpshop'); ?></a> |
|
| 7 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/paiement.jpg'; ?>" alt="<?php _e('Payment methods', 'wpshop'); ?>" title="<?php _e('Payment methods', 'wpshop'); ?>" /> |
|
| 8 | + <h3><?php _e('Payment methods', 'wpshop'); ?></h3> |
|
| 9 | + <p><?php printf(__('When installing WPShop you will have included by default, checks and paypal payment gateway. However there are more %spayment method%s developped for WPShop. If you are interested by a non existant payment method. You can contact us on our %sforum%s', 'wpshop'), '<a href="http://www.wpshop.fr/boutique/extensions/paiement/" target="_wps_about_extra">', '</a>', '<a href="http://forums.eoxia.com/" target="_eoxia_form">', '</a>'); ?></p> |
|
| 10 | + <a href="<?php echo admin_url('options-general.php?page=wpshop_option#wpshop_payments_option'); ?>" class="button button-large button-primary"><?php _e('Manage payment methods', 'wpshop'); ?></a> |
|
| 11 | 11 | </div> |
| 12 | 12 | <div class="col"> |
| 13 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/livraison.jpg'; ?>" alt="<?php _e( 'Shipping methods', 'wpshop'); ?>" title="<?php _e( 'Shipping methods', 'wpshop'); ?>" /> |
|
| 14 | - <h3><?php _e( 'Shipping methods', 'wpshop'); ?></h3> |
|
| 15 | - <p><?php printf( __( 'By default you have one shipping method available into WPShop. You can create as much as you want using %ssettings interface%s. You will also find on our %swebsite%s additionnals shipping methods. You can contact us on our %sforum%s', 'wpshop'), '<a href="' . admin_url( 'options-general.php?page=wpshop_option#wpshop_shipping_option' ) . '" target="_wps_settings_interface" >', '</a>', '<a href="http://www.wpshop.fr/shop-theme/" target="_wps_about_extra" >', '</a>', '<a href="http://forums.eoxia.com/" target="_eoxia_form">', '</a>' ); ?></p> |
|
| 16 | - <a href="<?php echo admin_url( 'options-general.php?page=wpshop_option#wpshop_shipping_option' ); ?>" class="button button-large button-primary"><?php _e( 'Manage shipping methods', 'wpshop'); ?></a> |
|
| 13 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/livraison.jpg'; ?>" alt="<?php _e('Shipping methods', 'wpshop'); ?>" title="<?php _e('Shipping methods', 'wpshop'); ?>" /> |
|
| 14 | + <h3><?php _e('Shipping methods', 'wpshop'); ?></h3> |
|
| 15 | + <p><?php printf(__('By default you have one shipping method available into WPShop. You can create as much as you want using %ssettings interface%s. You will also find on our %swebsite%s additionnals shipping methods. You can contact us on our %sforum%s', 'wpshop'), '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_shipping_option') . '" target="_wps_settings_interface" >', '</a>', '<a href="http://www.wpshop.fr/shop-theme/" target="_wps_about_extra" >', '</a>', '<a href="http://forums.eoxia.com/" target="_eoxia_form">', '</a>'); ?></p> |
|
| 16 | + <a href="<?php echo admin_url('options-general.php?page=wpshop_option#wpshop_shipping_option'); ?>" class="button button-large button-primary"><?php _e('Manage shipping methods', 'wpshop'); ?></a> |
|
| 17 | 17 | </div> |
| 18 | 18 | <div class="col last-feature"> |
| 19 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/produit.jpg'; ?>" alt="<?php _e( 'Create products', 'wpshop'); ?>" title="<?php _e( 'Create products', 'wpshop'); ?>" /> |
|
| 20 | - <h3><?php _e( 'Create products', 'wpshop'); ?></h3> |
|
| 21 | - <p><?php _e( 'With WPshop plugin you can now create your product catalog on WordPress and market them. A catalog and clear product information, easy to create and fully customizable through shortcodes.', 'wpshop'); ?></p> |
|
| 22 | - <a href="<?php echo admin_url( 'edit.php?post_type=wpshop_product' ); ?>" class="button button-large button-primary wpshop-about-btn-create-products"><?php _e( 'Create products', 'wpshop'); ?></a> |
|
| 19 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/produit.jpg'; ?>" alt="<?php _e('Create products', 'wpshop'); ?>" title="<?php _e('Create products', 'wpshop'); ?>" /> |
|
| 20 | + <h3><?php _e('Create products', 'wpshop'); ?></h3> |
|
| 21 | + <p><?php _e('With WPshop plugin you can now create your product catalog on WordPress and market them. A catalog and clear product information, easy to create and fully customizable through shortcodes.', 'wpshop'); ?></p> |
|
| 22 | + <a href="<?php echo admin_url('edit.php?post_type=wpshop_product'); ?>" class="button button-large button-primary wpshop-about-btn-create-products"><?php _e('Create products', 'wpshop'); ?></a> |
|
| 23 | 23 | </div> |
| 24 | 24 | </div> |
| 25 | 25 | |
| 26 | 26 | <div class="feature-section col three-col"> |
| 27 | 27 | <div class="col"> |
| 28 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/commande.jpg'; ?>" alt="<?php _e( 'Manage orders', 'wpshop'); ?>" title="<?php _e( 'Manage orders', 'wpshop'); ?>" /> |
|
| 29 | - <h3><?php _e( 'Manage orders', 'wpshop'); ?></h3> |
|
| 30 | - <p><?php _e( 'You can manage all your orders and stay in touch with your customers. The dashboard controls will allow you to quickly view your most visited pages , static of your orders ...', 'wpshop'); ?></p> |
|
| 31 | - <a href="<?php echo admin_url( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER ); ?>" class="button button-large button-primary"><?php _e( 'Manage orders', 'wpshop'); ?></a> |
|
| 28 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/commande.jpg'; ?>" alt="<?php _e('Manage orders', 'wpshop'); ?>" title="<?php _e('Manage orders', 'wpshop'); ?>" /> |
|
| 29 | + <h3><?php _e('Manage orders', 'wpshop'); ?></h3> |
|
| 30 | + <p><?php _e('You can manage all your orders and stay in touch with your customers. The dashboard controls will allow you to quickly view your most visited pages , static of your orders ...', 'wpshop'); ?></p> |
|
| 31 | + <a href="<?php echo admin_url('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER); ?>" class="button button-large button-primary"><?php _e('Manage orders', 'wpshop'); ?></a> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="col"> |
| 34 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/reglage-boutique.jpg'; ?>" alt="<?php _e( 'Configure my shop', 'wpshop'); ?>" title="<?php _e( 'Configure my shop', 'wpshop'); ?>" /> |
|
| 35 | - <h3><?php _e( 'Configure my shop', 'wpshop'); ?></h3> |
|
| 36 | - <p><?php printf( __( 'We update WPShop in order to improve speed, accessibility and mobile usage. Go on %smain settings interface%s in order to configure your new shop, payment gateways or shipping methods', 'wpshop'), '<a href="' . admin_url( 'options-general.php?page=wpshop_option' ) . '" target="_wps_settings_interface" >', '</a>' ); ?></p> |
|
| 37 | - <a href="<?php echo admin_url( 'options-general.php?page=wpshop_option' ); ?>" class="button button-large button-primary"><?php _e( 'Configure my shop', 'wpshop'); ?></a> |
|
| 34 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/reglage-boutique.jpg'; ?>" alt="<?php _e('Configure my shop', 'wpshop'); ?>" title="<?php _e('Configure my shop', 'wpshop'); ?>" /> |
|
| 35 | + <h3><?php _e('Configure my shop', 'wpshop'); ?></h3> |
|
| 36 | + <p><?php printf(__('We update WPShop in order to improve speed, accessibility and mobile usage. Go on %smain settings interface%s in order to configure your new shop, payment gateways or shipping methods', 'wpshop'), '<a href="' . admin_url('options-general.php?page=wpshop_option') . '" target="_wps_settings_interface" >', '</a>'); ?></p> |
|
| 37 | + <a href="<?php echo admin_url('options-general.php?page=wpshop_option'); ?>" class="button button-large button-primary"><?php _e('Configure my shop', 'wpshop'); ?></a> |
|
| 38 | 38 | </div> |
| 39 | 39 | <div class="col last-feature"> |
| 40 | - <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/contenu.jpg'; ?>" alt="<?php _e( 'Full content customization', 'wpshop'); ?>" title="<?php _e( 'Full content customization', 'wpshop'); ?>" /> |
|
| 41 | - <h3><?php _e( 'Full content customization', 'wpshop'); ?></h3> |
|
| 42 | - <p><?php printf( __( 'You can design all you %stransactionnal emails%s, change the different %spage layout%s (as cart page, checkout page, and so on)', 'wpshop'), '<a href="' . admin_url( 'edit.php?post_type=wpshop_shop_message' ) . '" target="_wps_settings_interface" >', '</a>', '<a href="' . admin_url( 'edit.php?post_type=page' ) . '" target="_wps_settings_interface" >', '</a>' ); ?></p> |
|
| 40 | + <img src="<?php echo WPS_INSTALLER_URL . WPS_INSTALLER_DIR . '/assets/medias/contenu.jpg'; ?>" alt="<?php _e('Full content customization', 'wpshop'); ?>" title="<?php _e('Full content customization', 'wpshop'); ?>" /> |
|
| 41 | + <h3><?php _e('Full content customization', 'wpshop'); ?></h3> |
|
| 42 | + <p><?php printf(__('You can design all you %stransactionnal emails%s, change the different %spage layout%s (as cart page, checkout page, and so on)', 'wpshop'), '<a href="' . admin_url('edit.php?post_type=wpshop_shop_message') . '" target="_wps_settings_interface" >', '</a>', '<a href="' . admin_url('edit.php?post_type=page') . '" target="_wps_settings_interface" >', '</a>'); ?></p> |
|
| 43 | 43 | </div> |
| 44 | 44 | </div> |
| 45 | 45 | |
| 46 | - <h2 class="about-headline-callout"><?php _e( 'Extend default WPShop functionnalities', 'wpshop'); ?></h2> |
|
| 46 | + <h2 class="about-headline-callout"><?php _e('Extend default WPShop functionnalities', 'wpshop'); ?></h2> |
|
| 47 | 47 | <div class="feature-section col two-col"> |
| 48 | 48 | <div class="col"> |
| 49 | - <h3><?php _e( 'External addons', 'wpshop'); ?></h3> |
|
| 50 | - <p><?php printf( __( 'Need a theme? or a payment gateway? or a shipping addons? Anythong else? Check %sour website%s in order to find the addons for WPShop that you need. If you don\'t find it please contact us through the forum with the link below.', 'wpshop'), '<a href="http://www.wpshop.fr/shop-theme/" >', '</a>' ); ?></p> |
|
| 49 | + <h3><?php _e('External addons', 'wpshop'); ?></h3> |
|
| 50 | + <p><?php printf(__('Need a theme? or a payment gateway? or a shipping addons? Anythong else? Check %sour website%s in order to find the addons for WPShop that you need. If you don\'t find it please contact us through the forum with the link below.', 'wpshop'), '<a href="http://www.wpshop.fr/shop-theme/" >', '</a>'); ?></p> |
|
| 51 | 51 | </div> |
| 52 | 52 | <div class="col last-feature"> |
| 53 | - <h3><?php _e( 'Custom hooks', 'wpshop'); ?></h3> |
|
| 54 | - <p><?php printf( __( 'We inserted some custom hook through WPShop code. That will give you some possibilities to add functionnalities when it is already planned.', 'wpshop') ); ?></p> |
|
| 53 | + <h3><?php _e('Custom hooks', 'wpshop'); ?></h3> |
|
| 54 | + <p><?php printf(__('We inserted some custom hook through WPShop code. That will give you some possibilities to add functionnalities when it is already planned.', 'wpshop')); ?></p> |
|
| 55 | 55 | </div> |
| 56 | 56 | </div> |
| 57 | 57 | |
| 58 | 58 | <?php // <h3 class="about-headline-callout"><?php printf( __( 'A question ? A comment ? A need ? Join us on %sWPShop forum%s', 'wpshop'), '<a href="http://forums.eoxia.com/login" taget="_wpshop_forums" >', '</a>' ); </h3> ?> |
| 59 | 59 | |
| 60 | 60 | <hr> |
| 61 | - <div class="return-to-dashboard"><a href="<?php echo admin_url( 'admin.php?page=wpshop_dashboard' ); ?>"><?php _e( 'Go to your shop dashboard', 'wpshop'); ?></a></div> |
|
| 61 | + <div class="return-to-dashboard"><a href="<?php echo admin_url('admin.php?page=wpshop_dashboard'); ?>"><?php _e('Go to your shop dashboard', 'wpshop'); ?></a></div> |
|
| 62 | 62 | </div> |
@@ -1,24 +1,24 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
| 1 | +<?php if (!defined('ABSPATH')) { |
|
| 2 | 2 | exit; |
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | class wps_download_file_ctr { |
| 6 | 6 | |
| 7 | 7 | public function __construct() { |
| 8 | - add_action( 'admin_post_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
| 9 | - add_action( 'admin_post_nopriv_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
| 10 | - add_action( 'wps_after_check_order_payment_total_amount', array( $this, 'wps_after_check_order_payment_total_amount' ) ); |
|
| 8 | + add_action('admin_post_wps_download_file', array($this, 'wps_download_file')); |
|
| 9 | + add_action('admin_post_nopriv_wps_download_file', array($this, 'wps_download_file')); |
|
| 10 | + add_action('wps_after_check_order_payment_total_amount', array($this, 'wps_after_check_order_payment_total_amount')); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public static function get_product_download_link( $oid, $item ) { |
|
| 13 | + public static function get_product_download_link($oid, $item) { |
|
| 14 | 14 | global $wpdb; |
| 15 | 15 | |
| 16 | 16 | $parent_def = array(); |
| 17 | 17 | $item_id = $item['item_id']; |
| 18 | - $item_post_type = get_post_type( $item['item_id'] ); |
|
| 19 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) { |
|
| 20 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 21 | - if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { |
|
| 18 | + $item_post_type = get_post_type($item['item_id']); |
|
| 19 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) { |
|
| 20 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 21 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
| 22 | 22 | $parent_post = $parent_def['parent_post']; |
| 23 | 23 | $item_id = $parent_post->ID; |
| 24 | 24 | $item_title = $parent_post->post_title; |
@@ -28,50 +28,50 @@ discard block |
||
| 28 | 28 | $download_link = false; |
| 29 | 29 | $item_id_for_download = null; |
| 30 | 30 | /** Check if the product or the head product is a download product */ |
| 31 | - if ( ! empty( $parent_def ) ) { |
|
| 31 | + if (!empty($parent_def)) { |
|
| 32 | 32 | $parent_meta = $parent_def['parent_post_meta']; |
| 33 | - if ( ! empty( $parent_meta['is_downloadable_'] ) ) { |
|
| 34 | - $query = $wpdb->prepare( 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'] ); |
|
| 35 | - $downloadable_option_value = $wpdb->get_var( $query ); |
|
| 36 | - if ( empty( $downloadable_option_value ) ) { |
|
| 33 | + if (!empty($parent_meta['is_downloadable_'])) { |
|
| 34 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_']); |
|
| 35 | + $downloadable_option_value = $wpdb->get_var($query); |
|
| 36 | + if (empty($downloadable_option_value)) { |
|
| 37 | 37 | $item['item_is_downloadable_'] = 'No'; |
| 38 | 38 | } else { |
| 39 | 39 | $item['item_is_downloadable_'] = $downloadable_option_value; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | - if ( empty( $item['item_is_downloadable_'] ) ) { |
|
| 44 | - $product_data = wpshop_products::get_product_data( $item['item_id'] ); |
|
| 45 | - if ( empty( $product_data['is_downloadable_'] ) ) { |
|
| 43 | + if (empty($item['item_is_downloadable_'])) { |
|
| 44 | + $product_data = wpshop_products::get_product_data($item['item_id']); |
|
| 45 | + if (empty($product_data['is_downloadable_'])) { |
|
| 46 | 46 | $item['item_is_downloadable_'] = 'No'; |
| 47 | 47 | } else { |
| 48 | 48 | $item['item_is_downloadable_'] = $product_data['is_downloadable_']; |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - if ( strtolower( __( $item['item_is_downloadable_'], 'wpshop' ) ) === strtolower( __( 'Yes', 'wpshop' ) ) ) { |
|
| 51 | + if (strtolower(__($item['item_is_downloadable_'], 'wpshop')) === strtolower(__('Yes', 'wpshop'))) { |
|
| 52 | 52 | $item_id_for_download = $item_id; |
| 53 | 53 | } |
| 54 | - if ( isset( $item['item_meta']['variations'] ) ) { |
|
| 55 | - foreach ( $item['item_meta']['variations'] as $variation_id => $variation ) { |
|
| 56 | - if ( isset( $variation['item_meta']['is_downloadable_'] ) ) { |
|
| 54 | + if (isset($item['item_meta']['variations'])) { |
|
| 55 | + foreach ($item['item_meta']['variations'] as $variation_id => $variation) { |
|
| 56 | + if (isset($variation['item_meta']['is_downloadable_'])) { |
|
| 57 | 57 | $item_id_for_download = $item_id . '__' . $variation_id; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | /** In case there is a item identifier defined for download */ |
| 62 | - if ( null !== $item_id_for_download ) { |
|
| 63 | - $download_codes = get_user_meta( get_current_user_id(), '_order_download_codes_' . $oid, true ); |
|
| 62 | + if (null !== $item_id_for_download) { |
|
| 63 | + $download_codes = get_user_meta(get_current_user_id(), '_order_download_codes_' . $oid, true); |
|
| 64 | 64 | /** Check if the current product exist into download code list, if not check if there is a composition between parent product and children product */ |
| 65 | - if ( empty( $download_codes[ $item_id_for_download ] ) ) { |
|
| 66 | - $item_id_component = explode( '__', $item_id_for_download ); |
|
| 67 | - if ( ! empty( $item_id_component ) && ( $item_id_component[0] !== $item_id_for_download ) ) { |
|
| 65 | + if (empty($download_codes[$item_id_for_download])) { |
|
| 66 | + $item_id_component = explode('__', $item_id_for_download); |
|
| 67 | + if (!empty($item_id_component) && ($item_id_component[0] !== $item_id_for_download)) { |
|
| 68 | 68 | $item_id_for_download = $item_id_component[0]; |
| 69 | - } elseif ( ! empty( $download_codes[ $item['item_id'] ] ) ) { |
|
| 69 | + } elseif (!empty($download_codes[$item['item_id']])) { |
|
| 70 | 70 | $item_id_for_download = $item['item_id']; |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | - if ( ! empty( $download_codes ) && ! empty( $download_codes[ $item_id_for_download ] ) && ! empty( $download_codes[ $item_id_for_download ]['download_code'] ) ) { |
|
| 74 | - $download_link = admin_url( 'admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[ $item_id_for_download ]['download_code'] ); |
|
| 73 | + if (!empty($download_codes) && !empty($download_codes[$item_id_for_download]) && !empty($download_codes[$item_id_for_download]['download_code'])) { |
|
| 74 | + $download_link = admin_url('admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[$item_id_for_download]['download_code']); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -79,34 +79,34 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function wps_download_file() { |
| 82 | - $download = ! empty( $_GET['download'] ) ? sanitize_text_field( $_GET['download'] ) : ''; |
|
| 83 | - $oid = ! empty( $_GET['oid'] ) ? (int) $_GET['oid'] : 0; |
|
| 82 | + $download = !empty($_GET['download']) ? sanitize_text_field($_GET['download']) : ''; |
|
| 83 | + $oid = !empty($_GET['oid']) ? (int)$_GET['oid'] : 0; |
|
| 84 | 84 | |
| 85 | - if ( ! empty( $download ) && ! empty( $oid ) ) { |
|
| 85 | + if (!empty($download) && !empty($oid)) { |
|
| 86 | 86 | $variation_id = ''; |
| 87 | - $order = get_post_meta( $oid, '_order_postmeta', true ); |
|
| 88 | - if ( ! empty( $order ) && ! empty( $order['customer_id'] ) ) { |
|
| 89 | - $download_codes = get_user_meta( $order['customer_id'], '_order_download_codes_' . $oid, true ); |
|
| 90 | - if ( ! empty( $download_codes ) && is_array( $download_codes ) ) { |
|
| 91 | - foreach ( $download_codes as $downloadable_product_id => $d ) { |
|
| 87 | + $order = get_post_meta($oid, '_order_postmeta', true); |
|
| 88 | + if (!empty($order) && !empty($order['customer_id'])) { |
|
| 89 | + $download_codes = get_user_meta($order['customer_id'], '_order_download_codes_' . $oid, true); |
|
| 90 | + if (!empty($download_codes) && is_array($download_codes)) { |
|
| 91 | + foreach ($download_codes as $downloadable_product_id => $d) { |
|
| 92 | 92 | $is_encrypted = false; |
| 93 | - if ( $d['download_code'] === $download ) { |
|
| 93 | + if ($d['download_code'] === $download) { |
|
| 94 | 94 | wpshop_tools::create_custom_hook('encrypt_actions_for_downloadable_product', array( |
| 95 | 95 | 'order_id' => $oid, |
| 96 | 96 | 'download_product_id' => $downloadable_product_id, |
| 97 | 97 | |
| 98 | - ) ); |
|
| 98 | + )); |
|
| 99 | 99 | |
| 100 | - if ( get_post_type( $downloadable_product_id ) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 101 | - $parent_def = wpshop_products::get_parent_variation( $downloadable_product_id ); |
|
| 102 | - if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { |
|
| 100 | + if (get_post_type($downloadable_product_id) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 101 | + $parent_def = wpshop_products::get_parent_variation($downloadable_product_id); |
|
| 102 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
| 103 | 103 | $parent_post = $parent_def['parent_post']; |
| 104 | 104 | $variation_id = $downloadable_product_id; |
| 105 | 105 | $downloadable_product_id = $parent_post->ID; |
| 106 | 106 | } |
| 107 | 107 | } else { |
| 108 | - $downloadable_product_id = explode( '__', $downloadable_product_id ); |
|
| 109 | - $downloadable_product_id = isset( $downloadable_product_id[1] ) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
| 108 | + $downloadable_product_id = explode('__', $downloadable_product_id); |
|
| 109 | + $downloadable_product_id = isset($downloadable_product_id[1]) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $link = wpshop_attributes::get_attribute_option_output( |
@@ -117,50 +117,50 @@ discard block |
||
| 117 | 117 | 'is_downloadable_', 'file_url', $order |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | - if ( false !== $link ) { |
|
| 120 | + if (false !== $link) { |
|
| 121 | 121 | $uploads = wp_upload_dir(); |
| 122 | 122 | $basedir = $uploads['basedir']; |
| 123 | - $pos = strpos( $link, 'uploads' ); |
|
| 124 | - $link = $basedir . substr( $link,$pos + 7 ); |
|
| 123 | + $pos = strpos($link, 'uploads'); |
|
| 124 | + $link = $basedir . substr($link, $pos + 7); |
|
| 125 | 125 | /** If plugin is encrypted */ |
| 126 | - $encrypted_plugin_path = get_post_meta( $oid, '_download_file_path_' . $oid . '_' . ( ( ! empty( $variation_id ) && get_post_type( $variation_id ) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) ? $variation_id : $downloadable_product_id ), true ); |
|
| 127 | - if ( ! empty( $encrypted_plugin_path ) ) { |
|
| 126 | + $encrypted_plugin_path = get_post_meta($oid, '_download_file_path_' . $oid . '_' . ((!empty($variation_id) && get_post_type($variation_id) === WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ? $variation_id : $downloadable_product_id), true); |
|
| 127 | + if (!empty($encrypted_plugin_path)) { |
|
| 128 | 128 | $link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path; |
| 129 | 129 | $is_encrypted = true; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $overload_force_download = apply_filters( 'wps_download_file_overload_force_download', false ); |
|
| 133 | - if ( ! $overload_force_download ) { |
|
| 134 | - wpshop_tools::forceDownload( $link, $is_encrypted ); |
|
| 132 | + $overload_force_download = apply_filters('wps_download_file_overload_force_download', false); |
|
| 133 | + if (!$overload_force_download) { |
|
| 134 | + wpshop_tools::forceDownload($link, $is_encrypted); |
|
| 135 | 135 | } else { |
| 136 | - wpshop_tools::wpshop_safe_redirect( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $link ) ); |
|
| 136 | + wpshop_tools::wpshop_safe_redirect(str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $link)); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | }// End if(). |
| 140 | 140 | }// End foreach(). |
| 141 | 141 | }// End if(). |
| 142 | 142 | } else { |
| 143 | - wp_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' ) ) ) ); |
|
| 143 | + wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); |
|
| 144 | 144 | }// End if(). |
| 145 | 145 | }// End if(). |
| 146 | - esc_html_e( 'Impossible to download the file you requested', 'wpshop' ); |
|
| 146 | + esc_html_e('Impossible to download the file you requested', 'wpshop'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public function wps_after_check_order_payment_total_amount( $order_id ) { |
|
| 150 | - $order_meta = ( ! empty( $order_meta ) ) ? false : get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 149 | + public function wps_after_check_order_payment_total_amount($order_id) { |
|
| 150 | + $order_meta = (!empty($order_meta)) ? false : get_post_meta($order_id, '_order_postmeta', true); |
|
| 151 | 151 | /** Check if the order content a downloadable product **/ |
| 152 | - if ( ! empty( $order_meta ) && ! empty( $order_meta['order_items'] ) && ! empty( $order_meta['order_status'] ) && 'completed' === $order_meta['order_status'] ) { |
|
| 153 | - foreach ( $order_meta['order_items'] as $key_value => $item ) { |
|
| 154 | - $link = self::get_product_download_link( $order_id, $item ); |
|
| 155 | - if ( false === $link ) { |
|
| 152 | + if (!empty($order_meta) && !empty($order_meta['order_items']) && !empty($order_meta['order_status']) && 'completed' === $order_meta['order_status']) { |
|
| 153 | + foreach ($order_meta['order_items'] as $key_value => $item) { |
|
| 154 | + $link = self::get_product_download_link($order_id, $item); |
|
| 155 | + if (false === $link) { |
|
| 156 | 156 | \eoxia\log_class::exec( |
| 157 | 157 | get_class(), |
| 158 | 158 | get_class(), |
| 159 | 159 | sprintf( |
| 160 | - __( 'Failure returned at order link generation. UserID : <b>%1$d</b>, ProductID : <b>%2$d</d>, UserMeta : <pre>%3$s</pre>', 'wpshop' ), |
|
| 161 | - (int) get_current_user_id(), |
|
| 162 | - (int) $item['item_id'], |
|
| 163 | - get_user_meta( get_current_user_id(), '_order_download_codes_' . $order_id, true ) |
|
| 160 | + __('Failure returned at order link generation. UserID : <b>%1$d</b>, ProductID : <b>%2$d</d>, UserMeta : <pre>%3$s</pre>', 'wpshop'), |
|
| 161 | + (int)get_current_user_id(), |
|
| 162 | + (int)$item['item_id'], |
|
| 163 | + get_user_meta(get_current_user_id(), '_order_download_codes_' . $order_id, true) |
|
| 164 | 164 | ), |
| 165 | 165 | array( |
| 166 | 166 | 'object_id' => $order_id, |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | 0 |
| 169 | 169 | ); |
| 170 | 170 | } else { |
| 171 | - $link = '<a href="' . esc_url( $link ) . '" target="_blank">' . __( 'Download the product', 'wpshop' ) . '</a>'; |
|
| 171 | + $link = '<a href="' . esc_url($link) . '" target="_blank">' . __('Download the product', 'wpshop') . '</a>'; |
|
| 172 | 172 | $wps_message->wpshop_prepared_email( |
| 173 | 173 | $email, |
| 174 | 174 | 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', |
@@ -2,18 +2,18 @@ discard block |
||
| 2 | 2 | <div data-view-model="wps_variations_options_summary" id="wps_variations_summary_display"> |
| 3 | 3 | <b>%summary%</b> |
| 4 | 4 | </div> |
| 5 | - <a id="wps_variations_parameters" title="<?php esc_html_e( 'Edit possibilities', 'wpshop' ); ?>" href="#"> |
|
| 5 | + <a id="wps_variations_parameters" title="<?php esc_html_e('Edit possibilities', 'wpshop'); ?>" href="#"> |
|
| 6 | 6 | <?php // href=">?php print wp_nonce_url( get_edit_post_link( $post->ID ) . '&wps_variation_interface=false', 'wps_remove_variation_interface' );?<">. ?> |
| 7 | 7 | <span class="dashicons dashicons-admin-generic"></span> |
| 8 | 8 | </a> |
| 9 | 9 | </div> |
| 10 | 10 | <div id="wps_variations_options"> |
| 11 | 11 | <ul id="wps_variations_options_title"> |
| 12 | - <li><?php esc_html_e( 'Generate option', 'wpshop' ); ?></li> |
|
| 13 | - <li><?php esc_html_e( 'Option', 'wpshop' ); ?></li> |
|
| 14 | - <li><?php esc_html_e( 'Requiered', 'wpshop' ); ?></li> |
|
| 15 | - <li><?php esc_html_e( 'Possibilities', 'wpshop' ); ?></li> |
|
| 16 | - <li><?php esc_html_e( 'Default', 'wpshop' ); ?></li> |
|
| 12 | + <li><?php esc_html_e('Generate option', 'wpshop'); ?></li> |
|
| 13 | + <li><?php esc_html_e('Option', 'wpshop'); ?></li> |
|
| 14 | + <li><?php esc_html_e('Requiered', 'wpshop'); ?></li> |
|
| 15 | + <li><?php esc_html_e('Possibilities', 'wpshop'); ?></li> |
|
| 16 | + <li><?php esc_html_e('Default', 'wpshop'); ?></li> |
|
| 17 | 17 | </ul> |
| 18 | 18 | <ul data-view-model="wps_variations_options_raw" class="wps_variations_options_raw"> |
| 19 | 19 | <li class="wps_variations_generate_col"> |
@@ -44,42 +44,42 @@ discard block |
||
| 44 | 44 | </div> |
| 45 | 45 | <div id="wps_variations_questions"> |
| 46 | 46 | <ul> |
| 47 | - <li class="wps_variations_questions_question_col"><?php esc_html_e( 'Do you want to manage each options singly or combine them ?', 'wpshop' ); ?></li> |
|
| 47 | + <li class="wps_variations_questions_question_col"><?php esc_html_e('Do you want to manage each options singly or combine them ?', 'wpshop'); ?></li> |
|
| 48 | 48 | <li class="wps_variations_questions_answers_col"> |
| 49 | 49 | <?php |
| 50 | 50 | $id1 = uniqid(); |
| 51 | 51 | ?> |
| 52 | - <input id="question_combine_options_<?php echo intval( $id1 ); ?>" name="question_combine_options" type="radio" value="combine"> |
|
| 53 | - <label for="question_combine_options_<?php echo intval( $id1 ); ?>"><?php esc_html_e( 'Combined options', 'wpshop' ); ?></label> |
|
| 52 | + <input id="question_combine_options_<?php echo intval($id1); ?>" name="question_combine_options" type="radio" value="combine"> |
|
| 53 | + <label for="question_combine_options_<?php echo intval($id1); ?>"><?php esc_html_e('Combined options', 'wpshop'); ?></label> |
|
| 54 | 54 | <?php |
| 55 | 55 | $id2 = uniqid(); |
| 56 | 56 | ?> |
| 57 | - <input id="question_combine_options_<?php echo intval( $id2 ); ?>" name="question_combine_options" type="radio" value="single"> |
|
| 58 | - <label for="question_combine_options_<?php echo intval( $id2 ); ?>"><?php esc_html_e( 'Distinct options', 'wpshop' ); ?></label> |
|
| 57 | + <input id="question_combine_options_<?php echo intval($id2); ?>" name="question_combine_options" type="radio" value="single"> |
|
| 58 | + <label for="question_combine_options_<?php echo intval($id2); ?>"><?php esc_html_e('Distinct options', 'wpshop'); ?></label> |
|
| 59 | 59 | </li> |
| 60 | 60 | </ul> |
| 61 | 61 | </div> |
| 62 | 62 | <div id="wps_variations_tabs"> |
| 63 | 63 | <ul> |
| 64 | - <li data-tab="wps_variations_price_option_tab" class="disabled"><?php esc_html_e( 'Options prices', 'wpshop' ); ?></li> |
|
| 65 | - <li id="wps_variations_apply_btn" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpshop_variation_management' ) ); ?>"> |
|
| 66 | - <?php esc_html_e( 'Apply modifications', 'wpshop' ); ?> |
|
| 64 | + <li data-tab="wps_variations_price_option_tab" class="disabled"><?php esc_html_e('Options prices', 'wpshop'); ?></li> |
|
| 65 | + <li id="wps_variations_apply_btn" data-nonce="<?php echo esc_attr(wp_create_nonce('wpshop_variation_management')); ?>"> |
|
| 66 | + <?php esc_html_e('Apply modifications', 'wpshop'); ?> |
|
| 67 | 67 | </li> |
| 68 | 68 | </ul> |
| 69 | 69 | </div> |
| 70 | 70 | <div id="wps_variations_price_option_tab" class="wps_variations_tabs"> |
| 71 | 71 | <ul id="wps_variations_price_option_tab_title"> |
| 72 | - <li class="wps_variations_price_id_col"><?php esc_html_e( 'ID', 'wpshop' ); ?></li> |
|
| 73 | - <li class="wps_variations_price_name_col"><?php esc_html_e( 'Options', 'wpshop' ); ?></li> |
|
| 74 | - <li class="wps_variations_price_config_col"><?php esc_html_e( 'Prices', 'wpshop' ); ?></li> |
|
| 75 | - <li class="wps_variations_price_final_col"><?php esc_html_e( 'Final prices', 'wpshop' ); ?></li> |
|
| 76 | - <li class="wps_variations_price_vat_col"><?php esc_html_e( 'VAT', 'wpshop' ); ?></li> |
|
| 77 | - <li class="wps_variations_price_stock_col"><?php esc_html_e( 'Stock', 'wpshop' ); ?></li> |
|
| 78 | - <li class="wps_variations_price_weight_col"><?php esc_html_e( 'Weight', 'wpshop' ); ?></li> |
|
| 79 | - <li class="wps_variations_price_reference_col"><?php esc_html_e( 'Ref. product', 'wpshop' ); ?></li> |
|
| 80 | - <li class="wps_variations_price_file_col"><?php esc_html_e( 'Link download', 'wpshop' ); ?></li> |
|
| 81 | - <?php echo apply_filters( 'wps_filters_product_variation_extra_columns_title', '' ); ?> |
|
| 82 | - <li class="wps_variations_price_active_col"><?php esc_html_e( 'Activate', 'wpshop' ); ?></li> |
|
| 72 | + <li class="wps_variations_price_id_col"><?php esc_html_e('ID', 'wpshop'); ?></li> |
|
| 73 | + <li class="wps_variations_price_name_col"><?php esc_html_e('Options', 'wpshop'); ?></li> |
|
| 74 | + <li class="wps_variations_price_config_col"><?php esc_html_e('Prices', 'wpshop'); ?></li> |
|
| 75 | + <li class="wps_variations_price_final_col"><?php esc_html_e('Final prices', 'wpshop'); ?></li> |
|
| 76 | + <li class="wps_variations_price_vat_col"><?php esc_html_e('VAT', 'wpshop'); ?></li> |
|
| 77 | + <li class="wps_variations_price_stock_col"><?php esc_html_e('Stock', 'wpshop'); ?></li> |
|
| 78 | + <li class="wps_variations_price_weight_col"><?php esc_html_e('Weight', 'wpshop'); ?></li> |
|
| 79 | + <li class="wps_variations_price_reference_col"><?php esc_html_e('Ref. product', 'wpshop'); ?></li> |
|
| 80 | + <li class="wps_variations_price_file_col"><?php esc_html_e('Link download', 'wpshop'); ?></li> |
|
| 81 | + <?php echo apply_filters('wps_filters_product_variation_extra_columns_title', ''); ?> |
|
| 82 | + <li class="wps_variations_price_active_col"><?php esc_html_e('Activate', 'wpshop'); ?></li> |
|
| 83 | 83 | </ul> |
| 84 | 84 | <ul data-view-model="wps_variations_price_option_raw"> |
| 85 | 85 | <li class="wps_variations_price_id_col"> |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | <input type="text" pattern="[0-9]+(\.[0-9][0-9]?)?" onchange="wps_variations_price_option_raw.control.price(this)" align="right" value="%price_value%"> |
| 99 | 99 | </li> |
| 100 | 100 | <li class="wps_variations_price_final_col"> |
| 101 | - <input type="hidden" name="wps_pdt_variations[%ID%][attribute][decimal][<?php echo (!empty($price_piloting) && $price_piloting != 'HT') ? 'product_price' : 'price_ht' ; ?>]" value="%price_option%"> |
|
| 101 | + <input type="hidden" name="wps_pdt_variations[%ID%][attribute][decimal][<?php echo (!empty($price_piloting) && $price_piloting != 'HT') ? 'product_price' : 'price_ht'; ?>]" value="%price_option%"> |
|
| 102 | 102 | <b>%price_option%%currency%</b> %piloting% |
| 103 | 103 | </li> |
| 104 | 104 | <li class="wps_variations_price_vat_col"> |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | </li> |
| 119 | 119 | <li class="wps_variations_price_file_col" data-view-model="wps_variations_price_option_file_%ID%"> |
| 120 | 120 | <span class="wps_variations_price_option_price_file" onclick="wps_variations_price_option_raw.control.file(this)">%link%</span> |
| 121 | - <?php echo apply_filters( 'wps_filters_product_variation_file', '<input style="display: none;" type="file" name="wpshop_file" id="wpshop_file" onchange="wps_variations_price_option_raw.control.link(event, this)">' ); ?> |
|
| 122 | - <?php wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action', 'wpshop_file_nonce' );?> |
|
| 121 | + <?php echo apply_filters('wps_filters_product_variation_file', '<input style="display: none;" type="file" name="wpshop_file" id="wpshop_file" onchange="wps_variations_price_option_raw.control.link(event, this)">'); ?> |
|
| 122 | + <?php wp_nonce_field('ajax_wpshop_upload_downloadable_file_action', 'wpshop_file_nonce'); ?> |
|
| 123 | 123 | <a class="wps_variations_price_option_price_download_file" href="%path%" target="_blank" download="" style="display: %download%"> |
| 124 | 124 | <span class="dashicons dashicons-download"></span> |
| 125 | 125 | </a> |
| 126 | 126 | </li> |
| 127 | - <?php echo apply_filters( 'wps_filters_product_variation_extra_columns_content', '' ); ?> |
|
| 127 | + <?php echo apply_filters('wps_filters_product_variation_extra_columns_content', ''); ?> |
|
| 128 | 128 | <li class="wps_variations_price_active_col"> |
| 129 | 129 | <input name="wps_pdt_variations[%ID%][status]" onclick="wps_variations_price_option_raw.control.activate(this)" type="checkbox" %price_option_activate%> |
| 130 | 130 | </li> |