【问题标题】:Display (tier) prices with qty increments and taxes显示(层)价格与数量增量和税
【发布时间】:2012-06-25 14:25:35
【问题描述】:

我需要根据产品的数量增量显示(层)价格。例如。一个简单的产品,正常价格为 50 美分,不含税,数量增量为 20 应在产品视图中显示为“每 20 美元 10 美元”。

如果不使用税收,这应该很容易。但是似乎没有“默认”助手或模型可以在启用税收和不同计算算法的情况下执行此操作(例如Mage_Tax_Model_Calculation::CALC_UNIT_BASE);期待Mage_Tax_Model_Sales_Total_Quote_TaxMage_Tax_Model_Sales_Total_Quote_Subtotal 中的引号。

我在这里遗漏了什么,还是我必须自己编写业务逻辑来计算价格?以及我将如何最好地封装它?

【问题讨论】:

    标签: api magento integration catalog


    【解决方案1】:

    我现在非常简单地解决了我的问题。为此,我在自定义模块中使用了 <rewrite> 元素来扩展帮助程序 Mage_Tax_Helper_Data 并使用额外的实例方法:

    class My_Module_Helper_Tax_Data extends Mage_Tax_Helper_Data {
    
        /**
         * Get product price based on stock quantity increments
         *
         * @param Mage_Catalog_Model_Product $product
         * @param float $price inputed product price
         * @param null|int $qtyIncrements inputed stock quantity increments
         * @param null|bool $includingTax return price include tax flag
         * @param null|Mage_Customer_Model_Address $shippingAddress
         * @param null|Mage_Customer_Model_Address $billingAddress
         * @param null|int $customerTaxClass customer tax class
         * @param mixed $store
         * @param bool $priceIncludesTax flag what price parameter contain tax
         * @return float
         */
        public function getQtyIncrementsPrice($product, $price, $qtyIncrements = 1,
            $includingTax = null, $shippingAddress = null, $billingAddress = null, 
            $customerTaxClass = null, $store = null, $priceIncludesTax = null) {
    
            $store = Mage::app()->getStore($store);
            $qtyIncrements *= 1;
    
            if ($this->_config->getAlgorithm($store) 
                == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
                $price = $this->getPrice(
                    $product, $price, $includingTax, $shippingAddress, 
                    $billingAddress, $customerTaxClass, $store, $priceIncludesTax
                );
                $price *= $qtyIncrements;
                $price = $store->roundPrice($price);
            } else {
                $price *= $qtyIncrements;
                $price = $this->getPrice(
                    $product, $price, $includingTax, $shippingAddress,
                    $billingAddress, $customerTaxClass, $store, $priceIncludesTax
                );
            }
    
            return $price;
        }
    }
    

    它可以在以后用于自定义重写方法,例如Mage_Catalog_Block_Product_Price::getTierPrices()

    【讨论】:

      猜你喜欢
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-28
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多