Exemplo n.º 1
0
 /**
  * Add product if is queried and recalcule cart informations
  * @param array $product_list
  * @param string $custom_order_information
  * @param array $current_cart
  * @param boolean $from_admin
  * @return array
  */
 function calcul_cart_information($product_list, $custom_order_information = '', $current_cart = array(), $from_admin = false)
 {
     // Price piloting option
     $price_piloting = get_option('wpshop_shop_price_piloting');
     // Init vars
     $cart_infos = !empty($current_cart) ? $current_cart : (!empty($_SESSION) && !empty($_SESSION['cart']) && !$from_admin ? $_SESSION['cart'] : array());
     $cart_items = !empty($current_cart) && !empty($current_cart['order_items']) ? $current_cart['order_items'] : array();
     $cart_items = !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !$from_admin ? $_SESSION['cart']['order_items'] : $cart_items;
     $order_total_ht = $order_total_ttc = $total_vat = 0;
     $order_tva = array();
     $total_weight = $nb_of_items = $order_shipping_cost_by_article = 0;
     $order_discount_rate = $order_discount_amount = $order_items_discount_amount = $order_total_discount_amount = 0;
     // If Product list is not empty, add products to order
     if (!empty($product_list)) {
         foreach ($product_list as $product_id => $d) {
             $product_key = $product_id;
             if (isset($d['product_qty'])) {
                 // Formate datas
                 $product_id = $head_product_id = $d['product_id'];
                 $product_qty = $d['product_qty'];
                 $product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
                 // If product is a single variation product
                 if (!empty($product_variation) && count($product_variation) == 1) {
                     $product_id = $product_variation[0];
                 }
                 // Construct final product
                 $product = wpshop_products::get_product_data($d['product_id'], true, '"publish", "free_product"');
                 $the_product = array_merge(array('product_id' => $d['product_id'], 'product_qty' => $product_qty), $product);
                 //	Add variation to product into cart for storage
                 if (!empty($product_variation)) {
                     $the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
                 }
                 // Free Variations Checking
                 if (!empty($d['free_variation'])) {
                     $the_product['item_meta']['free_variation'] = $d['free_variation'];
                     $head_product_id = $the_product['product_id'];
                 }
                 // If product is a variation, we check parent product general
                 if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                     $parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
                     if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                         $variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
                         $parent_meta = $parent_def['parent_post_meta'];
                         if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
                             $the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
                             $the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
                             $the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
                         }
                     }
                 }
                 // Delete product if its qty is equals to zero, else add this product to order
                 if (empty($d['product_qty'])) {
                     unset($cart_items[$product_key]);
                     unset($cart_infos['order_items'][$product_key]);
                 } else {
                     $wps_orders = new wps_orders_ctr();
                     $cart_items[$product_key] = $wps_orders->add_product_to_order($the_product);
                 }
             }
         }
     }
     // Add automaticaly Add-to-cart Products
     $cart_items = $this->add_automaticaly_product_to_cart($cart_items);
     // Calcul Cart Informations
     if (!empty($cart_items) && is_array($cart_items)) {
         foreach ($cart_items as $item_id => $item) {
             $order_total_ht += $item['item_total_ht'];
             $order_total_ttc += $item['item_total_ttc'];
             // VAT
             if (!empty($order_tva[$item['item_tva_rate']])) {
                 $order_tva[$item['item_tva_rate']] += $item['item_tva_total_amount'];
             } else {
                 $order_tva[$item['item_tva_rate']] = $item['item_tva_total_amount'];
             }
         }
     } else {
         return array();
     }
     // Apply informations to cart
     $cart_infos['order_items'] = $cart_items;
     $cart_infos['order_total_ht'] = $order_total_ht;
     $cart_infos['order_total_ttc'] = $order_total_ttc;
     // Calcul Shipping cost
     if (!$from_admin) {
         $wps_shipping = new wps_shipping();
         $total_cart_ht_or_ttc_regarding_config = !empty($price_piloting) && $price_piloting == 'HT' ? $cart_infos['order_total_ht'] : $cart_infos['order_total_ttc'];
         $cart_weight = $wps_shipping->calcul_cart_weight($cart_infos['order_items']);
         $total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost($cart_infos['order_items']);
         $cart_infos['order_shipping_cost'] = $wps_shipping->get_shipping_cost(count($cart_infos['order_items']), $total_cart_ht_or_ttc_regarding_config, $total_shipping_cost_for_products, $cart_weight);
     }
     // If Price piloting is ET, calcul VAT on Shipping cost
     if (!empty($price_piloting) && $price_piloting == 'HT') {
         $shipping_cost_vat = !empty($cart_infos['order_shipping_cost']) ? WPSHOP_VAT_ON_SHIPPING_COST / 100 * number_format($cart_infos['order_shipping_cost'], 2, '.', '') : 0;
         $order_tva['VAT_shipping_cost'] = $shipping_cost_vat;
     }
     // Calcul VAT Total
     if (!empty($order_tva)) {
         foreach ($order_tva as $vat_rate => $vat_value) {
             $total_vat += $vat_value;
         }
     }
     // Recap totals
     $cart_infos['order_total_ttc'] = $cart_infos['order_total_ht'] + (!empty($cart_infos) && !empty($cart_infos['order_shipping_cost']) ? $cart_infos['order_shipping_cost'] : 0) + $total_vat;
     $cart_infos['order_grand_total_before_discount'] = $cart_infos['order_amount_to_pay_now'] = $cart_infos['order_grand_total'] = $cart_infos['order_total_ttc'];
     // Apply coupons
     if (!empty($_SESSION['cart']) && !$from_admin) {
         if (!empty($_SESSION['cart']['coupon_id'])) {
             $wps_coupon_mdl = new wps_coupon_model();
             $coupon = $wps_coupon_mdl->get_coupon_data($_SESSION['cart']['coupon_id']);
             if (!empty($coupon) && !empty($coupon['wpshop_coupon_code'])) {
                 $wps_coupon = new wps_coupon_ctr();
                 $coupon_checking = $wps_coupon->applyCoupon($coupon['wpshop_coupon_code']);
                 // If Coupon conditions are Ok
                 if (!empty($coupon_checking) && !empty($coupon_checking['status']) && $coupon_checking['status']) {
                     $cart_infos['order_discount_type'] = $coupon['wpshop_coupon_discount_type'];
                     $cart_infos['order_discount_value'] = $coupon['wpshop_coupon_discount_value'];
                 }
             }
         }
     }
     // Checking Discounts
     if (!empty($cart_infos['order_discount_type']) && $cart_infos['order_discount_value']) {
         // Calcul discount on Order
         switch ($cart_infos['order_discount_type']) {
             case 'amount':
                 $cart_infos['order_discount_amount_total_cart'] = number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '');
                 break;
             case 'percent':
                 $cart_infos['order_discount_amount_total_cart'] = number_format($cart_infos['order_grand_total'], 2, '.', '') * (number_format(str_replace(',', '.', $cart_infos['order_discount_value']), 2, '.', '') / 100);
                 break;
         }
         $cart_infos['order_grand_total'] -= number_format($cart_infos['order_discount_amount_total_cart'], 2, '.', '');
         $cart_infos['order_amount_to_pay_now'] = number_format($cart_infos['order_grand_total'], 2, '.', '');
     }
     // Apply Partial Payments
     $wpshop_payment = new wpshop_payment();
     $partial_payment = $wpshop_payment->partial_payment_calcul($cart_infos['order_grand_total']);
     if (!empty($partial_payment['amount_to_pay'])) {
         unset($partial_payment['display']);
         $cart_infos['order_partial_payment'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
         $cart_infos['order_amount_to_pay_now'] = number_format(str_replace(',', '.', $partial_payment['amount_to_pay']), 2, '.', '');
     }
     // Cart Type
     if (isset($_SESSION['cart']['cart_type'])) {
         $cart_infos['cart_type'] = $_SESSION['cart']['cart_type'];
     }
     // Apply Extra actions on cart infos
     $cart_infos = apply_filters('wps_extra_calcul_in_cart', $cart_infos, $_SESSION);
     return $cart_infos;
 }
Exemplo n.º 2
0
/**
 * Refresh Price in complete product sheet and Cart summary display
 */
function wpshop_ajax_wpshop_variation_selection()
{
    global $wpdb;
    $wpshop_cart = new wps_cart();
    $wpshop_products = new wpshop_products();
    $response = '';
    $response_status = $has_variation = false;
    $tpl_component = array();
    //Sended vars
    $product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null;
    $wpshop_variation_selected = isset($_POST['wpshop_variation']) ? $_POST['wpshop_variation'] : null;
    $wpshop_free_variation = isset($_POST['wpshop_free_variation']) ? $_POST['wpshop_free_variation'] : null;
    $wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? $_POST['wpshop_current_for_display'] : null;
    $product_qty = isset($_POST['product_qty']) ? $_POST['product_qty'] : 1;
    // Check if variations exists
    if (!empty($wpshop_variation_selected) || !empty($wpshop_free_variation)) {
        //Recover all selected variations
        $variations_selected = array();
        if (!empty($wpshop_variation_selected)) {
            foreach ($wpshop_variation_selected as $selected_variation) {
                $variation_definition = explode('-_variation_val_-', $selected_variation);
                $variations_selected[$variation_definition[0]] = $variation_definition[1];
            }
        }
        // Check variations priority
        $product_with_variation = wpshop_products::get_variation_by_priority($variations_selected, $product_id);
        // Check if $product_with_variation have variations
        if (!empty($product_with_variation[$product_id]['variations']) || !empty($wpshop_free_variation)) {
            $formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $variations_selected);
            $product_to_add_to_cart = $formatted_product[0];
            foreach ($formatted_product[0] as $pid => $product_more_content) {
                $order_items[$pid]['product_id'] = $product_more_content['id'];
                /** For product with variation	*/
                $order_items[$pid]['product_variation_type'] = !empty($product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
                $order_items[$pid]['free_variation'] = !empty($product_more_content['free_variation']) ? $product_more_content['free_variation'] : '';
                $order_items[$pid]['product_variation'] = '';
                if (!empty($product_more_content['variations'])) {
                    foreach ($product_more_content['variations'] as $variation_id) {
                        $order_items[$pid]['product_variation'][] = $variation_id;
                    }
                }
            }
            // If Product list is not empty, add products to order
            if (!empty($order_items)) {
                foreach ($order_items as $product_id => $d) {
                    $product_key = $product_id;
                    // Formate datas
                    $product_id = $head_product_id = $d['product_id'];
                    $product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
                    // If product is a single variation product
                    if (!empty($product_variation) && count($product_variation) == 1) {
                        $product_id = $product_variation[0];
                    }
                    // Construct final product
                    $product = wpshop_products::get_product_data($d['product_id'], true);
                    $the_product = array_merge(array('product_id' => $d['product_id'], 'product_qty' => 1), $product);
                    //	Add variation to product into cart for storage
                    if (!empty($product_variation)) {
                        $the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
                    }
                    // Free Variations Checking
                    if (!empty($d['free_variation'])) {
                        $the_product['item_meta']['free_variation'] = $d['free_variation'];
                        $head_product_id = $the_product['product_id'];
                    }
                    // If product is a variation, we check parent product general
                    if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                        $parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
                        if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                            $variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
                            $parent_meta = $parent_def['parent_post_meta'];
                            if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
                                $the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
                                $the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
                                $the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
                            }
                        }
                    }
                }
            }
            if (!empty($the_product) && empty($the_product['price_ttc_before_discount']) && empty($the_product['price_ht_before_discount'])) {
                $price_infos = wpshop_prices::check_product_price($the_product, true);
                if (!empty($price_infos['discount']['discount_exist'])) {
                    $the_product['price_ttc_before_discount'] = $the_product['product_price'];
                    $the_product['price_ht_before_discount'] = $the_product['price_ht'];
                }
                $the_product['price_ht'] = !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist'] ? $price_infos['discount']['discount_et_price'] : $price_infos['et'];
                $the_product['product_price'] = !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist'] ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati'];
                $the_product['tva'] = !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist'] ? $price_infos['discount']['discount_tva'] : $price_infos['tva'];
            }
            $product = wpshop_products::get_product_data($product_id, true);
            // Add free variations to product
            if (!empty($wpshop_free_variation)) {
                $the_product['item_meta']['free_variation'] = $wpshop_free_variation;
            }
            // Change picture if have a selected variation
            $the_selected_variation = !empty($product_with_variation) && !empty($product_with_variation[$head_product_id]) && !empty($product_with_variation[$head_product_id]['variations']) ? $product_with_variation[$head_product_id]['variations'] : null;
            $response['wps_product_image'] = $wpshop_products->wps_selected_variation_picture($head_product_id, $the_selected_variation);
            // Price Display
            $price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
            $price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
            $productPrice = '';
            if ($price_display) {
                $response['product_price_output'] = wpshop_prices::get_product_price($the_product, 'price_display', 'complete_sheet', false, true);
            }
            //Get Summary cart
            $response['product_output'] = $wpshop_products->wps_get_summary_variations_product($product_id, $the_product, !empty($wpshop_variation_selected) || !empty($wpshop_free_variation) ? true : false);
            $response_status = true;
        } else {
            //Product without variations
            $product_data = wpshop_products::get_product_data($product_id);
            $response['product_price_output'] = wpshop_prices::get_product_price($product_data, 'price_display', 'complete_sheet');
        }
    }
    echo json_encode(array($response_status, $response));
    wp_die();
}
Exemplo n.º 3
0
 public static function get_product_price($product, $return_type, $output_type = '', $only_price = false, $price_checking_done = false)
 {
     $wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting');
     // 			$wpshop_price_piloting_option = 'TTC';
     /** Price for Mini-output **/
     if (!$price_checking_done) {
         /** Checking if it's a product with variation **/
         $variation_option_checking = get_post_meta($product['product_id'], '_wpshop_variation_defining', true);
         if (!empty($variation_option_checking)) {
             $variations_exists = wpshop_products::get_variation($product['product_id']);
         }
         if (!empty($variation_option_checking) && !empty($variations_exists)) {
             if (!empty($variation_option_checking['attributes'])) {
                 foreach ($variation_option_checking['attributes'] as $attribute) {
                     $selected_variation[$attribute] = 0;
                     if (!empty($variation_option_checking['options']) && !empty($variation_option_checking['options']['attributes_default_value']) && array_key_exists($attribute, $variation_option_checking['options']['attributes_default_value'])) {
                         if ($variation_option_checking['options']['attributes_default_value'][$attribute] != 'none') {
                             $selected_variation[$attribute] = $variation_option_checking['options']['attributes_default_value'][$attribute];
                         }
                     }
                 }
             }
             if (!empty($selected_variation)) {
                 $product_with_variation = wpshop_products::get_variation_by_priority($selected_variation, $product['product_id']);
             }
             if (empty($product_with_variation[$product['product_id']]['variations'])) {
                 $product_with_variation[$product['product_id']]['variations'] = array();
             }
             if (!empty($product_with_variation[$product['product_id']]['variation_priority'])) {
                 $product = wpshop_products::get_variation_price_behaviour($product, $product_with_variation[$product['product_id']]['variations'], $product['product_id'], array('type' => $product_with_variation[$product['product_id']]['variation_priority'], 'text_from' => !empty($product_with_variation['text_from']) ? 'on' : ''));
             }
         } else {
             /** It's Simple product Check Discounts for products **/
             $discount_config = self::check_discount_for_product($product['product_id']);
             if (!empty($discount_config)) {
                 if (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price') {
                     $product['price_ttc_before_discount'] = $product['product_price'];
                     $product['price_ht_before_discount'] = $product['price_ht'];
                     $product['price_ht'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] / 100);
                     $product['product_price'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $discount_config['value'] * (1 + $product['tx_tva'] / 100) : $discount_config['value'];
                     $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100);
                 } elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount') {
                     $product['price_ttc_before_discount'] = $product['product_price'];
                     $product['price_ht_before_discount'] = $product['price_ht'];
                     $product['price_ht'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $product['price_ht_before_discount'] - $discount_config['value'] : ($product['price_ttc_before_discount'] - $discount_config['value']) / (1 + $product['tx_tva'] / 100);
                     $product['product_price'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] - $discount_config['value'];
                     $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100);
                 } elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') {
                     $product['price_ttc_before_discount'] = $product['product_price'];
                     $product['price_ht_before_discount'] = $product['price_ht'];
                     $product['price_ht'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $product['price_ht_before_discount'] * (1 - $discount_config['value'] / 100) : $product['price_ttc_before_discount'] * (1 - $discount_config['value'] / 100) / (1 + $product['tx_tva'] / 100);
                     $product['product_price'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] * (1 - $discount_config['value'] / 100);
                     $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100);
                 }
             }
         }
     }
     $price_infos = self::check_product_price($product);
     $productCurrency = '<span class="wps-currency">' . wpshop_tools::wpshop_get_currency() . '</span>';
     $wps_marketing_tools = new wps_marketing_tools_ctr();
     if (!empty($price_infos)) {
         if ($return_type == 'check_only') {
             /** Check if the product price has been set	*/
             if (isset($price_infos['ati']) && $price_infos['ati'] === '') {
                 return __('This product cannot be purchased - the price is not yet announced', 'wpshop');
             }
             /** Check if the product price is coherent (not less than 0)	*/
             if (isset($price_infos['ati']) && $price_infos['ati'] < 0) {
                 return __('This product cannot be purchased - its price is negative', 'wpshop');
             }
             return true;
         } elseif ($return_type == 'just_price_infos') {
             $tpl_component = array();
             $price = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $price_infos['et'] : $price_infos['ati'];
             $exploded_price = explode('.', number_format($price, 2, '.', ''));
             $price = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">,' . (!empty($exploded_price[1]) ? $exploded_price[1] : '') . '</span>';
             $tpl_component['TAX_PILOTING'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? __('ET', 'wpshop') : '';
             $tpl_component['CROSSED_OUT_PRICE'] = '';
             $tpl_component['MESSAGE_SAVE_MONEY'] = '';
             if (!empty($price_infos['discount']['discount_exist'])) {
                 $crossed_out_price = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2)) . ' ' . $productCurrency;
                 $tpl_component['CROSSED_OUT_PRICE'] = $crossed_out_price;
                 if (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') {
                     $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_et_price'], 2, '.', ''));
                 } else {
                     $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_ati_price'], 2, '.', ''));
                 }
                 $discount_price = $exploded_discount_price[0] . '<span class="wpshop_price_centimes_display">,' . (!empty($exploded_discount_price[1]) ? $exploded_discount_price[1] : '') . '</span>';
                 $tpl_component['PRODUCT_PRICE'] = '<span class="wps-absolute-price">' . $discount_price . '</span> ' . $productCurrency;
                 $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money($price_infos);
             } else {
                 $tpl_component['PRODUCT_PRICE'] = $price . ' ' . $productCurrency;
             }
             $post_type = get_post_type($product['product_id']);
             if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
                 $price_display_attribute = get_post_meta($product['product_id'], '_wpshop_variation_defining', true);
             } elseif ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                 $parent_def = wpshop_products::get_parent_variation($product['product_id']);
                 if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                     $parent_post = $parent_def['parent_post'];
                     $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true);
                 }
             }
             $price_display_option = get_option('wpshop_catalog_product_option');
             $tpl_component['PRICE_FROM'] = !empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) || !empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']))) ? 'on' : '';
             return $tpl_component;
         } else {
             if ($return_type == 'price_display') {
                 $tpl_component = array();
                 $price = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? $price_infos['et'] : $price_infos['ati'];
                 $price_data = $price_infos;
                 $exploded_price = explode('.', number_format($price, 2, '.', ''));
                 $price = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . (!empty($exploded_price[1]) ? $exploded_price[1] : '') . '</span>';
                 $tpl_component['TAX_PILOTING'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? __('ET', 'wpshop') : '';
                 $tpl_component['CROSSED_OUT_PRICE'] = '';
                 $tpl_component['MESSAGE_SAVE_MONEY'] = '';
                 if (!empty($price_infos['discount']['discount_exist'])) {
                     $text_from = false;
                     /** Get variation defining **/
                     $post_type = get_post_type($product['product_id']);
                     if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                         $parent_def = wpshop_products::get_parent_variation($product['product_id']);
                         if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                             $parent_post = $parent_def['parent_post'];
                             $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true);
                         }
                     } else {
                         $price_display_attribute = get_post_meta($product['product_id'], '_wpshop_variation_defining', true);
                     }
                     $text_from = !empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) || !empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']))) && !empty($product['text_from']) ? true : false;
                     $exploded_price = explode('.', number_format($price_infos['discount']['discount_et_price'], 2, '.', ''));
                     $price_infos['discount']['discount_et_price'] = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . (!empty($exploded_price[1]) ? $exploded_price[1] : '') . '</span>';
                     $exploded_price = explode('.', number_format($price_infos['discount']['discount_ati_price'], 2, '.', ''));
                     $price_infos['discount']['discount_ati_price'] = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . (!empty($exploded_price[1]) ? $exploded_price[1] : '') . '</span>';
                     $crossed_out_price = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2)) . ' ' . $productCurrency;
                     $tpl_component['CROSSED_OUT_PRICE'] = str_replace('.', ',', ($text_from ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $crossed_out_price)));
                     $tpl_component['PRODUCT_PRICE'] = !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ? '<span class="wps-absolute-price">' . $price_infos['discount']['discount_et_price'] . '</span> ' . $productCurrency : '<span class="wps-absolute-price">' . $price_infos['discount']['discount_ati_price'] . '</span> ' . $productCurrency;
                     $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money($price_data);
                 } else {
                     if (get_post_type($product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                         $parent_def = wpshop_products::get_parent_variation($product['product_id']);
                         $pid = $parent_def['parent_post'];
                         $pid = $pid->ID;
                     } else {
                         $pid = $product['product_id'];
                     }
                     $text_from = false;
                     /** Get variation defining **/
                     $post_type = get_post_type($pid);
                     if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                         $parent_def = wpshop_products::get_parent_variation($pid);
                         if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                             $parent_post = $parent_def['parent_post'];
                             $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true);
                         }
                     } else {
                         $price_display_attribute = get_post_meta($pid, '_wpshop_variation_defining', true);
                     }
                     $price_display_attribute = get_post_meta($pid, '_wpshop_variation_defining', true);
                     $text_from = !empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) || !empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']))) ? true : false;
                     $tpl_component['PRODUCT_PRICE'] = $text_from && !empty($product['text_from']) ? __('Price from', 'wpshop') . ' ' : '';
                     $tpl_component['PRODUCT_PRICE'] .= $price . ' ' . $productCurrency;
                 }
                 // Replace . by ,
                 $tpl_component['PRODUCT_PRICE'] = str_replace('.', ',', $tpl_component['PRODUCT_PRICE']);
                 if ($output_type == 'complete_sheet') {
                     $price_tpl = wpshop_display::display_template_element('product_price_template_complete_sheet', $tpl_component);
                 } elseif ($output_type == 'mini_output' || in_array('mini_output', $output_type)) {
                     $price_tpl = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component);
                 }
                 return $price_tpl;
             }
         }
     }
     return false;
 }