1

On my store we have a product that costs £2.95 including tax (at current UK rate of 20%). The tax seems to calculate fine here.

However, I then have a Customer Group that gets 30% off, which should make the price £2.07. When I first load both the Category and Product page, it correctly shows £2.07 for this configurable product and logged in with the Customer Group.

But then when I choose one of the Simple Product options, the price displays as £2.06 - 1p difference. However, when the product is added to the cart, it goes in at the correct amount of £2.07 so the issue appears to be the rounding on the display price.

I'm using Magento 1.9.0.1 and wondered if other people have the same issue with the combination of tax and customer group discount?

Regards, Neil

2
  • check order receipt...detail of included tax....and match that in your rules...
    – Deepak Rai
    Sep 9, 2015 at 10:38
  • Thanks Deepak. It's all correct there. It's simply on the product page where the price displays as a 1pence difference when I choose an option from the Configurable product. Sep 9, 2015 at 10:53

5 Answers 5

1

Try overridding Mage_Core_Model_Store::roundPrice().
Change

public function roundPrice($price)
    {
        return round($price, 2);
    }

to

public function roundPrice($price)
    {
        return round($price, 4);
    }
3
  • Thanks Anshu. Unfortunately I have tried this one but it didn't work. :( Sep 9, 2015 at 11:21
  • it didn't work for me either Jan 7, 2017 at 7:26
  • @anshu how to round up discount amount in total.. admin order Jan 7, 2017 at 7:27
0

There are some settings that could cause this.

Under System -> Configuration -> Taxes -> Calculation, change the "Apply after discount" setting.

Under System -> Configuration -> Sales -> Checkout Totals Sort Order, change them.

Also: do you input the prices excluding tax, and show them including tax (or the other way round?).

Can you confirm that your taxes have been set up as shown in the EU tax guide? GB is still in the EU, you know ;)

http://merch.docs.magento.com/ce/user_guide/Magento_Community_Edition_User_Guide.html#tax/configuration-eu.html

=== UPDATE ===

I am not sure what causes this problem, but maybe one of the following is a solution.

  1. What happens if you change the product price from 2.95 to 2.9520 in the backend?

  2. spConfig is filled by $this->getJsonConfig(). If you are not using a 3rd party extension for configurable products, this method can be found in Mage_Catalog_Block_Product_View_Type_Configurable. You could override this block in a new module and modify the function:

In your new module's config.xml file, add this section:

<blocks>
    <catalog>
        <rewrite>               
            <product_view_type_configurable>Namespace_Modulename_Block_Catalog_Product_View_Type_Configurable</product_view_type_configurable>
        </rewrite>
    </catalog>
</blocks>

Then create the file Namespace/Modulename/Block/Catalog/Product/View/Type/Configurable.php with these contents:

<?php
class Namespace_Modulename_Block_Catalog_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable {

    public function getJsonConfig() {
        // rest of method

        // this can be found pretty much near the end
        $config = array(
            'attributes' => $attributes,
            'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()),
            // basePrice has been changed: added round()
            'basePrice' => $this->_registerJsPrice(round($this->_convertPrice($currentProduct->getFinalPrice(), 2))),
            'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())),
            'productId' => $currentProduct->getId(),
            'chooseText' => Mage::helper('catalog')->__('Choose an Option...'),
            'taxConfig' => $taxConfig
        );


        // rest of method
    }
}

It would be even better to use an observer for the event catalog_product_type_configurable_price which is dispatched in the same method a few lines earlier, but I am not sure about the overall impact for the page if you change the price of the configurable product there.

Another solution would be to override the javascript class Product.Config and do the rounding manually. A pretty good explanation of how to override JS core classes can be found here:

https://stackoverflow.com/a/11946804/1130898

6
  • Thanks @simonthesorcerer - Apply Tax is set to After Discount and prices are entered including tax. Weirdly, the products always add to the cart at the correct price, it's just when you select an option on a configurable product that the price changes to be 1pence out. I thought this was perhaps being caused by the product.js. Sep 9, 2015 at 22:32
  • Does anything change if you switch "Apply tax" to "Before discount"? Maybe there's really a problem with the configurable product display... you can investigate the javascript object spConfig (I think this is its name) in the Dev.-Console of your browser and check the prices. My guess is: when the prices are calculated, they are rounded to a lower number than they should and this gives the 1p difference. Can you give a screenshot of System->Configuration->Taxes->Calculation? Sep 10, 2015 at 9:08
  • here's the spConfig var spConfig = new Product.Config({"attributes":{"223":{"id":"223","code":"weight_new","label":"Weight","options":[{"id":"232","label":"2x500g","price":0.35,"oldPrice":"0.5","products":["933"]},{"id":"233","label":"1kg","price":0,"oldPrice":"0","products":["932"]}]}},"template":"\u00a3#{price}","basePrice":"2.065","oldPrice":"2.95","productId":"931","chooseText":"Choose an Option...","taxConfig":{"includeTax":true,"showIncludeTax":true,"showBothPrices":false,"defaultTax":20,"currentTax":20,"inclTaxTitle":"Incl. Tax"}}); Sep 10, 2015 at 11:38
  • You can see that the adjusted basePrice is 2.065 instead of 2.07 Sep 10, 2015 at 11:38
0

Download Magento 1.9.2 and try create the same situation.

If you have the same rounding error again, go to the admin page and look for a message under the menu that will say:

Warning tax configuration can result in rounding errors. 
Please see source for more details.
Click here to go to Tax configuration and change your settings.

If not, give the 'guys' from Magento a ping, you just found a error. And there happy to create a new test-cases for it. So it will never happen again. Thrust me.... ;-)

0

We were getting the same issue recently, 1 cent difference, and it was because of Bluejalappeno Tieredproducts extension (are you using this?) which was extending core getFinalPrice method. The extension was returning product price 3 decimal places while in javascript it was getting incorrectly modified to 2 decimal places, resulting in price inconsistencies when "displayed" and when "adding to cart".

Check from where your product final price is coming from (extension or your local changes), and make sure it returns in 2 decimal places format before it displays. You can convert the price into 2 decimal places like this if it's coming in more than 2 decimal places: $finalPrice = number_format($finalPrice, '2', '.', ',');

0

thank you for your help. We actually found that the issue was with the /js/varien/product.js. When choosing a Simple product on a Configurable, the product.js was not rounding the same way. The product was still adding to the cart at the correct price but the JS that changed the visible price was incorrect.

So we modified this line:

return formatCurrency(a, this.priceFormat)

with:

var b = (Math.round((a * 100).toFixed(4))/100).toString();return formatCurrency(b, this.priceFormat);

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.