在我的Magento网站上,我有产品价格包括12.5%的税。 如果客户是B2B(将知道他是否选择他在OnePageCheckout中有C表格),我想重新计算税款,如下所示:

  • 从产品价格减少12.5%。即,如果我的产品价格为50000,那么从50000
  • 减少12.5%
  • 然后在减少12.5%的价格上加入2%的价格

例如:

Product Price : 50000
Base Price: 50000 - 12.5% of Product Price
CST (2%): 2% of the Base Price
Total: Base Price + CST
.

请指导我。

有帮助吗?

解决方案 5

I had done this with myself by adding custom logic in the sales_quote_collect_totals_before observer

Step 1:- Declare Observer in config.xml

<events>
    <sales_quote_collect_totals_before>
        <observers>
            <new_tax>
                <type>singleton</type>
                <class>Neo_Cform_Model_Observer</class>
                <method>newTax</method>
            </new_tax>
        </observers>
    </sales_quote_collect_totals_before>
</events>

Step 2:- Declare Observer's function in Observer.php

public function newTax($observer){
    $quote = $observer->getQuote();
    foreach ($quote->getAllItems() as $quoteItem) {
        if ($quote->getData('customer_cform') === 'true') { // check if customer is b2b customer and selects for the cform option
            $product = $quoteItem->getProduct();
            $product->setTaxClassId(0); // tax class removed.now the price is with no tax
            $basePrice = $product->getFinalPrice() / (1+(12.5/100)); // calcuated 12.5 % of total price and subtracted from the price to get base price
            $final_cst_price = $basePrice * (2/100); // added 2% in the base price to get fincal cst price
            $finalPrice = $basePrice + $final_cst_price;
            $product->setPrice($basePrice);
            $product->setTaxClassId(8); // here 8 is a tax rule defined in the magento admin just to show the split of base price and tax (2%) in the cart page and checkout page
        }
    }
}

其他提示

为所有B2B客户和税务规则设置客户组?

自定义产品定价是通过编写模块来扩展Mage_catalog_Model_Product_type_Price中的GetFinalPrice方法来实现的。

取决于您所拥有的产品类型,您可能需要扩展其他定价代码,因为可配置和简单产品有不同的价格方法。

这里是我写的模块的exceprt,它将最终产品价格折扣为B2B客户的固定百分比。

首先,我们将GetFinalPrice方法延长

class PAJ_Price_Model_Simple extends Mage_Catalog_Model_Product_Type_Price
{
    public function getFinalPrice($qty = null, $product)
    {

        if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
            return $product->getCalculatedFinalPrice();
        }

        $finalPrice = $this->getBasePrice($product, $qty);
        $product->setFinalPrice($finalPrice);

        Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));

        $finalPrice = $product->getData('final_price');
        $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
        $finalPrice = max(0, $finalPrice);

        // get B2B Final Price
        if ($_B2BFinalPrice=Mage::helper('PAJ_Price/B2BFinalPrice')->getB2BFinalPrice($product,$finalPrice)) { return max(0, $_B2BFinalPrice); }

        $product->setFinalPrice($finalPrice);

        return $finalPrice;
    }
}
.

可以看到价格计算现在在辅助方法B2BfinalPrice中执行。在这里,您可以应用逻辑,确定客户是B2B等于特定组的成员,然后在您的示例中执行最终价格的计算:

class PAJ_Price_Helper_B2BFinalPrice extends Mage_Core_Helper_Abstract
{
    public function getB2BFinalPrice($product,$finalPrice)
    {
                    $basePrice=$finalPrice - ($finalPrice * (12.5/100));
                    $cst=$basePrice + ($basePrice * (2/100));

                    $finalPrice=$basePrice+$cst;

                    return $finalPrice;
    }
}
.

请注意,这正在改变产品最终价格,而不是税收计算。在此示例中,将按最终价格计算税。

如果您正在显示其他价格,例如Tier价格,那么您还需要在前端主题中执行此计算,以便正确显示B2B客户的层定价。

要实现这样的解决方案,您需要熟悉创建自定义模块并扩展Magento核心代码。

您还需要进行大量测试以确保您获得正确的结果。你不想用产品定价犯错误!

我没有看,但你也可能发现从magento connect获得类似的东西。

希望这有帮助。

你可以请参考增值税豁免通过Marople 。它可以在某些情况下删除税款可能是我猜你的要求可以通过自定义一个误码来实现。

You can add a shopping price rule under which can be found under:

Promotions->Shopping Cart Price Rule 

and then place that rule at certain customer group that you will create. The customer group is located under:

Customers->Customer Groups
许可以下: CC-BY-SA归因
scroll top