@@ -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,26 +588,26 @@ discard block |
||
| 588 | 588 | update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0)); |
| 589 | 589 | |
| 590 | 590 | /** Check if the order content a downloadable product **/ |
| 591 | - if ( ! empty( $order_meta['order_items'] ) ) { |
|
| 592 | - foreach ( $order_meta['order_items'] as $key_value => $item ) { |
|
| 593 | - $link = wps_download_file_ctr::get_product_download_link( $order_id, $item ); |
|
| 594 | - if ( false !== $link ) { |
|
| 595 | - $link = '<a href="' . $link . '" target="_blank">' . __( 'Download the product', 'wpshop' ) . '</a>'; |
|
| 596 | - $wps_message->wpshop_prepared_email( $email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array( 'order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link ), array() ); |
|
| 591 | + if (!empty($order_meta['order_items'])) { |
|
| 592 | + foreach ($order_meta['order_items'] as $key_value => $item) { |
|
| 593 | + $link = wps_download_file_ctr::get_product_download_link($order_id, $item); |
|
| 594 | + if (false !== $link) { |
|
| 595 | + $link = '<a href="' . $link . '" target="_blank">' . __('Download the product', 'wpshop') . '</a>'; |
|
| 596 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array()); |
|
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | // Send confirmation e-mail to administrator |
| 602 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 602 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 603 | 603 | $email_option = get_option('wpshop_emails'); |
| 604 | - if( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){ |
|
| 605 | - wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data ); |
|
| 604 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) { |
|
| 605 | + wpshop_checkout::send_order_email_to_administrator($order_id, $user_data); |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // POS Status |
| 610 | - if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
|
| 610 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') { |
|
| 611 | 611 | $payment_status = 'pos'; |
| 612 | 612 | } |
| 613 | 613 | } |
@@ -616,27 +616,27 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | $order_meta['order_status'] = $payment_status; |
| 619 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 619 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 620 | 620 | $save_metadata = false; |
| 621 | 621 | |
| 622 | - $allow_send_invoice = get_option( 'wpshop_send_invoice' ); |
|
| 623 | - $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'] ) : ''; |
|
| 622 | + $allow_send_invoice = get_option('wpshop_send_invoice'); |
|
| 623 | + $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']) : ''; |
|
| 624 | 624 | |
| 625 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 625 | + $email_option = get_option('wpshop_emails'); |
|
| 626 | 626 | |
| 627 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 628 | - $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'] : '' ); |
|
| 627 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 628 | + $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'] : ''); |
|
| 629 | 629 | |
| 630 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 631 | - $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']; |
|
| 630 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 631 | + $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']; |
|
| 632 | 632 | |
| 633 | - if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed' |
|
| 634 | - && ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) { |
|
| 635 | - $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 ) ); |
|
| 633 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' |
|
| 634 | + && (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) { |
|
| 635 | + $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)); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
|
| 639 | - $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); |
|
| 638 | + if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) { |
|
| 639 | + $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); |
|
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | else { |
@@ -644,13 +644,13 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | $order_meta['order_status'] = $payment_status; |
| 647 | - if( !$save_metadata ) { |
|
| 647 | + if (!$save_metadata) { |
|
| 648 | 648 | return $order_meta; |
| 649 | 649 | } |
| 650 | 650 | else { |
| 651 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 651 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 652 | 652 | } |
| 653 | - update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
|
| 653 | + update_post_meta($order_id, '_wpshop_order_status', $payment_status); |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
@@ -662,11 +662,11 @@ discard block |
||
| 662 | 662 | * @param integer $order_id The order identifier we want to get the old transaction reference for |
| 663 | 663 | * @return integer |
| 664 | 664 | */ |
| 665 | - public static function get_payment_transaction_number_old_way($order_id){ |
|
| 665 | + public static function get_payment_transaction_number_old_way($order_id) { |
|
| 666 | 666 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 667 | 667 | $transaction_indentifier = 0; |
| 668 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 669 | - switch($order_postmeta['payment_method']){ |
|
| 668 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 669 | + switch ($order_postmeta['payment_method']) { |
|
| 670 | 670 | case 'check': |
| 671 | 671 | $transaction_indentifier = get_post_meta($order_id, '_order_check_number', true); |
| 672 | 672 | break; |
@@ -685,26 +685,26 @@ discard block |
||
| 685 | 685 | return $transaction_indentifier; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - public static function reverify_payment_invoice_ref( $order_id, $index_payment ) { |
|
| 688 | + public static function reverify_payment_invoice_ref($order_id, $index_payment) { |
|
| 689 | 689 | $status = false; |
| 690 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 691 | - 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'] ) ) { |
|
| 690 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 691 | + 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'])) { |
|
| 692 | 692 | $order_invoice = $invoice_ref = false; |
| 693 | 693 | |
| 694 | - end( $order_meta['order_payment']['received'] ); |
|
| 695 | - $last_payment = key( $order_meta['order_payment']['received'] ); |
|
| 696 | - if( $last_payment == $index_payment ) { |
|
| 694 | + end($order_meta['order_payment']['received']); |
|
| 695 | + $last_payment = key($order_meta['order_payment']['received']); |
|
| 696 | + if ($last_payment == $index_payment) { |
|
| 697 | 697 | $payments = 0; |
| 698 | - foreach( $order_meta['order_payment']['received'] as $payment ) { |
|
| 699 | - $payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0; |
|
| 698 | + foreach ($order_meta['order_payment']['received'] as $payment) { |
|
| 699 | + $payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0; |
|
| 700 | 700 | } |
| 701 | - if( $order_meta['order_grand_total'] <= $payments ) { |
|
| 702 | - if( $order_meta['order_status'] == 'partially_paid' ) { |
|
| 703 | - $order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
| 701 | + if ($order_meta['order_grand_total'] <= $payments) { |
|
| 702 | + if ($order_meta['order_status'] == 'partially_paid') { |
|
| 703 | + $order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
| 704 | 704 | $order_meta['order_status'] = 'completed'; |
| 705 | - $status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' ); |
|
| 705 | + $status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed'); |
|
| 706 | 706 | } |
| 707 | - if( !empty( $order_meta['order_invoice_ref'] ) ) { |
|
| 707 | + if (!empty($order_meta['order_invoice_ref'])) { |
|
| 708 | 708 | $invoice_ref = $order_meta['order_invoice_ref']; |
| 709 | 709 | $status = true; |
| 710 | 710 | } else { |
@@ -715,16 +715,16 @@ discard block |
||
| 715 | 715 | $status = true; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - if( $status ) { |
|
| 719 | - if( empty( $invoice_ref ) ) { |
|
| 720 | - $invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 721 | - if( $order_invoice ) { |
|
| 718 | + if ($status) { |
|
| 719 | + if (empty($invoice_ref)) { |
|
| 720 | + $invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 721 | + if ($order_invoice) { |
|
| 722 | 722 | $order_meta['order_invoice_ref'] = $invoice_ref; |
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref; |
| 727 | - $status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 727 | + $status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 728 | 728 | } |
| 729 | 729 | } |
| 730 | 730 | return $status; |
@@ -1,19 +1,19 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | class wps_download_file_ctr { |
| 4 | 4 | public function __construct() { |
| 5 | - add_action( 'admin_post_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
| 6 | - add_action( 'admin_post_nopriv_wps_download_file', array( $this, 'wps_download_file' ) ); |
|
| 5 | + add_action('admin_post_wps_download_file', array($this, 'wps_download_file')); |
|
| 6 | + add_action('admin_post_nopriv_wps_download_file', array($this, 'wps_download_file')); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Function to find download link by |
| 10 | - public static function get_product_download_link( $oid, $item ) { |
|
| 10 | + public static function get_product_download_link($oid, $item) { |
|
| 11 | 11 | $parent_def = array(); |
| 12 | 12 | $item_id = $item['item_id']; |
| 13 | - $item_post_type = get_post_type( $item['item_id'] ); |
|
| 14 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) { |
|
| 15 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 16 | - if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { |
|
| 13 | + $item_post_type = get_post_type($item['item_id']); |
|
| 14 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) { |
|
| 15 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 16 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
| 17 | 17 | $parent_post = $parent_def['parent_post']; |
| 18 | 18 | $item_id = $parent_post->ID; |
| 19 | 19 | } |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | $download_link = false; |
| 23 | 23 | $item_id_for_download = null; |
| 24 | 24 | /** Check if the product or the head product is a download product */ |
| 25 | - if ( ! empty( $parent_def ) ) { |
|
| 25 | + if (!empty($parent_def)) { |
|
| 26 | 26 | $parent_meta = $parent_def['parent_post_meta']; |
| 27 | - if ( ! empty( $parent_meta['is_downloadable_'] ) ) { |
|
| 28 | - $downloadable_option_value = $wpdb->get_var( $wpdb->prepare( 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'] ) ); |
|
| 29 | - if ( ! empty( $downloadable_option_value ) ) { |
|
| 27 | + if (!empty($parent_meta['is_downloadable_'])) { |
|
| 28 | + $downloadable_option_value = $wpdb->get_var($wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'])); |
|
| 29 | + if (!empty($downloadable_option_value)) { |
|
| 30 | 30 | $item['item_is_downloadable_'] = $downloadable_option_value; |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | - if ( ! empty( $item ) && ! empty( $item['item_is_downloadable_'] ) && ( strtolower( __( $item['item_is_downloadable_'], 'wpshop' ) ) === strtolower( __( 'Yes', 'wpshop' ) ) ) ) { |
|
| 34 | + if (!empty($item) && !empty($item['item_is_downloadable_']) && (strtolower(__($item['item_is_downloadable_'], 'wpshop')) === strtolower(__('Yes', 'wpshop')))) { |
|
| 35 | 35 | $item_id_for_download = $item_id; |
| 36 | - if ( isset( $item['item_meta']['variations'] ) ) { |
|
| 37 | - foreach ( $item['item_meta']['variations'] as $variation_id => $variation ) { |
|
| 38 | - if ( isset( $variation['item_meta']['is_downloadable_'] ) ) { |
|
| 36 | + if (isset($item['item_meta']['variations'])) { |
|
| 37 | + foreach ($item['item_meta']['variations'] as $variation_id => $variation) { |
|
| 38 | + if (isset($variation['item_meta']['is_downloadable_'])) { |
|
| 39 | 39 | $item_id_for_download = $item_id . '__' . $variation_id; |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -43,20 +43,20 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** In case there is a item identifier defined for download */ |
| 46 | - if ( null !== $item_id_for_download ) { |
|
| 47 | - $download_codes = get_user_meta( get_current_user_id(), '_order_download_codes_' . $oid, true ); |
|
| 46 | + if (null !== $item_id_for_download) { |
|
| 47 | + $download_codes = get_user_meta(get_current_user_id(), '_order_download_codes_' . $oid, true); |
|
| 48 | 48 | /** Check if the current product exist into download code list, if not check if there is a composition between parent product and children product */ |
| 49 | - if ( empty( $download_codes[ $item_id_for_download ] ) ) { |
|
| 50 | - $item_id_component = explode( '__', $item_id_for_download ); |
|
| 51 | - if ( ! empty( $item_id_component ) && ( $item_id_component[0] !== $item_id_for_download ) ) { |
|
| 49 | + if (empty($download_codes[$item_id_for_download])) { |
|
| 50 | + $item_id_component = explode('__', $item_id_for_download); |
|
| 51 | + if (!empty($item_id_component) && ($item_id_component[0] !== $item_id_for_download)) { |
|
| 52 | 52 | $item_id_for_download = $item_id_component[0]; |
| 53 | - } elseif ( ! empty( $download_codes[ $item['item_id'] ] ) ) { |
|
| 53 | + } elseif (!empty($download_codes[$item['item_id']])) { |
|
| 54 | 54 | $item_id_for_download = $item['item_id']; |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( ! empty( $download_codes ) && ! empty( $download_codes[ $item_id_for_download ] ) && ! empty( $download_codes[ $item_id_for_download ]['download_code'] ) ) { |
|
| 59 | - $download_link = admin_url( 'admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[ $item_id_for_download ]['download_code'] ); |
|
| 58 | + if (!empty($download_codes) && !empty($download_codes[$item_id_for_download]) && !empty($download_codes[$item_id_for_download]['download_code'])) { |
|
| 59 | + $download_link = admin_url('admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[$item_id_for_download]['download_code']); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | return $download_link; |
@@ -64,31 +64,31 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | // Download product downloadable |
| 66 | 66 | public function wps_download_file() { |
| 67 | - $download = !empty( $_GET['download'] ) ? sanitize_text_field( $_GET['download'] ) : ''; |
|
| 68 | - $oid = !empty( $_GET['oid'] ) ? (int) $_GET['oid'] : 0; |
|
| 67 | + $download = !empty($_GET['download']) ? sanitize_text_field($_GET['download']) : ''; |
|
| 68 | + $oid = !empty($_GET['oid']) ? (int)$_GET['oid'] : 0; |
|
| 69 | 69 | |
| 70 | - if ( !empty( $download ) && !empty( $oid ) ) { |
|
| 70 | + if (!empty($download) && !empty($oid)) { |
|
| 71 | 71 | $variation_id = ''; |
| 72 | 72 | $order = get_post_meta($oid, '_order_postmeta', true); |
| 73 | - if(!empty($order) && !empty( $order['customer_id'] )) { |
|
| 74 | - $download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_'.$oid, true); |
|
| 75 | - if ( !empty($download_codes) && is_array($download_codes) ) { |
|
| 76 | - foreach ( $download_codes as $downloadable_product_id => $d ) { |
|
| 73 | + if (!empty($order) && !empty($order['customer_id'])) { |
|
| 74 | + $download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_' . $oid, true); |
|
| 75 | + if (!empty($download_codes) && is_array($download_codes)) { |
|
| 76 | + foreach ($download_codes as $downloadable_product_id => $d) { |
|
| 77 | 77 | $is_encrypted = false; |
| 78 | - if ( $d['download_code'] == $download ) { |
|
| 79 | - wpshop_tools::create_custom_hook ('encrypt_actions_for_downloadable_product', array( 'order_id' => $oid, 'download_product_id' => $downloadable_product_id ) ); |
|
| 78 | + if ($d['download_code'] == $download) { |
|
| 79 | + wpshop_tools::create_custom_hook('encrypt_actions_for_downloadable_product', array('order_id' => $oid, 'download_product_id' => $downloadable_product_id)); |
|
| 80 | 80 | |
| 81 | - if ( get_post_type( $downloadable_product_id ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 82 | - $parent_def = wpshop_products::get_parent_variation( $downloadable_product_id ); |
|
| 83 | - if ( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
| 81 | + if (get_post_type($downloadable_product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 82 | + $parent_def = wpshop_products::get_parent_variation($downloadable_product_id); |
|
| 83 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
| 84 | 84 | $parent_post = $parent_def['parent_post']; |
| 85 | 85 | $variation_id = $downloadable_product_id; |
| 86 | 86 | $downloadable_product_id = $parent_post->ID; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | } else { |
| 90 | - $downloadable_product_id = explode( "__", $downloadable_product_id ); |
|
| 91 | - $downloadable_product_id = isset( $downloadable_product_id[1] ) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
| 90 | + $downloadable_product_id = explode("__", $downloadable_product_id); |
|
| 91 | + $downloadable_product_id = isset($downloadable_product_id[1]) ? $downloadable_product_id[1] : $downloadable_product_id[0]; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $link = wpshop_attributes::get_attribute_option_output( |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | 'is_downloadable_', 'file_url', $order |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - if ( $link !== false ) { |
|
| 99 | + if ($link !== false) { |
|
| 100 | 100 | $uploads = wp_upload_dir(); |
| 101 | 101 | $basedir = $uploads['basedir']; |
| 102 | 102 | $pos = strpos($link, 'uploads'); |
| 103 | - $link = $basedir.substr($link,$pos+7); |
|
| 103 | + $link = $basedir . substr($link, $pos + 7); |
|
| 104 | 104 | /** If plugin is encrypted **/ |
| 105 | - $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); |
|
| 106 | - if ( !empty($encrypted_plugin_path) ) { |
|
| 107 | - $link = WPSHOP_UPLOAD_DIR.$encrypted_plugin_path; |
|
| 105 | + $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); |
|
| 106 | + if (!empty($encrypted_plugin_path)) { |
|
| 107 | + $link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path; |
|
| 108 | 108 | $is_encrypted = true; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $overload_force_download = apply_filters( 'wps_download_file_overload_force_download', false ); |
|
| 112 | - if ( !$overload_force_download ) { |
|
| 111 | + $overload_force_download = apply_filters('wps_download_file_overload_force_download', false); |
|
| 112 | + if (!$overload_force_download) { |
|
| 113 | 113 | wpshop_tools::forceDownload($link, $is_encrypted); |
| 114 | 114 | } |
| 115 | 115 | else { |
| 116 | - wpshop_tools::wpshop_safe_redirect( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $link ) ); |
|
| 116 | + wpshop_tools::wpshop_safe_redirect(str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $link)); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | else { |
| 124 | - wp_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) ); |
|
| 124 | + wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | echo __('Impossible to download the file you requested', 'wpshop'); |
@@ -1,91 +1,91 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | ?> |
| 3 | 3 | <li class="wps-clearfix" id="wps_product_<?php echo $product_key; ?>"> |
| 4 | 4 | <div class="wps-cart-item-img"> |
| 5 | - <?php if ( !$auto_added_product ) : ?><a href="<?php echo get_permalink( $item_id ); ?>" title="<?php echo $item_title; ?>"><?php endif; ?> |
|
| 6 | - <?php echo get_the_post_thumbnail($item['item_id'], 'thumbnail' ); ?> |
|
| 7 | - <?php if ( !$auto_added_product ) : ?></a><?php endif; ?> |
|
| 5 | + <?php if (!$auto_added_product) : ?><a href="<?php echo get_permalink($item_id); ?>" title="<?php echo $item_title; ?>"><?php endif; ?> |
|
| 6 | + <?php echo get_the_post_thumbnail($item['item_id'], 'thumbnail'); ?> |
|
| 7 | + <?php if (!$auto_added_product) : ?></a><?php endif; ?> |
|
| 8 | 8 | </div> |
| 9 | 9 | <div class="wps-cart-item-content"> |
| 10 | - <?php if ( !$auto_added_product && get_post_status( $item_id ) != 'free_product' ) : ?><a href="<?php echo get_permalink( $item_id ); ?>" title="<?php echo $item_title; ?>"><?php endif; ?> |
|
| 10 | + <?php if (!$auto_added_product && get_post_status($item_id) != 'free_product') : ?><a href="<?php echo get_permalink($item_id); ?>" title="<?php echo $item_title; ?>"><?php endif; ?> |
|
| 11 | 11 | <?php echo $item_title; ?> |
| 12 | - <?php if ( !$auto_added_product && get_post_status( $item_id ) != 'free_product' ) : ?></a><?php endif; ?> |
|
| 12 | + <?php if (!$auto_added_product && get_post_status($item_id) != 'free_product') : ?></a><?php endif; ?> |
|
| 13 | 13 | |
| 14 | 14 | <?php echo $variations_indicator; ?> |
| 15 | 15 | |
| 16 | - <?php if ( !empty( $cart_content ) && !empty( $cart_content[ 'order_status' ] ) && ( 'completed' == $cart_content[ 'order_status' ] ) && ( empty($cart_type) || ( !empty($cart_type) && $cart_type == 'summary' ) ) ) : ?> |
|
| 16 | + <?php if (!empty($cart_content) && !empty($cart_content['order_status']) && ('completed' == $cart_content['order_status']) && (empty($cart_type) || (!empty($cart_type) && $cart_type == 'summary'))) : ?> |
|
| 17 | 17 | <?php echo $download_link; ?> |
| 18 | 18 | <?php endif; ?> |
| 19 | 19 | |
| 20 | - <?php echo apply_filters( 'wps_order_item_content_column', '', $item, $oid, $cart_content ); ?> |
|
| 20 | + <?php echo apply_filters('wps_order_item_content_column', '', $item, $oid, $cart_content); ?> |
|
| 21 | 21 | </div> |
| 22 | 22 | |
| 23 | - <?php if( $cart_option == 'simplified_et' ) : ?> |
|
| 23 | + <?php if ($cart_option == 'simplified_et') : ?> |
|
| 24 | 24 | <div class="wps-cart-item-unit-price"> |
| 25 | 25 | <span class="wps-price"> |
| 26 | 26 | <?php |
| 27 | 27 | $price_ati_to_display = $item['item_pu_ttc']; |
| 28 | - if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) { |
|
| 29 | - $price_ati_to_display = $item[ 'item_amount_to_pay_now' ]; |
|
| 28 | + if (!empty($item['item_amount_to_pay_now'])) { |
|
| 29 | + $price_ati_to_display = $item['item_amount_to_pay_now']; |
|
| 30 | 30 | } |
| 31 | 31 | ?> |
| 32 | - <?php echo wpshop_tools::formate_number( $price_ati_to_display ); ?><span><?php echo $currency; ?></span> |
|
| 32 | + <?php echo wpshop_tools::formate_number($price_ati_to_display); ?><span><?php echo $currency; ?></span> |
|
| 33 | 33 | </span> |
| 34 | 34 | </div> |
| 35 | 35 | <?php endif; ?> |
| 36 | 36 | |
| 37 | - <?php if( $cart_option == 'full_cart' ) : ?> |
|
| 37 | + <?php if ($cart_option == 'full_cart') : ?> |
|
| 38 | 38 | <div class="wps-cart-item-unit-price wps-cart-item-unit-price-et"> |
| 39 | - <span class="wps-price"> <?php echo wpshop_tools::formate_number( $item['item_pu_ht'] ); ?><span><?php echo $currency; ?></span></span> |
|
| 39 | + <span class="wps-price"> <?php echo wpshop_tools::formate_number($item['item_pu_ht']); ?><span><?php echo $currency; ?></span></span> |
|
| 40 | 40 | </div> |
| 41 | 41 | <?php endif; ?> |
| 42 | 42 | |
| 43 | - <?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' ) : ?> |
|
| 44 | - <div class="wps-cart-item-unit-price<?php echo ( $cart_option == 'full_cart' ) ? " wps-cart-item-unit-price-ati" : ""; ?>"> |
|
| 45 | - <span class="wps-price"> <?php echo wpshop_tools::formate_number( $item['item_pu_ttc'] ); ?><span><?php echo $currency; ?></span></span> |
|
| 43 | + <?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati') : ?> |
|
| 44 | + <div class="wps-cart-item-unit-price<?php echo ($cart_option == 'full_cart') ? " wps-cart-item-unit-price-ati" : ""; ?>"> |
|
| 45 | + <span class="wps-price"> <?php echo wpshop_tools::formate_number($item['item_pu_ttc']); ?><span><?php echo $currency; ?></span></span> |
|
| 46 | 46 | </div> |
| 47 | 47 | <?php endif; ?> |
| 48 | 48 | |
| 49 | 49 | <div class="wps-cart-item-quantity wps-productQtyForm"> |
| 50 | - <?php if ( ( empty($cart_type) || ( !empty($cart_type) ) ) && !$auto_added_product ) : ?> |
|
| 51 | - <?php if( $cart_type != 'summary' && ( $cart_type != 'admin-panel' || ( $cart_type == 'admin-panel' && ( empty( $cart_content['order_status'] ) || $cart_content['order_status'] == 'awaiting_payment' ) ) ) ) : ?> |
|
| 50 | + <?php if ((empty($cart_type) || (!empty($cart_type))) && !$auto_added_product) : ?> |
|
| 51 | + <?php if ($cart_type != 'summary' && ($cart_type != 'admin-panel' || ($cart_type == 'admin-panel' && (empty($cart_content['order_status']) || $cart_content['order_status'] == 'awaiting_payment')))) : ?> |
|
| 52 | 52 | <a href="" class="wps-cart-reduce-product-qty"><i class="wps-icon-minus"></i></a> |
| 53 | - <input type="text" name="french-hens" id="wps-cart-product-qty-<?php echo $product_key; ?>" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" value="<?php echo $item['item_qty']; ?>" class="wps-circlerounded wps-cart-product-qty"> |
|
| 53 | + <input type="text" name="french-hens" id="wps-cart-product-qty-<?php echo $product_key; ?>" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" value="<?php echo $item['item_qty']; ?>" class="wps-circlerounded wps-cart-product-qty"> |
|
| 54 | 54 | <a href="" class="wps-cart-add-product-qty"><i class="wps-icon-plus"></i></a> |
| 55 | 55 | <?php else : ?> |
| 56 | 56 | <?php echo $item['item_qty']; ?> |
| 57 | - <?php endif;?> |
|
| 58 | - <?php elseif ( $auto_added_product ) : ?> |
|
| 57 | + <?php endif; ?> |
|
| 58 | + <?php elseif ($auto_added_product) : ?> |
|
| 59 | 59 | 1 |
| 60 | 60 | <?php else : ?> |
| 61 | 61 | <?php echo $item['item_qty']; ?> |
| 62 | 62 | <?php endif; ?> |
| 63 | 63 | </div> |
| 64 | 64 | |
| 65 | - <?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_et' ) : ?> |
|
| 65 | + <?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_et') : ?> |
|
| 66 | 66 | <div class="wps-cart-item-price"> |
| 67 | - <span class="wps-price"> <?php echo wpshop_tools::formate_number( $item['item_total_ht'] ); ?><span><?php echo $currency; ?></span></span> |
|
| 68 | - <span class="wps-tva"><?php _e( 'ET', 'wpshop'); ?></span> |
|
| 67 | + <span class="wps-price"> <?php echo wpshop_tools::formate_number($item['item_total_ht']); ?><span><?php echo $currency; ?></span></span> |
|
| 68 | + <span class="wps-tva"><?php _e('ET', 'wpshop'); ?></span> |
|
| 69 | 69 | </div> |
| 70 | 70 | <?php endif; ?> |
| 71 | 71 | |
| 72 | - <?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' ) : ?> |
|
| 72 | + <?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati') : ?> |
|
| 73 | 73 | <div class="wps-cart-item-price"> |
| 74 | 74 | <?php |
| 75 | 75 | $price_total_to_display = $item['item_total_ttc']; |
| 76 | - if ( !empty( $item[ 'item_amount_to_pay_now' ] ) ) { |
|
| 77 | - $price_total_to_display = $item[ 'item_amount_to_pay_now' ] * $item['item_qty']; |
|
| 76 | + if (!empty($item['item_amount_to_pay_now'])) { |
|
| 77 | + $price_total_to_display = $item['item_amount_to_pay_now'] * $item['item_qty']; |
|
| 78 | 78 | } |
| 79 | 79 | ?> |
| 80 | - <span class="wps-price"> <?php echo wpshop_tools::formate_number( $price_total_to_display ); ?><span><?php echo $currency; ?></span></span> |
|
| 80 | + <span class="wps-price"> <?php echo wpshop_tools::formate_number($price_total_to_display); ?><span><?php echo $currency; ?></span></span> |
|
| 81 | 81 | </div> |
| 82 | 82 | <?php endif; ?> |
| 83 | 83 | |
| 84 | 84 | |
| 85 | - <?php if ( empty($cart_type) || ( !empty($cart_type) && $cart_type != 'summary' ) ) : ?> |
|
| 85 | + <?php if (empty($cart_type) || (!empty($cart_type) && $cart_type != 'summary')) : ?> |
|
| 86 | 86 | <div class="wps-cart-item-close"> |
| 87 | - <?php if( $cart_type != 'admin-panel' || ( $cart_type == 'admin-panel' && ( empty( $cart_content['order_status'] ) || $cart_content['order_status'] == 'awaiting_payment' ) ) ) : ?> |
|
| 88 | - <?php if ( !$auto_added_product ) : ?><button type="button" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" class="wps-bton-icon wps_cart_delete_product" id="wps-close-<?php echo $product_key; ?>"><i class="wps-icon-close"></i></button><?php endif; ?> |
|
| 87 | + <?php if ($cart_type != 'admin-panel' || ($cart_type == 'admin-panel' && (empty($cart_content['order_status']) || $cart_content['order_status'] == 'awaiting_payment'))) : ?> |
|
| 88 | + <?php if (!$auto_added_product) : ?><button type="button" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" class="wps-bton-icon wps_cart_delete_product" id="wps-close-<?php echo $product_key; ?>"><i class="wps-icon-close"></i></button><?php endif; ?> |
|
| 89 | 89 | <?php endif; ?> |
| 90 | 90 | </div> |
| 91 | 91 | <?php endif; ?> |
@@ -1,97 +1,97 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | - if( !$account_origin ) : ?> |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | + if (!$account_origin) : ?> |
|
| 3 | 3 | <div id="wps_cart_error_container" class="wps-alert-error"></div> |
| 4 | 4 | <?php endif; ?> |
| 5 | 5 | <ul class="wps-fullcart"> |
| 6 | 6 | <li class="wps-clearfix cart_header"> |
| 7 | 7 | <div class="wps-cart-item-img"></div> |
| 8 | 8 | |
| 9 | - <div class="wps-cart-item-content"><?php _e( 'Product name', 'wpshop'); ?></div> |
|
| 9 | + <div class="wps-cart-item-content"><?php _e('Product name', 'wpshop'); ?></div> |
|
| 10 | 10 | |
| 11 | - <?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' ) : ?> |
|
| 12 | - <div class="wps-cart-item-unit-price"><?php _e( 'P.U', 'wpshop' ); ?></div> |
|
| 11 | + <?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati') : ?> |
|
| 12 | + <div class="wps-cart-item-unit-price"><?php _e('P.U', 'wpshop'); ?></div> |
|
| 13 | 13 | <?php endif; ?> |
| 14 | - <?php if( $cart_option == 'simplified_et' ) : ?> |
|
| 15 | - <div class="wps-cart-item-unit-price"><?php _e( 'Unit price ET', 'wpshop' ); ?></div> |
|
| 14 | + <?php if ($cart_option == 'simplified_et') : ?> |
|
| 15 | + <div class="wps-cart-item-unit-price"><?php _e('Unit price ET', 'wpshop'); ?></div> |
|
| 16 | 16 | <?php endif; ?> |
| 17 | 17 | |
| 18 | - <div class="wps-cart-item-quantity"><?php _e( 'Qty', 'wpshop'); ?></div> |
|
| 18 | + <div class="wps-cart-item-quantity"><?php _e('Qty', 'wpshop'); ?></div> |
|
| 19 | 19 | |
| 20 | - <?php if( $cart_option == 'full_cart' || $cart_option == 'simplified_ati' ) : ?> |
|
| 21 | - <div class="wps-cart-item-price"><?php _e( 'Total', 'wpshop' ); ?></div> |
|
| 20 | + <?php if ($cart_option == 'full_cart' || $cart_option == 'simplified_ati') : ?> |
|
| 21 | + <div class="wps-cart-item-price"><?php _e('Total', 'wpshop'); ?></div> |
|
| 22 | 22 | <?php endif; ?> |
| 23 | - <?php if( $cart_option == 'simplified_et' ) : ?> |
|
| 24 | - <div class="wps-cart-item-price"><?php _e( 'Total ET', 'wpshop' ); ?></div> |
|
| 23 | + <?php if ($cart_option == 'simplified_et') : ?> |
|
| 24 | + <div class="wps-cart-item-price"><?php _e('Total ET', 'wpshop'); ?></div> |
|
| 25 | 25 | <?php endif; ?> |
| 26 | - <?php if ( empty($cart_type) || ( !empty($cart_type) && $cart_type != 'summary' ) ) : ?> |
|
| 26 | + <?php if (empty($cart_type) || (!empty($cart_type) && $cart_type != 'summary')) : ?> |
|
| 27 | 27 | <div class="wps-cart-item-close"></div> |
| 28 | 28 | <?php endif; ?> |
| 29 | 29 | </li> |
| 30 | 30 | |
| 31 | 31 | <?php |
| 32 | - foreach( $cart_items as $item_id => $item ) : |
|
| 32 | + foreach ($cart_items as $item_id => $item) : |
|
| 33 | 33 | $product_key = $item_id; |
| 34 | 34 | /** Check if it's a product or a variation **/ |
| 35 | - $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true) ) ; |
|
| 35 | + $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); |
|
| 36 | 36 | $output_order = array(); |
| 37 | - if ( count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail) ) { |
|
| 38 | - foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { |
|
| 39 | - foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) { |
|
| 40 | - if ( !empty($attribute_def->code) ) |
|
| 37 | + if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) { |
|
| 38 | + foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { |
|
| 39 | + foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { |
|
| 40 | + if (!empty($attribute_def->code)) |
|
| 41 | 41 | $output_order[$attribute_def->code] = $position; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | - $variation_attribute_ordered = wpshop_products::get_selected_variation_display( $item['item_meta'], $output_order, 'cart' ); |
|
| 45 | + $variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'cart'); |
|
| 46 | 46 | ksort($variation_attribute_ordered['attribute_list']); |
| 47 | 47 | $variations_indicator = ''; |
| 48 | - if( !empty($variation_attribute_ordered['attribute_list']) ) { |
|
| 48 | + if (!empty($variation_attribute_ordered['attribute_list'])) { |
|
| 49 | 49 | |
| 50 | 50 | $variations_indicator .= '<ul class="wps-cart-item-variations" >'; |
| 51 | - foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) { |
|
| 52 | - if ( !empty($attribute_variation_to_output) ) { |
|
| 51 | + foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { |
|
| 52 | + if (!empty($attribute_variation_to_output)) { |
|
| 53 | 53 | $variations_indicator .= $attribute_variation_to_output; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | - $variations_indicator = apply_filters( 'wps_cart_item_variation_list', $variations_indicator, $variation_attribute_ordered, $item, $oid ); |
|
| 56 | + $variations_indicator = apply_filters('wps_cart_item_variation_list', $variations_indicator, $variation_attribute_ordered, $item, $oid); |
|
| 57 | 57 | $variations_indicator .= '</ul>'; |
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $item_title = $item['item_name']; |
| 62 | - $item_post_type = get_post_type( $item['item_id'] ); |
|
| 63 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) { |
|
| 64 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 65 | - if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { |
|
| 62 | + $item_post_type = get_post_type($item['item_id']); |
|
| 63 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) { |
|
| 64 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 65 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
| 66 | 66 | $parent_post = $parent_def['parent_post']; |
| 67 | 67 | $item_id = $parent_post->ID; |
| 68 | 68 | $item_title = $parent_post->post_title; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $download_link = wps_download_file_ctr::get_product_download_link( $oid, $item ); |
|
| 73 | - if ( false === $download_link ) { |
|
| 72 | + $download_link = wps_download_file_ctr::get_product_download_link($oid, $item); |
|
| 73 | + if (false === $download_link) { |
|
| 74 | 74 | $download_link = ''; |
| 75 | 75 | } else { |
| 76 | - $download_link = '<a href="' . $download_link . '" target="_blank" class="wps-bton-fourth-mini-rounded">' . __( 'Download the product', 'wpshop' ) . '</a>'; |
|
| 76 | + $download_link = '<a href="' . $download_link . '" target="_blank" class="wps-bton-fourth-mini-rounded">' . __('Download the product', 'wpshop') . '</a>'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** Check if product is an auto added product : don't display link to product, quantity and remover */ |
| 80 | 80 | $auto_added_product = false; |
| 81 | - $item_options = get_post_meta( $item_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true ); |
|
| 82 | - if ( ! empty( $item_options['cart'] ) && ! empty( $item_options['cart']['auto_add'] ) && ( $item_options['cart']['auto_add'] == 'yes' ) ) : |
|
| 81 | + $item_options = get_post_meta($item_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true); |
|
| 82 | + if (!empty($item_options['cart']) && !empty($item_options['cart']['auto_add']) && ($item_options['cart']['auto_add'] == 'yes')) : |
|
| 83 | 83 | $auto_added_product = true; |
| 84 | 84 | endif; |
| 85 | 85 | |
| 86 | - require( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR,"frontend", "cart/cart", "item") ); |
|
| 86 | + require(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart", "item")); |
|
| 87 | 87 | endforeach; |
| 88 | 88 | ?> |
| 89 | 89 | </ul> |
| 90 | -<?php if( ! is_admin() ) { |
|
| 91 | - require_once( wpshop_tools::get_template_part( WPS_CART_DIR, WPS_CART_TPL_DIR,"frontend", "cart/cart", "total") ); |
|
| 90 | +<?php if (!is_admin()) { |
|
| 91 | + require_once(wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "cart/cart", "total")); |
|
| 92 | 92 | } else { |
| 93 | - require_once( WPS_CART_TPL_DIR . "frontend/cart/cart-total.php" ); |
|
| 93 | + require_once(WPS_CART_TPL_DIR . "frontend/cart/cart-total.php"); |
|
| 94 | 94 | } ?> |
| 95 | -<?php if ( empty($cart_type) || ( !empty($cart_type) && $cart_type != 'summary' ) ) : ?> |
|
| 96 | -<?php echo apply_filters( 'wps_cart_footer_extra_content', ''); ?> |
|
| 95 | +<?php if (empty($cart_type) || (!empty($cart_type) && $cart_type != 'summary')) : ?> |
|
| 96 | +<?php echo apply_filters('wps_cart_footer_extra_content', ''); ?> |
|
| 97 | 97 | <?php endif?> |