Copied to clipboard

Flag this post as spam?

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


  • von 61 posts 123 karma points
    Jul 30, 2014 @ 14:59
    von
    0

    Applying discounts

    How is this handled in Merchello? If the store is giving out coupons that can be use for discounts, should the coupons be created as contents? Then the price-off in the coupon will be inserted as a line item? If yes, at what point can I add the discount as a line item? And where should it be done?

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 30, 2014 @ 18:42
    Rusty Swayne
    0

    Hey Von,

    Great timing on this actually as I'm tasked to implement coupons for a client in the next few weeks.

    Merchello has a line item type of "Discount" which is intended to be used for this purpose among other things. In our scenario it makes more sense to apply the coupons during the checkout process (probably after quoting the shipping) but you could certainly wire something up to directly apply the discounted price on the product line item if that fits your requirements more appropriately.

    Other ways:

    Merchello also has essentially the same event model as Umbraco, so in some situations it may be useful to add discounts either in response to a Saving or Saved event.

    There are several builders that are based off of definable "Task Chains". Essentially this is a linked list of Umbraco Attempts which sequentially execute until either the end of the chain is reached or a failure occurs. Adding a new task is pretty straight forward but not well documented. Checkout the /App_Plugins/Merchello/Config/Merchello.config file and if this is a direction you want to go, lets hookup on Skype or something and do a Q/A session =)

  • Paul Brown 39 posts 80 karma points
    Jan 14, 2015 @ 10:33
    Paul Brown
    0

    Hi Von / Rusty

    Could either of you update me as to any progress thats been made on this subject?

    Cheers Paul

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 14, 2015 @ 14:20
    Rusty Swayne
    0

    Hi Paul,

    I've been doing some of the ground work prepping to add another section to the back office. In a nutshell, we wanted to get Merchello into it's own angular module and clean some things up before adding a bunch of new code =)

  • Chris Foot 61 posts 93 karma points
    Feb 23, 2015 @ 22:24
    Chris Foot
    0

    Hi Rusty,

    I'm trying to implement discounts on the site i'm building but i'm struggling to work out how to add the discount items to the basket. I have tried the following:

    ILineItem moneyOffItem = new OrderLineItem(LineItemType.Discount, "Test Discount", "discount123", 1, -discountAmount);
    Basket.Items.Add(moneyOffItem);
    

    But that just errors when I come to save the basket as modifying the items collection directly doesn't put it into the cache. I can't seem to spot an override to Basket.AddItem that will allow me to specify a LineItemType. I have also tried using Basket.SalePreparation().AddItem(moneyOffItem) but that doesn't seem to work for me either.

    What have I missed?

    Thanks

    Chris

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Feb 23, 2015 @ 23:11
    Rusty Swayne
    0

    Hi Chris,

    A basket line item is an ItemCacheLineItem. Try

    ILineItem moneyOffItem = new ItemCacheLineItem(LineItemType.Discount, "Test Discount", "discount123", 1, -discountAmount);

  • Chris Foot 61 posts 93 karma points
    Feb 24, 2015 @ 10:44
    Chris Foot
    0

    Hi Rusty,

    That works much better! In case anyone else comes to do this in the future I've discovered that the discount amounts have to be positive numbers to get them to be removed from the invoice total. This does however, cause the Basket.TotalBasketPrice to be calculated with them added on but that can be got around fairly easily!

    EDIT: Actually, I have found now that adding them with positive numbers causes the tax to be calculated incorrectly if you want your discounts taxable (This particular site wants tax calculated on the subtotal after discounts) so I have had to put them in with minus amounts and compiled my own version of merchello with line 89 of invoicebuilderchain.cs changed from

    attempt.Result.Total = Math.Round(decimal.TryParse((charges - discounts).ToString(CultureInfo.InvariantCulture), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture.NumberFormat, out converted) ? converted : 0, 2);
    

    to

    attempt.Result.Total = Math.Round(decimal.TryParse((charges + discounts).ToString(CultureInfo.InvariantCulture), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture.NumberFormat, out converted) ? converted : 0, 2);
    

    Rusty, is this approach likely to break anything else?

    Thanks for your help

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft