문제

확인하고 싶어 세금 규칙의 각 제품에서 청구 페이지입니다.

어떤 변수를 저장하는 세금과 같은 규칙을 8%18%?

그것은 다음과 같이 될 것이다

{if $order_invoice->tax_rule == "18%"}
    ...
{/if}
도움이 되었습니까?

해결책

체크 오른 변수

당신이 찾을 수 없습니다 데이터 $order_invoice.을 얻고 싶은 경우 세금 규칙에 각 제품에 대해 체크인하셔야 합니다에 $order_detail var.추출물 invoice.tpl :

<!-- PRODUCTS -->
{foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">
    <!-- Here we've got one line, for one product -->
    <!-- This product's datas are stored in $order_detail -->
</tr>

당신을 찾을 수 있습니다 세율 $order_detail.tax_rate.불행하게도,그것은 항상 돌아 0.000.

예...이 데이터는 채워지지 않습니다...슬픈 일...


Create an OrderDetail override

OrderDetail.php 에서 파일 override/classes/order/ 폴더,이 코드가 포함된:

class OrderDetail extends OrderDetailCore
{

    /**
     * Get order products
     *
     * @return array Products with price, quantity (with taxe and without)
     */
    public function getProducts($products = false, $selectedProducts = false, $selectedQty = false)
    {
        if (!$products)
            $products = $this->getProductsDetail();

        $order = new Order($this->id_order);
        $customized_datas = Product::getAllCustomizedDatas($order->id_cart);

        $resultArray = array();
        foreach ($products as $row)
        {
            // Retrieve tax rate
            $product = new Product($row['product_id']);
            $row['tax_rate'] = $product->getTaxesRate();

            // Change qty if selected
            if ($selectedQty)
            {
                $row['product_quantity'] = 0;
                foreach ($selectedProducts as $key => $id_product)
                    if ($row['id_order_detail'] == $id_product)
                        $row['product_quantity'] = (int)($selectedQty[$key]);
                if (!$row['product_quantity'])
                    continue;
            }

            $this->setProductImageInformations($row);
            $this->setProductCurrentStock($row);
            $this->setProductCustomizedDatas($row, $customized_datas);

            // Add information for virtual product
            if ($row['download_hash'] && !empty($row['download_hash']))
            {
                $row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
                // Get the display filename
                $row['display_filename'] = ProductDownload::getFilenameFromFilename($row['filename']);
            }

            $row['id_address_delivery'] = $order->id_address_delivery;

            /* Stock product */
            $resultArray[(int)$row['id_order_detail']] = $row;
        }

        if ($customized_datas)
            Product::addCustomizationPrice($resultArray, $customized_datas);

        return $resultArray;
    }

}

이를 무시할 수 있습 편집 tax_rate 값이 있습니다.
나는 단순히 추가 이 두 라인에서 getProducts() 기능:

foreach ($products as $row)
{
    // Retrieve tax rate
    $product = new Product($row['product_id']);
    $row['tax_rate'] = $product->getTaxesRate();

    // ...
}

Create an OrderInvoice override

OrderInvoice.php 에서 파일 override/classes/order/ 폴더에 있습니다.
이 클래스가 포함됩 동일한 코드 으로 우리의 이전할 수 있습니다.그냥 변화의 첫 번째 줄:

<?php

class OrderInvoice extends OrderInvoiceCore
{
    // Copy/Paste the same code
}

지금 표시할 수 있습니다 세율에 대한 각 제품을 사용하여, {$order_detail.tax_rate} !!

(보너스)편집 템플릿

을 변경하자는 이 템플릿(여기: pdf/invoice.tpl 이)추가"세금 규칙"란:

<tr style="line-height:4px;">
    <!-- Remove 10% from the first column header width -->
    <td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: {if !$tax_excluded_display}25%{else}35%{/if}">{l s='Product / Reference' pdf='true'}</td>
    ...
    <!-- Add our new column header, 10% width -->
    <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: 10%; white-space: nowrap;">{l s='Tax rate' pdf='true'}</td>
    ...
</tr>
<!-- PRODUCTS -->
{foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">
    <!-- Remove 10% from the first column width -->
    <td style="text-align: left; width: {if !$tax_excluded_display}25%{else}35%{/if}">{$order_detail.product_name}{if isset($order_detail.product_reference) && !empty($order_detail.product_reference)} ({l s='Reference:' pdf='true'} {$order_detail.product_reference}){/if}</td>
    ...
    <!-- Add our new column, 10% width -->
    <td style="text-align: right; width: 10%; white-space: nowrap;">
        {$order_detail.tax_rate}
    </td>
    ...
</tr>

다른 팁

나는 정확한 방식이 orderinvoice.php

에서 getpriducts () 함수를 무시하는 것입니다.
foreach ($products as $row)
{
...
$sql = "SELECT tax.rate FROM ps_tax as tax join `ps_order_detail_tax` on ps_order_detail_tax.id_tax = tax.id_tax WHERE ps_order_detail_tax.id_order_detail = " .(int)$row['id_order_detail'] ;
$result = Db::getInstance()->executeS($sql);
$tmp = $result[0];
if (isset($tmp['rate'])){
            $row['tax_rate_product'] = $tmp['rate'];
}
else { //No Tax
$row['tax_rate_product'] = "0.000";
}
...
}
.

및 .tpl의 사용률 값

...
<td style="text-alig: right; width: 15%">{$order_detail.tax_rate_product}</td>
...
.

캐시 / class_index.php

를 삭제하는 것을 잊지 마십시오.

선적 주소에 따라 제품 세금 규칙이있을 수 있습니다.시도해보십시오

foreach ($products as $row)
.

{

...

// Retrieve tax rate

$product = new Product($row['product_id']);
$row['tax_rate'] = $product->getTaxesRate(new Address((int)$order->id_address_delivery))
 ...
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top