swipestripe / silverstripe-swipestripe

Ecommerce module for SilverStripe
http://swipestripe.com
33 stars 49 forks source link

Show price including tax rates in front-end. #74

Open luukgruijs opened 10 years ago

luukgruijs commented 10 years ago

Hi, I would like to show the price of a product including tax. The tax is now shown during checkout.

In Holland company's don't have to pay the tax. So then it wouldn't be a problem. But since my shop is for consumers it would be nice to see the total price per product before the checkout.

Do you have any idea's?

luukgruijs commented 10 years ago

i cant seem to find the place where the modification is added to the totalprice. As described above, i basically only like to display the tax, but it shouldn't be added to the totalprice. Any ideas?

stevie-mayhew commented 10 years ago

Hey @luukgruijs

We tend to just do this as a simple extension on order:

Order:
  extensions:
    - 'OrderExtension'
<?php

class OrderExtension extends DataExtension
{
    public function GSTAmount()
    {
        $order = Cart::get_current_order();
        $subtotal = $order->Total();

        return number_format($subtotal->getAmount() * 3/23, 2);
    }
}
luukgruijs commented 10 years ago

Thanks for your reply, I doesn't seem to work with a copy and past. Can you explain what you did?

stevie-mayhew commented 10 years ago

Once you've added the above extension and yml config, and have performed a ?flush=1 you can add something like the following to your OrderFormCart.ss. You might need to copy that file out of swipestripe and into your theme includes folder.

(includes ${$GSTAmount} $TotalPrice.Currency GST)