Copied to clipboard

Flag this post as spam?

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


  • Tom W 39 posts 96 karma points
    Sep 24, 2020 @ 12:59
    Tom W
    0

    Do not discount bundled line items

    Hi Matt!

    Have a quick question about bundling and discounts, I hope you can help.

    We have a requirement to be able to allow a customer to add a gift wrap option to products. This can be one of many products. I've already manage to extend OrderLineReadOnly to get the correct product/id, and we have a SurfaceController action that allows us manage what's updated to the basket (quantities, and whether gift wrapping is available)

    https://vendr.net/docs/core/1-3-0/key-concepts/product-bundles/

    I know that we can add a product to the bundle, which is awesome, using order.AddProductToBundle(bundleId, subProductReference, subProductQuantity);

    However, we don't ever want to discount the gift wrapping price. I'm using a few of your (very nice) built in Rules and Rewards, and a custom Rule too. Worked a treat.

    However, when the discount is applied (any OrderLine discount) it applies to everything in the line. Hence with a 10% discount, on a £100 product, with a £3 gift wrapping charge, I need this to be (100*0.9=90) + 3 = £93. But I'm actually getting £103 - £10.30 = £92.70

    I've seen that there's a concept of Calculators. I could write my own OrderLineCalculator to prevent this, but it would effectively be exactly the same as your default, without applying discounts to bundled lines.

    Do you have any suggestions?

    Many thanks, loving Vendr.

    Tom

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 24, 2020 @ 13:17
    Matt Brailsford
    100

    Hmm, that's a very good question 🤔

    I think this may be possible with a custom reward provider. Maybe this could be a BundleOrderLineBasePriceDiscountReward and the reward you provide gets calculated against the order lines UnitPrice.Base property. It would have to be returned as a UnitPrice discount but I think being just calculated against the base price should work.

    I'll have to think whether there is an easy option I could add to the current rules / rewards to say whether they apply to bundle order lines, but hopefully a custom reward as mentioned above should cover it for now.

    Give it and try and let me know how you get on.

    Matt

  • Tom W 39 posts 96 karma points
    Sep 24, 2020 @ 13:21
    Tom W
    1

    That's some speedy, quality service Matt, thanks!

    I certainly will... cheers

  • Tom W 39 posts 96 karma points
    Sep 24, 2020 @ 14:07
    Tom W
    1

    Legend... I must admit I was a little daunted about rewriting all of your logic for calculating the discount, so I cheated a little (email me if you want to, and don't know, how)... but I now have my own reward provider, which has the same options as yours, but then an boolean to "exclude bundled items". If checked, it uses the Base price

    decimal withoutTax = settings.ExcludeBundledItemsFromCalc ? item.UnitPrice.Base.WithoutTax * value1 : item.UnitPrice.Value.WithoutTax * value1;
    

    Works an absolute treat. Big relief, as the bundling was exactly what we needed for gift options. Thanks again! You do rock.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 24, 2020 @ 14:11
    Matt Brailsford
    0

    That's awesome!

    So cool you were able to work it out and that's a pretty darn good solution. I'll take a look at whether that makes sense to incorporate into the existing order line discount reward, but again, that fantastic you were able to create your own as the work around.

    🤘🎉🎉🎉

Please Sign in or register to post replies

Write your reply to:

Draft