Copied to clipboard

Flag this post as spam?

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


  • John Logan 24 posts 65 karma points
    Nov 18, 2021 @ 22:11
    John Logan
    0

    Get shipping discount on current order when in cart page

    Hi

    I am trying to add some user feedback messages in the cart page.

    the messages are based around the delivery/shipping charge

    if the current order doesn't meets the requirements for free shipping then I want to add a message about how much they still need to buy before getting to that threshold

    I have tried a few things

    currentOrder.ShippingInfo.TotalPrice.Adjustment is the property I am looking at currently

    but it seems like I need to force the calculation at an earlier stage in the process than what is currently happening ie if I go through to the confirmation page (just before cc details are taken) then back to the cart then I start to see the values I expect.

    Is there a way to get the current calculated shipping amount after discount - no matter where you are in the checkout process?

    the actual shipping rates are very basic - only 1 country and its a flat rate

    there are 2 active shipping discounts 100% shipping discount when order total is greater than x 100% shipping discount when order has at least 1 x product y in it

    Cheers J

    Umbraco version 8.11.1 Vendr 1.8.3 Vendr Checkout 1.2.0

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 19, 2021 @ 09:01
    Matt Brailsford
    0

    Hi John,

    I think the problem is likely the use of Vendr Checkout as it's kind of opinionated in it's implementation. Effectively, that package will remove the shipping / billing countries from the order until you get past the billing information stage and so this is why your calculation isn't working till after this stage.

    The reason Vendr Checkout does this is because if someone goes to the checkout and completes their billing details, but then goes back and changes the order, you could get into a position where the order may no longer be shipable to that location and so the pricing information being displayed would be a little bit missleading and so we clear all this information until you get back to that step.

    If you want to disable this functionality, you could setup a composer to run after the Vendr Checkout composer and then remove all the event handlers Vendr Checkout registers here https://github.com/vendrhub/vendr-checkout/blob/v1/main/src/Vendr.Checkout/Composing/VendrCheckoutComposer.cs#L14-L30

    Hope this helps / makes sense.

    Matt

  • John Logan 24 posts 65 karma points
    Nov 19, 2021 @ 09:59
    John Logan
    0

    Hi Matt

    Thanks for the quick reply.

    I did a quick check on the properties of the shipping info when I get to the cart page

    currentOrder.ShippingInfo.CountryId has a value at this stage

    the currentOrder.ShippingInfo.ShippingMethodId does not

    I know there is at least 1 shipping method available in
    VendrApi.Instance.GetShippingMethods(store.Id)

    so if I set the ShippingMethodId would that trigger the handler to update the price such that

    currentOrder.ShippingInfo.TotalPrice.WithoutAdjustments and currentOrder.ShippingInfo.TotalPrice.Adjustment

    would then return the correct values

    if so how do I make the currentOrder.ShippingInfo writable?

    Cheers J

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 19, 2021 @ 10:06
    Matt Brailsford
    0

    Hi John,

    Yes it would, though I'd still think you might need to remove the event handlers mentioned above.

    In terms of setting the shipping method you'll need to make the current order writable (see the docs here https://vendr.net/docs/core/2.0.0/umbraco-v9/key-concepts/readonly-and-writable-entities/) and then call it's SetShippingMethod method to set the shipping method accordingly.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft