Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Trevor Loader 199 posts 256 karma points
    Aug 21, 2015 @ 03:46
    Trevor Loader

    Taxes included in product prices


    Since v1.10 you can set up Merchello to allow the store owner to input tax inclusive prices against a product.

    To set it up

    1. Merchello -> Settings -> "Set how taxes are applied" = "Product"
    2. Merchello -> Gateway Providers -> Taxation -> "Include in product pricing"

    However, using Merchello Bazaar as the front end, the price still displays with the tax applied on top of the entered tax inclusive price. Eg, price entered as $18 is displayed as $20.70 (GST is 15% in NZ).

    Is there something also I need to do to configure this properly?

    I note that when checking out, the "total tax" added to the order is $0.00 - so it does appear that it is semi-aware that the tax is already included in the line item pricing.

    Any help, much appreciated. Cheers, Trevor

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 21, 2015 @ 03:51
    Rusty Swayne

    Trevor - I'd like to see this if you don't mind doing a screen share with me over Skype ... it works without a hitch in every test I've done. Mind if I ping you to set something up?

  • Trevor Loader 199 posts 256 karma points
    Aug 21, 2015 @ 19:24
    Trevor Loader


    Firstly a big thanks to Rusty for taking the time to understand my issue (mostly my confusion) and helping come up with a solution.


    Now, my first problem was a misunderstanding of the new features introduced in v.1.10. This feature was to allow the shop admin to enter product pricing "tax exclusive" but have the products rendered on the front end with taxes already applied (tax inclusive). That feature works as stated.

    However, in NZ when it comes to consumer to consumer commerce, most shop admins only care about the tax inclusive price and want to enter in the product as $29.95 and have it displayed as $29.95 on the front end. On the resulting invoice however, we want to state that the invoice total "includes tax of $xx.xx".


    Merchello setup: 1. Set your country tax rate provider and leave "include in product pricing" unchecked. 2. Enter all your products with "This variant is taxable" unchecked! (I know it doesn't seem right but trust me).

    Now add the following into your App_Code folder (I've named the file TaxesVisitor.cs).

    using Merchello.Core;
    using Merchello.Core.Gateways.Taxation;
    using Merchello.Core.Models;
    using Merchello.Core.Services;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Umbraco.Core.Logging;
    /// <summary>
    /// Summary description for TaxesVisitor
    /// </summary>
    public class TaxesVisitor : ILineItemVisitor
        private ITaxMethod _taxMethod;
        private bool _productPricingEnabled = false;
        private IGatewayProviderService _gatewayService = MerchelloContext.Current.Services.GatewayProviderService;
        private TaxationGatewayProviderBase _productTaxProvider;
        private decimal _taxTotal = 0M;
        public decimal TaxTotal { get { return _taxTotal; } }
        public TaxesVisitor()
        public void Visit(ILineItem lineItem)
            if (!_productPricingEnabled) return;
            var productProvider = _productTaxProvider as ITaxationByProductProvider;
            if (lineItem.LineItemType != LineItemType.Product && lineItem.LineItemType != LineItemType.Shipping) return;
            if (productProvider != null)
                var taxMethod = productProvider.GetTaxationByProductMethod(_taxMethod.Key);
                var baseTaxRate = taxMethod.TaxMethod.PercentageTaxRate;
                var taxRate = baseTaxRate > 1 ? baseTaxRate / 100M : baseTaxRate;
                // according to NZ IRD GST laws, you can calc gst one of few just have to do it consistently!
                // I'm going to calc on each line item, calculating the gst on a single unit and rounding and then
                // multiple that by the quantity ordered.
                // Therefore if the product is $29.95 (incl of 15% gst) then
                // GST = 29.95 - ( 29.95 / 1.15 ) = 3.906521 = 3.91
                // if I ordered 3 of them, the tax is $11.73.
                // note, the rounding difference if you calculated GST on the total line item
                // 29.95 * 3 = 89.85 - (89.85 / 1.15) = $11.72
                _taxTotal += Math.Round(lineItem.Price - (lineItem.Price / (1M + taxRate)), 2) * lineItem.Quantity;
        private void initialise()
            var taxationContext = MerchelloContext.Current.Gateways.Taxation;
            if (!taxationContext.ProductPricingEnabled) return;
            _productPricingEnabled = true;
            _taxMethod = _gatewayService.GetTaxMethodForProductPricing();
            _productTaxProvider = taxationContext.GetProviderByMethodKey(_taxMethod.Key);

    Now in your code that displays the order information (eg if using Merchello Bazaar, InvoiceSummary.cs script) instantiate the taxes visitor and apply it against the Invoice.

    var visitor = new TaxesVisitor();

    At this you can output the tax amount however you like. I've included a new table row after the invoice total that outputs the "includes GST of" amount like this:

            <td colspan="3" class="text-right">(includes GST of)</b></td>
            <td class="text-right"><span id="tax-total">@ModelExtensions.FormatPrice(**visitor.TaxTotal**, Model.Currency.Symbol)</span></td>

    And voila! There you have everything calculating correctly for tax inclusive pricing.

  • Dacre 3 posts 72 karma points
    Feb 14, 2018 @ 10:11

    Thanks - this helped me a lot!!!

  • Paul Nilsson 1 post 71 karma points
    Oct 29, 2015 @ 15:16
    Paul Nilsson

    I tryed this and it woks great in the cart. But in the order confirnation mail and in the backoffice the tax is still 0.

    I'm using the latest Merchello 1.13.0.

    What do I have to do to get it to update these too?

  • Marcus Maunula 229 posts 386 karma points
    Oct 29, 2015 @ 19:09
    Marcus Maunula

    How would you go about putting variable taxes on products? That is something I can't get my head around.

    Eg. Some Products have 25% VAT, some 6% etc. How?

  • progproger 52 posts 130 karma points
    Mar 16, 2016 @ 13:40

    Hi Marcus,

    Any update on this?

  • Marcus Maunula 229 posts 386 karma points
    Mar 16, 2016 @ 13:47
    Marcus Maunula

    I have decided to go with uCommerce for now. The amount of work to adapt it to Nordic circumstances seems to much at the moment. I will look into Merchello for the next Project.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Nov 04, 2015 @ 23:49
    Rusty Swayne

    @Marcus - you would need to create a custom tax provider based on product categories. Take a look at the included Flat Rate Tax Provider - I'd think it would be very similar, only you would need to look up the base tax rate per product for the computation.

  • Marcus Maunula 229 posts 386 karma points
    Nov 07, 2015 @ 14:09
    Marcus Maunula

    I thought about that but I couldn't find any docs on how to create providers.

  • Arjan Woldring 124 posts 231 karma points
    Mar 06, 2017 @ 10:12
    Arjan Woldring


    I do have exactly the same issue.

    Many webshops for Business to Consumers (B2C ) in The Netherlands do want to fill in prices vat included in backoffice and want to show the exact same price on the product in the frontend. In the checkout it needs to say how much tax was calculated.

    My question, is the post from Trevor still the way to go? Does it also work for Fasttrack?

    Any info would be great!

    Cheers, Arjan

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Mar 06, 2017 @ 17:04
    Rusty Swayne

    In the Merchello 2.4.0 release, a new strategy was included to make this easier.

    In the Merchello.config file find strategies and comment out the default InvoiceItemizationStrategy and uncomment the Merchello.Core.Strategies.Itemization.ProductBasedTaxationInvoiceItemazationStrategy line. This will immediately re-itemize things in the back office.

        <strategy alias="DefaultPackaging" type="Merchello.Core.Strategies.Packaging.DefaultWarehousePackagingStrategy, Merchello.Core" />
        <strategy alias="DefaultShipmentRateQuote" type="Merchello.Core.Gateways.Shipping.DefaultShipmentRateQuoteStrategy, Merchello.Core" />
        <strategy alias="DefaultInvoiceTaxRateQuote" type="Merchello.Core.Gateways.Taxation.FixedRate.FixedRateTaxCalculationStrategy, Merchello.Core" />
        <strategy alias="DefaultAnonymousBasketConversionStrategy" type="Merchello.Web.Workflow.BasketConversionByDiscardingPreviousCustomerBasket, Merchello.Web" />
        <!--strategy alias="DefaultAnonymousBasketConversionStrategy" type="Merchello.Web.Workflow.BasketConversionByCombiningAnonymousBasket, Merchello.Web" /-->
        <strategy alias="InvoiceItemizationStrategy" type="Merchello.Core.Strategies.Itemization.DefaultInvoiceItemizationStrategy, Merchello.Core" />
        <!--strategy alias="InvoiceItemizationStrategy" type="Merchello.Core.Strategies.Itemization.ProductBasedTaxationInvoiceItemazationStrategy, Merchello.Core" /-->

    The code for the actual strategy is here:

    It uses an visitor class to itemize the invoice. That can be found here:

    You also have the option of writing your own strategy (just follow the examples above and put the type reference to the custom strategy class in the Merchello.config).

    You can use the same strategy on the front end (like the receipt if you need to) but it's not wired into FastTrack at the moment - but I'll add that as a task for the 2.6.0 as it makes sense to do so.

    If you wanted to do it quickly in the meantime you could do it right in the view (or override the CheckoutSummaryController).

    In the view:

      var invoice = MerchelloContext.Current.Services.InvoiceService.GetByKey(model.InvoiceKey);
      // there is already an extension to resolve the strategy from IInvoice
      var itemization = invoice.ItemizeItems();
      return itemization.ToInvoiceItemItemizationDisplay();

    Note: adding the strategy to FastTrack in version 2.6.0 will be a minor breaking change in the factory that builds ICheckoutSummaryModel<TBillingAddress, TShippingAddress, TLineItem> if you go the route of overriding the controller ...

  • Arjan Woldring 124 posts 231 karma points
    Mar 06, 2017 @ 19:03
    Arjan Woldring

    Hi Rusty,

    Thank you for the extensive answer. This week I'll look into this. Hopefully I'll figure it all out ;)

    Thanks for helping!

  • Marcus Maunula 229 posts 386 karma points
    Mar 06, 2017 @ 18:56
    Marcus Maunula

    The best would be if you could simply put the VAT on the product individually. Otherwise it will always be a case of using extended data for non US-countries.

    Simply because many Countries use differentiated VAT based on product types. For instance Books here have 6% VAT, Food 12% and rest 25%.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Mar 06, 2017 @ 19:08
    Rusty Swayne

    The VAT value and product price does get put into the ExtendedData collection of the product line item.

    On the road map for Merchello 2.6.0 is a new taxation provider to handle taxation for various tax categories. It'd be great if you would write up your thoughts in the discussion.

  • Arjan Woldring 124 posts 231 karma points
    Mar 07, 2017 @ 09:02
    Arjan Woldring

    Posted my 2 cents on the issue tracker :)

  • Marcus Maunula 229 posts 386 karma points
    Mar 07, 2017 @ 22:23
    Marcus Maunula

    Essentially the same issue I have.

  • Tito 314 posts 623 karma points
    Apr 21, 2017 @ 09:10

    Hi Rusty, do you have any idea when will Merchello 2.6.0 be available? i am going to start a new project and would like to start with this version. Will it work with Umbraco v7.6?

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Apr 21, 2017 @ 12:18
    Rusty Swayne

    We are really just getting started on 2.6.0 - I've been on holiday and busy just getting organized/planning - and don't have an estimated time table as of yet.

    It will definitely work with 7.6 =)

  • Marcus Maunula 229 posts 386 karma points
    Mar 06, 2017 @ 20:47
    Marcus Maunula

    I did but maybe not that issue ;). Forgot where I put it.

    Essentially I would like more configurations for individual products when it comes to VAT. Similar to how uCommerce does it if you need inspiration :).

Please Sign in or register to post replies

Write your reply to: