久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento:在審查期間向報價添加關稅/稅款

Magento: adding duties/taxes to a quote during review(Magento:在審查期間向報價添加關稅/稅款)
本文介紹了Magento:在審查期間向報價添加關稅/稅款的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要調用第 3 方 API,以便在結帳流程的審核階段了解國際運輸的最新關稅/稅費.我已準備好 API 調用,但是我缺少將退回的關稅和稅款添加到報價中的方法.

I need to make a call to a 3rd party API to get up to date Duties/Taxes for international shipping during the review stage of the checkout process. I have the API call ready to go, however I am missing a way to add the returned duties and taxes to the quote.

有沒有內置的方法來做到這一點?

Is there a built in way to do this?

我希望有類似的東西

$quote->addCostComponent("Duties", 5.0);

推薦答案

您需要執行以下步驟:

  1. 首先,您需要為您的關稅/稅款創建屬性以按順序顯示它們,而不僅僅是添加到總計中.應該至少有兩個屬性,一個是網站貨幣的價值(用于支付捕獲,它應該有 base_ 前綴)和一個顯示貨幣的價值(僅用于顯示客戶所需貨幣的金額).應將此屬性添加到具有財務部分(quote_address、order、invoice)的每個實體.例如它應該是:base_your_attribute_codeyour_attribute_code 十進制類型.

  1. First of all you need to create attributes for your custom duties/taxes for displaying them in order, not only just add to the grand total. There should be at least two attributes one for value in website currency (used in payment capture and it should have base_ prefix) and one value in displayed currency (used just for displaying amount in desired currency for customer). This attributes should be added to every entity with financial part (quote_address, order, invoice). For instance it should be: base_your_attribute_code and your_attribute_code with decimal type.

然后你需要創建你的總收集器模型,它應該從 Mage_Sales_Model_Quote_Address_Total_Abstract 擴展,并實現像這個例子中的收集和獲取方法:

Then you need create your total collector model that should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract and implement collect and fetch methods like in this example:

/**
 * Your custom total model
 *
 */
class Your_Module_Model_Total_Custom extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
    /** 
     * Constructor that should initiaze 
     */
    public function __construct()
    {
        $this->setCode('your_attribute_code');
    }

    /**
     * Used each time when collectTotals is invoked
     * 
     * @param Mage_Sales_Model_Quote_Address $address
     * @return Your_Module_Model_Total_Custom
     */
    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        parent::collect($address);

        // ... Some your api calls to retrive amount ...

        // Set base amount of your custom fee
        $this->_setBaseAmount($calculatedAmount);

        // Set amount of your custom fee in displayed currency
        $this->_setAmount(
            $address->getQuote()->getStore()->convertPrice($calculatedAmount, false)
        );

        return $this;
    }

    /**
     * Used each time when totals are displayed
     * 
     * @param Mage_Sales_Model_Quote_Address $address
     * @return Your_Module_Model_Total_Custom
     */
    public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
        // Display total only if it is not zero
        if ($address->getYourAttributeCode() != 0) {
            $address->addTotal(array(
                'code' => $this->getCode(),
                'title' => 'My Custom Duty',
                'value' => $address->getYourAttributeCode()
            ));
        }
    }
}

  • 收集器模型創建后,您需要將其添加到配置中:

  • After you the collector model is created you need add it to configuration:

    <config>
        <global>
            <sales>
                <quote>
                    <totals>
                        <your_total_code>
                            <class>your_module/total_custom</class>
                            <before>grand_total</before>
                            <after>shipping</after>
                        </your_total_code>
                    </totals>
                </quote>
            </sales>
        </global>
    </config>
    

    • class 節點包含收集器模型的類別名
    • beforeafter 節點表示收集器的調用順序.
      • class node contains the class alias of your collector model
      • before and after nodes indicate invocation order of your collector.
      • 您需要將您的總屬性添加到將用于將計算數據復制到訂單或發票中的字段集:

        You need to add your total attributes to field-sets that will be used for copying calculated data into order or invoice:

        <config>
            <global>
                <fieldsets>
                    <!-- copies data from quote address to order during the order placement -->
                    <sales_convert_quote_address>
                        <base_your_attribute_code><to_order>*</to_order></base_your_attribute_code>
                        <your_attribute_code><to_order>*</to_order></your_attribute_code>
                    </sales_convert_quote_address>
        
                    <!-- copies data from order to invoice/shipment/creditmemo during their creation -->
                    <sales_convert_order>
                        <base_your_attribute_code><to_invoice>*</to_invoice><to_shipment>*</to_shipment><to_cm>*</to_cm></base_your_attribute_code>
                        <your_attribute_code><to_invoice>*</to_invoice><to_shipment>*</to_shipment><to_cm>*</to_cm></your_attribute_code>
                    </sales_convert_order>
        
                </fieldsets>
            </global>
        </config>
        

      • 執行此步驟后,您將能夠在訂單總額中看到自定義費用

      • After performing this steps you will be able to see your custom fee in order totals

        這篇關于Magento:在審查期間向報價添加關稅/稅款的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

        【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!
  • 相關文檔推薦

    Override Magento Config(覆蓋 Magento 配置)
    What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導致 print_r 和/或 var_dump 調試變量失敗?)
    How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
    Magento 404 on Admin Page(管理頁面上的 Magento 404)
    Magento - get price rules from order(Magento - 從訂單中獲取價格規則)
    Magento Change Product Page Titles to Include Attributes(Magento 更改產品頁面標題以包含屬性)
    主站蜘蛛池模板: 亚洲视频在线观看免费 | 日韩一区二区福利视频 | 毛片免费观看视频 | 欧美日韩18 | 人人干人人超 | 伊人网伊人 | 久久久久久久av麻豆果冻 | 99久久久久 | 国产精品久久久久久久岛一牛影视 | av在线伊人| 在线观看国产三级 | 9191av| 国产成人一区二区三区 | 99精品视频在线观看 | 国产欧美日韩在线观看 | 欧美久久久电影 | 麻豆91av | 久久久夜夜夜 | 成人中文网 | 亚洲视频中文 | 欧美日韩一区二区在线 | 亚洲综合色婷婷 | 国产综合在线视频 | 日韩三区 | 日韩视频在线观看一区二区 | 日韩福利 | 草樱av | 国产精品久久久久久久久免费软件 | 天天干天天谢 | 羞羞色在线观看 | 欧美2区| 久久久精品高清 | 欧美一区二区三区视频 | 国产激情在线 | 国产欧美一区二区三区日本久久久 | 国产乱码精品一品二品 | 国产欧美在线播放 | 韩日精品在线观看 | 青青激情网 | 超碰地址 | 一级免费毛片 |