<?php echo wpshop_tools::trunk($order_item['item_name'], 50); ?> <?php $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($order_item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); $output_order = array(); if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) { foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { if (!empty($attribute_def->code)) { $output_order[$attribute_def->code] = $position; } } } } $variation_attribute_ordered = wpshop_products::get_selected_variation_display($order_item['item_meta'], $output_order, 'cart'); ksort($variation_attribute_ordered['attribute_list']); ?> <?php if (!empty($variation_attribute_ordered['attribute_list'])) { ?> <ul class="wps-cart-item-variations" > <?php foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { ?> <?php if (!empty($attribute_variation_to_output)) { ?> <?php echo $attribute_variation_to_output; ?>
function wps_get_summary_variations_product($product_id, $the_product, $has_variation) { global $wpdb; global $wpshop_payment; $output = ''; $tpl_component = array(); /** Get attribute order for current product */ $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); $output_order = array(); if (count($product_attribute_order_detail) > 0) { foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { if (!empty($attribute_def->code)) { $output_order[$attribute_def->code] = $position; } } } } $variation_attribute_ordered = array(); /** Check if product is a variation and change his name **/ $product_post_type = get_post_type($the_product['product_id']); if (!empty($product_post_type) && $product_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { $parent_infos = wpshop_products::get_parent_variation($the_product['product_id']); $parent_post = !empty($parent_infos) && !empty($parent_infos['parent_post']) ? $parent_infos['parent_post'] : array(); $the_product['product_name'] = $the_product['post_title'] = $parent_post->post_title; } foreach ($the_product as $product_definition_key => $product_definition_value) { if ($product_definition_key != 'item_meta') { $tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value; if (!empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES))) { $tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value; } } else { $variation_attribute_ordered = wpshop_products::get_selected_variation_display($product_definition_value, $output_order, 'selection_summary'); } } ksort($variation_attribute_ordered['attribute_list']); $tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] = ''; foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { $tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] .= $attribute_variation_to_output; } /** For security get all attributes defined as user defined or used in variation in order to set default value to empty */ $attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_for_variation", true); if (!empty($attribute_list)) { foreach ($attribute_list as $attribute_def) { $tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute_def->code)] = '-'; } } /** Fill the array with all prices for different variations */ foreach ($variation_attribute_ordered['prices'] as $attribute => $prices) { $tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute)] = $prices; } $tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = ''; $query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options'); $post_list_with_options = $wpdb->get_results($query); if (!empty($post_list_with_options)) { $additionnal_price = 0; foreach ($post_list_with_options as $product_info) { $product_meta = unserialize($product_info->meta_value); if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && $product_meta['cart']['auto_add'] == 'yes') { $product = wpshop_products::get_product_data($product_info->post_id, true, '"publish", "draft"'); $the_product = array_merge(array('product_id' => $product_info->post_id, 'product_qty' => 1), $product); $additionnal_price += !$different_currency || $change_rate == 1 ? $the_product['product_price'] : $the_product['product_price'] * $change_rate; $tpl_component['AUTO_PRODUCT_NAME'] = $the_product['product_name']; $tpl_component['AUTO_PRODUCT_PRODUCT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', !$different_currency || $change_rate == 1 ? $the_product['product_price'] : $the_product['product_price'] * $change_rate); $tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_auto_product', $tpl_component); } } } $tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = ''; $tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = ''; if (!empty($additionnal_price)) { $tpl_component['SUMMARY_FINAL_RESULT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', $tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price); $tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = $tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price; $tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_final_result', $tpl_component); } /** Call informtion for partial payment */ $partial_payment = $wpshop_payment->partial_payment_calcul($tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT']); $tpl_component['PARTIAL_PAYMENT_INFO'] = !empty($partial_payment['amount_to_pay']) ? $partial_payment['display'] : ''; /** Define the current selected currency for the order summary */ // $response['product_output'] = $has_variation ? wpshop_display::display_template_element('wpshop_product_configuration_summary_detail', $tpl_component) : ''; $output = $has_variation ? wpshop_display::display_template_element('wpshop_product_configuration_summary_detail', $tpl_component) : ''; return $output; }
foreach ($orders_infos['order_items'] as $key => $item) { $item_ref = $item['item_ref']; $item_name = $item['item_name']; if (!empty($item['item_id'])) { $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); $output_order = array(); if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) { foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { if (!empty($attribute_def->code)) { $output_order[$attribute_def->code] = $position; } } } } $variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'invoice_print', 'common'); ksort($variation_attribute_ordered['attribute_list']); $cart_more_infos = ''; if (!empty($variation_attribute_ordered['attribute_list'])) { foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { $cart_more_infos .= '<li>' . $attribute_variation_to_output . '</li>'; } } $item_name .= !empty($cart_more_infos) ? '<ul>' . $cart_more_infos . '</ul>' : ''; } ?> <tr height="40" valign="middle" align="center"> <td><?php echo $item_ref; ?> </td><td align="center"><?php
/** * Generate output for an invoice * * @param integer $order_id * @param string $invoice_ref * * @return string The invoice output in case no error is found. The error in other case */ public static function generate_html_invoice($order_id, $invoice_ref) { global $wpdb; $date_output_format = get_option('date_format') . ' ' . get_option('time_format'); $count_products = 0; if (!empty($order_id)) { $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); $discounts_exists = false; $is_quotation = empty($order_postmeta['order_key']) && !empty($order_postmeta['order_temporary_key']) ? true : false; /** Check if it's a partial payment bill **/ $is_partial_payment = !empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_status'] == 'partially_paid' && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_invoice_ref'] != $invoice_ref || empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid' || !empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_invoice_ref'] != $invoice_ref ? true : false; /** Check it is a shipping slip **/ $bon_colisage = !empty($_GET['bon_colisage']) ? true : false; if (!empty($order_postmeta)) { $tpl_component = array(); /** Billing Header **/ //Logo $logo_options = get_option('wpshop_logo'); $tpl_component['INVOICE_LOGO'] = !empty($logo_options) ? '<img src="' . $logo_options . '" alt="" />' : ''; // Title $tpl_component['INVOICE_TITLE'] = $is_quotation ? __('Quotation', 'wpshop') : ($is_partial_payment ? __('Bill payment', 'wpshop') : __('Invoice', 'wpshop')); // if ( empty($order_postmeta['order_invoice_ref']) ) { // $tpl_component['INVOICE_TITLE'] = __('Bill payment', 'wpshop'); // $is_partial_payment = true; // } if ($bon_colisage) { $tpl_component['INVOICE_TITLE'] = __('Products List', 'wpshop'); } $tpl_component['INVOICE_ORDER_INVOICE_REF'] = !empty($invoice_ref) ? $invoice_ref : (!empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : null); if ($bon_colisage) { $tpl_component['INVOICE_ORDER_INVOICE_REF'] = ''; } $tpl_component['INVOICE_ORDER_KEY_INDICATION'] = $is_quotation ? sprintf(__('Ref. %s', 'wpshop'), $order_postmeta['order_temporary_key']) : sprintf(__('Order n. %s', 'wpshop'), $order_postmeta['order_key']); $tpl_component['INVOICE_ORDER_DATE_INDICATION'] = $is_quotation ? sprintf(__('Quotation date %s', 'wpshop'), mysql2date($date_output_format, $order_postmeta['order_date'], true)) : sprintf(__('Order date %s', 'wpshop'), mysql2date($date_output_format, $order_postmeta['order_date'], true)); /** Validate period for Quotation **/ if ($is_quotation) { $quotation_validate_period = self::quotation_validate_period($order_postmeta['order_date']); } else { $tpl_component['INVOICE_VALIDATE_TIME'] = ''; } $tpl_component['INVOICE_VALIDATE_TIME'] = empty($tpl_component['INVOICE_VALIDATE_TIME']) ? '' : $tpl_component['INVOICE_VALIDATE_TIME']; $tpl_component['AMOUNT_INFORMATION'] = !$bon_colisage ? sprintf(__('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency(true)) : ''; // Sender & receiver addresses $tpl_component['INVOICE_SENDER'] = self::generate_invoice_sender_part(); $tpl_component['INVOICE_RECEIVER'] = self::generate_receiver_part($order_id, $bon_colisage); $tpl_component['INVOICE_TRACKING'] = ''; $first = false; if (!empty($order_postmeta['order_trackingNumber'])) { $tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingNumber']; $first = true; } if (!empty($order_postmeta['order_trackingLink'])) { if (!$first) { $tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingLink']; } else { $tpl_component['INVOICE_TRACKING'] .= ' - ' . $order_postmeta['order_trackingLink']; } } /** Items Tab **/ $order_tva = array(); if ($bon_colisage) { $tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('bon_colisage_row_header', array(), array(), 'common'); } else { $tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header', array(), array(), 'common'); if (!$is_quotation) { /** Check if products have discounts **/ if (!empty($order_postmeta['order_items']) && !$is_partial_payment) { foreach ($order_postmeta['order_items'] as $item_id => $item) { if (!empty($item['item_global_discount_value']) || !empty($item['item_unit_discount_value'])) { $discounts_exists = true; } } } if ($discounts_exists) { $tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header_with_discount', array(), array(), 'common'); } } } $total_discounted = 0; $tpl_component['INVOICE_ROWS'] = ''; if (!$is_partial_payment) { if (!empty($order_postmeta['order_items'])) { foreach ($order_postmeta['order_items'] as $item_id => $item) { $sub_tpl_component = array(); $count_products++; $barcode = get_post_meta($item['item_id'], '_barcode', true); if (empty($barcode)) { $product_metadata = get_post_meta($item['item_id'], '_wpshop_product_metadata', true); $barcode = !empty($product_metadata) && !empty($product_metadata['barcode']) ? $product_metadata['barcode'] : ''; if (empty($barcode)) { $product_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); $att_def = wpshop_attributes::getElement('barcode', '"valid"', 'code'); $query = $wpdb->prepare('SELECT value FROM ' . $wpdb->prefix . 'wpshop__attribute_value_' . $att_def->data_type . ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d AND value != ""', $product_entity, $att_def->id, $item['item_id']); $barcode = $wpdb->get_var($query); } } $sub_tpl_component['INVOICE_ROW_ITEM_BARCODE'] = !empty($barcode) ? $barcode : '-'; $sub_tpl_component['INVOICE_ROW_ITEM_REF'] = !empty($barcode) ? $barcode : $item['item_ref']; /** Item name **/ $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = $item['item_name']; /** Get attribute order for current product */ $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); $output_order = array(); if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) { foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { if (!empty($attribute_def->code)) { $output_order[$attribute_def->code] = $position; } } } } $variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'invoice_print', 'common'); ksort($variation_attribute_ordered['attribute_list']); $detail_tpl_component['CART_PRODUCT_MORE_INFO'] = ''; foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { $detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= $attribute_variation_to_output; } $sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = !empty($detail_tpl_component['CART_PRODUCT_MORE_INFO']) ? wpshop_display::display_template_element('invoice_row_item_detail', $detail_tpl_component, array(), 'common') : ''; unset($detail_tpl_component); $sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = $item['item_qty']; $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = !empty($item['item_pu_ht_before_discount']) ? number_format($item['item_pu_ht_before_discount'], 2, '.', '') : number_format($item['item_pu_ht'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = !empty($item['item_discount_value']) ? number_format($item['item_discount_value'], 2, '.', '') : number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format($item['item_pu_ht'] * $item['item_qty'], 2, '.', ''); /** TVA **/ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format($item['item_tva_total_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = $item['item_tva_rate']; $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($item['item_total_ttc'], 2, '.', ''); /** Checking Rate amount **/ if (!$bon_colisage) { $checking = self::check_product_price($item['item_total_ht'], $item['item_total_ttc'], $item['item_tva_total_amount'], $item['item_tva_rate'], $item['item_id'], $invoice_ref, $order_id); if (!$checking) { return __('Invoice cannot be generate because an error was found. The website administrator has been warned.', 'wpshop'); } } if ($bon_colisage) { $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('bon_colisage_row', $sub_tpl_component, array(), 'common'); } else { if ($discounts_exists) { $discounted_total_per_item = $item['item_total_ht']; /** Unit Discount **/ if (!empty($item['item_unit_discount_amount']) && !empty($item['item_unit_discount_value'])) { $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format($item['item_unit_discount_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format($item['item_unit_discount_value'], 2, '.', ''); $discounted_total_per_item = $discounted_total_per_item - $item['item_unit_discount_amount']; } else { $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); } /** Global Discount **/ if (!empty($item['item_global_discount_amount']) && !empty($item['item_global_discount_value'])) { $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format($item['item_global_discount_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format($item['item_global_discount_value'], 2, '.', ''); $discounted_total_per_item = $discounted_total_per_item - $item['item_global_discount_amount']; } else { $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); } $total_discounted += $discounted_total_per_item; /** Total HT Discounted **/ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format($discounted_total_per_item, 2, '.', ''); $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common'); } else { $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common'); } } unset($sub_tpl_component); /** Check TVA **/ 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']; } } } /** Display Partials payments **/ $total_partial_payment = 0; $last_payment = 0; $order_invoice_ref = !empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : ''; if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) { foreach ($order_postmeta['order_payment']['received'] as $received_payment) { if (!empty($received_payment['invoice_ref']) && $received_payment['invoice_ref'] != $order_invoice_ref) { if (intval(substr($received_payment['invoice_ref'], 2)) == intval(substr($tpl_component['INVOICE_ORDER_INVOICE_REF'], 2))) { $sub_tpl_component = array(); $sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref']; /** Item name **/ $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf(__('Partial payment on order %1$s', 'wpshop'), $order_postmeta['order_key'], __($received_payment['method'], 'wpshop'), $received_payment['payment_reference']); $sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = ''; $sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1; $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); /** TVA **/ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0; $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); if ($discounts_exists) { $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common'); } else { $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common'); } } unset($sub_tpl_component); $total_partial_payment += !empty($received_payment['received_amount']) ? $received_payment['received_amount'] : 0; } else { if ('payment_received' == $received_payment['status']) { $last_payment += !empty($received_payment['received_amount']) ? $received_payment['received_amount'] : 0; } } } } } else { /** Display Partials payments **/ $total_partial_payment = 0; $last_payment = 0; if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) { foreach ($order_postmeta['order_payment']['received'] as $received_payment) { if (!empty($received_payment['invoice_ref']) && !empty($invoice_ref) && $received_payment['invoice_ref'] == $invoice_ref) { $sub_tpl_component = array(); $sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref']; /** Item name **/ $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf(__('Partial payment on order %1$s', 'wpshop'), $order_postmeta['order_key'], __($received_payment['method'], 'wpshop'), $received_payment['payment_reference']); $sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = ''; $sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1; $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = number_format($received_payment['received_amount'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format($received_payment['received_amount'], 2, '.', ''); /** TVA **/ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0; $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($received_payment['received_amount'], 2, '.', ''); $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); $total_partial_payment += $received_payment['received_amount']; } } } } /** Summary of order **/ $summary_tpl_component = array(); $tpl_component['INVOICE_SUMMARY_PART'] = $summary_tpl_component['INVOICE_SUMMARY_TAXES'] = ''; if (!$bon_colisage) { if (!empty($order_tva)) { foreach ($order_tva as $tax_rate => $tax_amount) { if ($tax_amount > 0) { $tax_rate = !empty($tax_rate) && $tax_rate == 'VAT_shipping_cost' ? __('on Shipping cost', 'wpshop') . ' ' . WPSHOP_VAT_ON_SHIPPING_COST : $tax_rate; $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%'); $sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency(); $summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); } elseif ($is_partial_payment) { $tax_rate = 0; $tax_amount = number_format(0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency(); $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%'); $sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency(); $summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); } } } /** If Discount Exist **/ if (!empty($total_discounted) && $discounts_exists) { $sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Discounted Total ET', 'wpshop'); $sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format($total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(); $summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); } else { $summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = ''; } $shipping_et = 0; if (!$is_partial_payment) { if (!empty($order_postmeta['order_shipping_cost'])) { $shipping_et = $order_postmeta['order_shipping_cost']; } } $shipping_taxes = WPSHOP_VAT_ON_SHIPPING_COST / 100 * $shipping_et; $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = number_format($shipping_et, 2, ',', ''); $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST_TAXES'] = number_format($shipping_taxes, 2, ',', ''); //$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = ( $is_partial_payment ) ? number_format( 0, 2, ',', '') : number_format( ( (!empty($order_postmeta['order_shipping_cost']) ) ? $order_postmeta['order_shipping_cost'] : 0 ), 2, ',', '' ); $summary_tpl_component['INVOICE_ORDER_GRAND_TOTAL'] = $is_partial_payment ? number_format($total_partial_payment, 2, ',', '') : number_format($order_postmeta['order_grand_total'], 2, ',', ''); // - $total_partial_payment , 2, ',', '' ); $summary_tpl_component['INVOICE_ORDER_TOTAL_HT'] = $is_partial_payment ? number_format($total_partial_payment, 2, ',', '') : number_format($order_postmeta['order_total_ht'], 2, ',', ''); $summary_tpl_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', ''); $total_payment = 0; /** Amount paid **/ if (empty($order_postmeta['order_invoice_ref'])) { foreach ($order_postmeta['order_payment']['received'] as $key => $value) { if (!empty($value['invoice_ref']) && $value['invoice_ref'] === $tpl_component['INVOICE_ORDER_INVOICE_REF']) { $total_payment = number_format($value['received_amount'], 2, ',', ''); } } } else { $total_payment = $total_partial_payment + $last_payment !== $order_postmeta['order_grand_total'] ? number_format($total_partial_payment + $last_payment, 2, ',', '') : $order_postmeta['order_grand_total']; } $sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Amount already paid', 'wpshop'); $sub_tpl_component['SUMMARY_ROW_VALUE'] = $total_payment . ' ' . wpshop_tools::wpshop_get_currency(); //$sub_tpl_component['SUMMARY_ROW_VALUE'] = ( $is_partial_payment ) ? number_format($total_partial_payment, 2, ',', '' ). ' ' . wpshop_tools::wpshop_get_currency() : number_format($order_postmeta['order_grand_total'], 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency(); $summary_tpl_component['INVOICE_SUMMARY_MORE'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); $sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Number of products', 'wpshop'); $sub_tpl_component['SUMMARY_ROW_VALUE'] = $count_products; $summary_tpl_component['INVOICE_SUMMARY_MORE'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); /** If Discount Exist **/ if (!empty($order_postmeta['coupon_id']) && !empty($order_postmeta['order_discount_value'])) { $tpl_discount_component = array(); $tpl_discount_component['DISCOUNT_VALUE'] = $order_postmeta['order_discount_type'] == 'percent' ? number_format($order_postmeta['order_discount_amount_total_cart'], 2, ',', '') : number_format($order_postmeta['order_discount_value'], 2, ',', ''); $tpl_discount_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', ''); $summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = wpshop_display::display_template_element('invoice_discount_part', $tpl_discount_component, array(), 'common'); unset($tpl_discount_component); } else { $summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = ''; } $price_piloting = get_option('wpshop_shop_price_piloting', 'TTC'); $summary_tpl_component['PRICE_PILOTING'] = 'HT' == $price_piloting ? __('ET', 'wpshop') : __('ATI', 'wpshop'); $tpl_component['INVOICE_SUMMARY_PART'] = wpshop_display::display_template_element('invoice_summary_part', $summary_tpl_component, array(), 'common'); unset($summary_tpl_component); } /** IBAN Include on quotation **/ if ($is_quotation) { /** If admin want to include his IBAN to quotation */ $iban_options = get_option('wpshop_paymentMethod_options'); $payment_options = get_option('wps_payment_mode'); if (!empty($payment_options) && !empty($payment_options['mode']) && !empty($payment_options['mode']['banktransfer']) && !empty($payment_options['mode']['banktransfer']['active']) && $payment_options['mode']['banktransfer']['active'] == 'on') { if (!empty($iban_options) && !empty($iban_options['banktransfer'])) { $tpl_component['IBAN_INFOS'] = __('Payment by Bank Transfer on this bank account', 'wpshop') . ' : <br/>'; $tpl_component['IBAN_INFOS'] .= __('Bank name', 'wpshop') . ' : ' . (!empty($iban_options['banktransfer']['bank_name']) ? $iban_options['banktransfer']['bank_name'] : '') . '<br/>'; $tpl_component['IBAN_INFOS'] .= __('IBAN', 'wpshop') . ' : ' . (!empty($iban_options['banktransfer']['iban']) ? $iban_options['banktransfer']['iban'] : '') . '<br/>'; $tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop') . ' : ' . (!empty($iban_options['banktransfer']['bic']) ? $iban_options['banktransfer']['bic'] : '') . '<br/>'; $tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop') . ' : ' . (!empty($iban_options['banktransfer']['accountowner']) ? $iban_options['banktransfer']['accountowner'] : '') . '<br/>'; } } else { $tpl_component['IBAN_INFOS'] = ''; } } else { $tpl_component['IBAN_INFOS'] = ''; } /** Received payements **/ if (!$is_partial_payment && !$bon_colisage && !empty($order_postmeta['order_invoice_ref'])) { $tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part($order_id); } else { $tpl_component['RECEIVED_PAYMENT'] = ''; } /** Invoice footer **/ $tpl_component['INVOICE_FOOTER'] = self::generate_footer_invoice(); $output = wpshop_display::display_template_element('invoice_page_content', $tpl_component, array(), 'common'); } else { $output = __('No order information has been found', 'wpshop'); } } else { $output = __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop'); } return $output; }