Copied to clipboard

Flag this post as spam?

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


  • Basti Sørensen 5 posts 75 karma points
    Jul 18, 2019 @ 13:53
    Basti Sørensen
    0

    Teacommerce Discout Rule

    Hi

    I'm having trouble creating a discount.

    I would like to give an amount discount for a cover if you buy a specific pillow but it does not seem to be working?

    I dont want the customer to use a discount code, the discount should automatically apear when both items are in the basket?

    What is missing? enter image description here

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 18, 2019 @ 14:10
    Matt Brailsford
    0

    Are you saying you want this rule to add the cover item to the cart as well? Or should both items be added to the cart in order for the discount to work?

    The later is what the rule is doing so both items need to exist in the cart in order to apply.

    The rule looks for the first product and the award looks for the second product and applies a discount to it. If the second product isn't in the cart, it has nothing to apply it to so the discount doesn't apply.

    If you want to auto add the product to the cart on purchase you'd need to listen to order events for items being added to the cart and then add the second item or have the "add to order" button for the primary product add both products at the same time.

    Hope that helps

    Matt

  • Basti Sørensen 5 posts 75 karma points
    Jul 19, 2019 @ 08:04
    Basti Sørensen
    0

    Both items should be added to the cart in order for the discount to work.

    But when both products are in the cart, It still does not provide a discount on the Cover?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 19, 2019 @ 08:17
    Matt Brailsford
    0

    Hmm, I think it should work then.

    I'd be tempted to add another product rule for the Cover item so that the rule checks both products have to be in the cart in order for the discount to apply, but I'm not sure if that is what is preventing it from working.

    Might be worth a try though.

  • Basti Sørensen 5 posts 75 karma points
    Jul 19, 2019 @ 09:06
    Basti Sørensen
    0

    Hi Matt

    If I add another product rule for Cover it works when it is for example Pillow OR Cover.

    But not when it is set as Pillow AND Cover. We do not want to put Pillow OR Cover as a customer can just put a cover in the basket and get a 75% discount without purchasing anything else..

    Hovedpuder = Pillow / Sengetøj og Betræk = Covers.

    Any ideas??

    Basti

    enter image description here

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 19, 2019 @ 10:34
    Matt Brailsford
    0

    Ahh, OK, just looked into the code and I think I know what the issue is.

    Unfortunately the way the product rules work is they are effectivly filters, to fetch order lines that match a rule, so the first rule runs and it's values are passed into the next rule, so the problem here is that an order line can't be both types of product at the same time.

    If you see here how the product rule works, you'll see it takes in the list of order lines processed from previous rules and then filters them further https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/master/Source/TeaCommerce.Umbraco.Configuration/Marketing/Models/Rules/ProductRule.cs#L36

    Any order line based rewards are then defined to work on that filtered list of order lines, rather than all order lines in the order.

    The only way I could think to achieve it then would be to either create your own Rule (you can implement your own IOrderLineRules) which would be the "right but longer" approach, or as a quicker but gets the job done approach look at using the events system to listen for an order being updated and see if both items are in the cart and if they are, apply a discount rule or set and order property and create your rule as either a discount code rule or order property rule and that should do the trick.

    I must admit it does sound like the rules should work how you expected them to, but I'll need to review this to see how that can be implemented in a future release (it must have been built this way for a reason so I need to learn why),

    Hope this helps

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft