Copied to clipboard

Flag this post as spam?

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


  • Laurence Gillian 600 posts 1219 karma points
    Aug 15, 2016 @ 12:51
    Laurence Gillian
    0

    Accessing Marketing Rules in Code

    Hello!

    I'd like to be able to have access to the active marketing rules in my view logic and wondered if this was possible using an existing API?

    The use case, is that we offer 2 shipping variants, and also give free shipping for orders for say £100. I'd like to get back the current shipping discount, so when I'm updating totals, this is considered.

    E.g.

    var shippingDiscount = order.Discounts.ShippingDiscount // 100% or 0%
    

    Many thanks! Laurence

  • Anders Burla 2560 posts 8256 karma points
    Aug 16, 2016 @ 08:59
    Anders Burla
    0

    Hi Laurence

    So you want to see the discounts that has been applied to the order or do you want to show the marketing rules? The order doesnt have any info about how the discounts was applied - only what amount etc that is applied.

    The marketing engine is quite complex and its not easy to make a system where all info about how the discounts was applied, how much was applied etc is available. So we have made the info available the is the most basics. Let us know if you need anything else and we can try and see if we can make it available.

    Kind regards

    Anders

  • Laurence Gillian 600 posts 1219 karma points
    Aug 16, 2016 @ 09:11
    Laurence Gillian
    0

    Hey Anders,

    Thank's for the reply :-)

    Ideally there would be a method on the ShippingPrice that returned the Price including any discounts, or perhaps something that returned the shipping discount within the Order.

    If it's not available, I figured I could calculate it by:

    bool freeShipping = ((order.TotalPrice.Value.Value - order.SubtotalPrice.Value.Value) == 0);
    
  • Anders Burla 2560 posts 8256 karma points
    Aug 17, 2016 @ 09:43
    Anders Burla
    0

    The shipping price on the order does have the discount so you can print it - BUT you cant print your 3 different shipping methods with their original price and then a price it would have if it was applied to the order and maybe got discounted. I thing the demo.teacommerce.net website already write discounts for the shipping and other things in the cart flow.

    Kind regards

    Anders

  • Comment author was deleted

    Sep 22, 2016 @ 14:46

    Hi Anders, got a similar question, I've created a new marketing rule that checks if the user is logged in (well part of a membergroup), if he is he get's an award (say 50% of subtotal in this case).

    Now how do I show this calculated discount on the shopping basket? Since now it looks like this

    enter image description here

    Might be missing something obvious here, but just want it to display the name of the marketing rule with the calculated award

  • Anders Burla 2560 posts 8256 karma points
    Sep 22, 2016 @ 14:58
  • Comment author was deleted

    Sep 22, 2016 @ 15:09

    Nice, I now get the following which is good

    enter image description here

    But to further enhance this I would love to have a line for each marketing rule that is active...

    SO I would get

    SubTotal without discounts: 55

    Award due to rule 1 (rule name): -10%

    SubTotal with discounts: 50

    Does that make sense?

  • Anders Burla 2560 posts 8256 karma points
    Sep 23, 2016 @ 06:54
    Anders Burla
    2

    You can loop the order.SubtotalPrice.Discounts where you have the campaign name and then the value it discounted the subtotal.

  • Comment author was deleted

    Sep 23, 2016 @ 07:29

    Thanks Anders! :)

Please Sign in or register to post replies

Write your reply to:

Draft