Search code examples
magentodiscounts

Magento - Displaying reward points on products with Tax


We run a Magento Based e-commerce site. It is running Magento Enterprise 1.10.

We are in the UK - so we like to show all prices inclusive of Tax(VAT). Our store is set up with Prices entered inclusive of VAT, and Magento back-calculates the VAT at the checkout.

The site uses the built in enterprise Reward points functionality, and offers customers 10 points for every £1 they spend.

Displaying reward points (currently using the function "echo $this->getRewardPoints()" in the catalog and basket) shows the reward points inclusive of tax (so £15 = 150 points) but in the checkout, using the same function to show potential points for an item calculates the reward points on the item minus tax (so £15 = 120 points).

When the order is placed, the reward points are added to the customers account Minus the tax. This is obviously confusing for the users.

As a temporary measure I have stopped showing the incorrect points amount on the

We are looking to either:

a) Get Magento to always display points inclusive of VAT - and add the correct amount of points when an order is placed (and leave the points - pounds ratio as is) b) Get Magento to always display and add points excluding VAT - and hence we would put the points - pounds ratio up to compensate.

Any help or pointers on this would be greatly appreciated.


Solution

  • I had a client that needed this too, so I wrote a custom module that overrides the function that calculates the rewards only on pre-tax, to allow it to calculate on price + tax too. I just added a new option to the rewards configuration area to allow calculation including tax yes or no.

    Don't want to go through the process of describing how to create a custom module (there's plenty of resources for that), but the actual function that does the calculation is in this file: code/core/enterprise/reward/model/action/OrderExtra.php

    If you want to do it quick and dirty, find the getPoints function and change the $monetaryAmount calculation to be (if there is a $quote):

    $monetaryAmount = $quote->getBaseGrandTotal() - $address->getBaseShippingAmount();
    

    and (if no $quote)

    $monetaryAmount = $this->getEntity()->getBaseTotalPaid() - $this->getEntity()->getBaseShippingAmount();
    

    Hope that helps!

    EDIT: The actual code from the getPoints function should look something like this:

    if ($this->_quote) {
            $quote = $this->_quote;
            // known issue: no support for multishipping quote
            $address = $quote->getIsVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
            // use only money customer spend - shipping & tax
            $monetaryAmount = $quote->getBaseGrandTotal() - $address->getBaseShippingAmount();
    
            // *****CALCULATE POINTS INCLUDING TAX
            $monetaryAmount -= $address->getBaseTaxAmount();
    
            // set points to 0 if calcualtion is negative
            $monetaryAmount = $monetaryAmount < 0 ? 0 : $monetaryAmount;
        } else {
          // use only money customer spend - shipping
            $monetaryAmount = $this->getEntity()->getBaseTotalPaid() - $this->getEntity()->getBaseShippingAmount();
    
            // *****CALCULATE POINTS INCLUDING TAX
            $monetaryAmount -= $this->getEntity()->getBaseTaxAmount();
        }