Copied to clipboard

Flag this post as spam?

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


  • Adam Shallcross 55 posts 211 karma points MVP c-trib
    1 week ago
    Adam Shallcross
    0

    Discount errors

    Hi Matt

    So we have tried to implement a discount and add a rule that only allows it got be used by a particular member group.

    When we try and use it on the front end though we get an error.

    ![enter image description here][1]

    ![enter image description here][2]

    We are using Vendr v1.3.3 and your checkout package as well.

    Any ideas why this might be happening?

    Cheers

  • Matt Brailsford 2852 posts 14824 karma points MVP 7x c-trib
    1 week ago
    Matt Brailsford
    0

    Hey Adam.

    What does the JSON for the discount rules look like in the database. It looks like it's having a problem deserializing it, with the group MatchType coming back as null 🤔

    Matt

  • Marcin Zajkowski 104 posts 566 karma points MVP 3x c-trib
    1 week ago
    Marcin Zajkowski
    0

    Hey Matt!

    That's what's inside the rule Adam created:

    {"ruleProviderAlias":"groupDiscountRule","settings":{"matchType":"All"},"children":[{"ruleProviderAlias":"memberGroupDiscountRule","settings":{"memberGroups":"[\"Friend\"]","matchType":null},"children":[]}]}
    

    And that's the reward JSON:

    [{"rewardProviderAlias":"orderAmountDiscountReward","settings":{"priceType":"TotalPrice","adjustmentType":"Amount","percentage":null,"amounts":"{\"50f2194f-9135-411c-acb3-c2bf8cfdd19c\":30}","amountsIncludeTax":"True"}}]
    

    From what I can see the matchType is null what looks like a source of the problem?

  • Adam Shallcross 55 posts 211 karma points MVP c-trib
    1 week ago
    Adam Shallcross
    0

    Hiya, sorry I have added the match type now to say 'all' and the error has gone, but the discount is not being applied.

    It is is saying it is attached, but not discount is being deducted.

    enter image description here

    enter image description here

  • Marcin Zajkowski 104 posts 566 karma points MVP 3x c-trib
    1 week ago
    Marcin Zajkowski
    0

    Ok, so the null reference bug is purely because of lack of selection there (maybe a mandatory field? or some catch there?)

    The main issue is related only with the "Group" rule. Any other methods works there.

    We've found recently that in Umbraco IMember, the cast object has null value in Member's properties. Any chance that you're using this property to validate if member is in role or has the role(s) described in the rules??

  • Matt Brailsford 2852 posts 14824 karma points MVP 7x c-trib
    1 week ago
    Matt Brailsford
    100

    Good catch on the Match Type, we'll see what can be done about making fields mandatory. At the very least, it should have a default value such that this error doesn't display.

    Regarding the discount applying, the order first of all needs to be assigned to a member as it's from the orders customer reference that we test the rule against, not the member that is currently in session.

    By default Vendr should try to assign the customer at 2 stages. 1 when the order is created (there is a bug on this one which will be fixed in 1.3.4, the next patch release) and 2 just before the order is about to go to the payment screen. Outside of this you'll need to call order.AssignToCustomer() to manually assign the order to a customer. It's quite possible that the customer may not have been logged in at the point of creating the order, but later logs in. If that is the case, you need to call this method as unfortunately, there is no universal way for us to know when a session becomes authenticated / unauthenticated.

    My guess then is that the order isn't assigned to the logged in customer and so the discount isn't applying.

    Matt

  • Adam Shallcross 55 posts 211 karma points MVP c-trib
    7 days ago
    Adam Shallcross
    1

    Indeed, associating the order with the member solved this issue. The order now knows that the member is logged in and the discount is allowed for the group the member is associated with.

Please Sign in or register to post replies

Write your reply to:

Draft