Copied to clipboard

Flag this post as spam?

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


  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 14:38
    Kyle Eck
    0

    Vendr Checkout with Custom Shipping Calculator but built in flat rate taxes

    Matt,

    Im using Vendr checkout and have disabled all of the Event Handlers just like the following:

    composition.WithCollectionBuilder<EventHandlerCollectionBuilder<OrderProductAddingNotification>>()
                .Remove<OrderProductAddingHandler>();
    
            composition.WithCollectionBuilder<EventHandlerCollectionBuilder<OrderLineChangingNotification>>()
                .Remove<OrderLineChangingHandler>();
    
            //composition.WithCollectionBuilder<EventHandlerCollectionBuilder<OrderPaymentCountryRegionChangingNotification>>()
            //    .Remove<OrderPaymentCountryRegionChangingHandler>();
    
            composition.WithCollectionBuilder<EventHandlerCollectionBuilder<OrderShippingCountryRegionChangingNotification>>()
                .Remove<OrderShippingCountryRegionChangingHandler>();
    
            composition.WithCollectionBuilder<EventHandlerCollectionBuilder<OrderShippingMethodChangingNotification>>()
                .Remove<OrderShippingMethodChangingHandler>();
    

    I am using custom flat rate shipping that we dictate and the ncalculate appropriately, this works fine once removing these handlers.

    How would I use built in taxes from the various US regions though?

    Can i mix the two (custom shipping, built in taxes?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 14:46
    Matt Brailsford
    0

    Hi Kyle,

    All those event handlers did was effectively clear the current shipping / payment method at different stages of the checkout. This was mainly to ensure that someone didn't go partially through the checkout, setting those values, but then navigating back and changing their cart such that the shipping / payment methods may no longer have been applicable.

    Anyways, those aren't essential so fine to remove them, but ultimately these shouldn't have any effect on what you are mentioning.

    RE settings the tax rates, in Vendr this would be done by configuring the US regions as regions under the USA country in the Vendr settings section. With the US regions setup, in the a tax class you'd then have the option to define the relevant tax rate per state.

    Vendr would then apply the relevant tax rate depending on the shipping country / region defined on the order.

    Hope this helps

    Matt

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 14:53
    Kyle Eck
    0

    Matt,

    I have all of the US regions inheriting their shipping and payment method, must these explicitly be set?

    Furthermore, if I have something like this defined, which is an injection point for a potential tax API:

            public override TaxRate CalculateShippingMethodTaxRate(ShippingMethodReadOnly shippingMethod, TaxSource taxSource, TaxRate fallbackTaxRate, ShippingCalculatorContext context)
        {
            //tax api call here?
            //see above method
            return base.CalculateShippingMethodTaxRate(shippingMethod, taxSource, fallbackTaxRate, context);
        }
    

    This would use the default tax rate correct? as i am not actually overriding anything, granted this may get hit instead of the built in method.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:00
    Matt Brailsford
    0

    No, you shouldn't need to explicitly set them (IIRC) and yes this should fallback.

    RE tax rate calculation though, I think we have some improvements we need to make on this for US customers. It's currently very much geared towards EU countries which will know the tax rates up front, where as in the US it appears taxes can be dependant on the cart items themselves.

    The problem here being that the tax rates are calculated as one of the first things in Vendr's calculation pipeline and then the price taxes are calculated as the pipeline goes along. Where as for US folk, I think what we need to do is actually calculate the tax rate after all pretax prices have been calculated.

    This is sort of possible now by forcing a 0% tax rate on everything and then using the PriceAdjustments API, returning a price with just a tax value in it, to apply the applicable tax value as an adjustment instead. This is how some of our other customers have tackled this with US customers.

    I'm not sure if this applies to you, but I've mentioned it anyways as I think it may do.

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 15:03
    Kyle Eck
    0

    It would apply if I used a tax api it would make complete send to be a price adjustment just like the shipping is, however, how does a price adjustment fall into line when using the default flat rated tax regions from vendr?

    I hope that makes sense?

    Could we shift the pipeline for taxes to be at the very end etc? How would that affect other pricing bits?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:07
    Matt Brailsford
    0

    Hey Kyle,

    We couldn't just shift the pipeline currently as like I say, a lot of the processes currently calculate pre + tax + total prices as they go along, where as I think it needs to do multiple loops instead, calculating pre tax, then calculating tax rates, then calculating tax + totals. So some of the pipelines potentially need breaking up (there is a further complication with the store setting of "Prices include tax" which means we do need to calculate tax rates straight away, but this isn't relevant to your issue)

    RE the price adjustments, you can control when it applies based on something on the order.

    Can you explain though, when do you need it to use flat rates? vs using the tax API?

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 15:11
    Kyle Eck
    0

    Matt,

    Essentially it comes down to however the client wants to calculate tax, i.e do they want to pay to use a tax api like taxjar or stripe taxes etc.

    If they do, then I can put my tax api call in like i showed above, if they dont want to pay for a tax api than i would use the regions in vendr.

    Regardless of using a tax api or the flat rates within vendr I dont get a tax rate at all, they are always $0.00. I had thought my custom tax calculator was messing this up but I am not so sure as of yet.

    Does that make sense? I should have an answer to this by this afternoon from the client but outside of that, I am still not calculating taxes, even with regions setup under my country and tax rates filled in for each region.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:16
    Matt Brailsford
    0

    Gotcha 👍

    Then something else is not quite right on the tax setup.

    Generally speaking an order get's a default tax class assigned to it on creation which dictates the tax rate to apply. This can be overridden at the product level by adding a tax class picker to the product.

    With those in place though, you should be able to control the flat rated taxes. Maybe double check to see what tax rate is assigned to the order and make sure it's the one you expect.

    Matt

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 15:18
    Kyle Eck
    0

    Matt,

    To follow up on your statement

    I think we have some improvements we need to make on this for US customers.

    Is there a scope for this to be implemented? I know your plate is overflowing most of the time.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:21
    Matt Brailsford
    0

    Potentially. As mentioned above, I think I have the "what we need to do" worked out so we could defo look at bringing that forward.

    We do have some other bits in progress which there is a demand for, but not sure if it's a dealbreaker for anyone atm.

    The only thing that's tricky is it being part of the calculation pipeline which invariably means lots of testing to ensure we don't break anything.

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 15:20
    Kyle Eck
    0

    Matt,

    One thing i forgot to mention, my tax class has a default of 0% and i let the regions dictate what percentage the sales tax should be, I have a feeling this could be the issue.

    If I supply a value for the standard tax rate, at what point does the region take over? After theyve put their state and zip in at checkout time?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:22
    Matt Brailsford
    0

    Correct, you need a country / region assigned to the order for it to then use the regions tax rate. The configured TaxSource dictates whether it's based on the billing or shipping country / region.

  • Kyle Eck 130 posts 280 karma points
    Jan 21, 2022 @ 15:27
    Kyle Eck
    0

    To be clear that region should be set in checkout when the user enters their state/zip right?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 21, 2022 @ 15:39
    Matt Brailsford
    0

    Correct (unless you explicitly assign it at any point earlier on the order)

Please Sign in or register to post replies

Write your reply to:

Draft