• 15

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Magento Show Multiple Discounts Breakdown

I have installed a rewards module into my Magento build. I have also set up some shopping cart promotions. Everything works. On the shopping cart page you can redeem reward points and enter a discount code and everything is discounted correctly. The problem is that they are both labelled under the 'discount' label (where 1,000 points = £1 off)

(source: i.imm.io)

As you can see, it is grouping the £5 coupon discount and the £1 rewards discount together. How do I separate these so that I have two discount rows, one for the coupon and one for the rewards points?

This is not a simple task. Unfortunately Magento's discount system is not supremely prepared for the addition of new discount types that you might not want added together in the cart totals box.

It's true that you need to modify the resetDiscountLabels() method of the TBT_Rewards_Model_Salesrule_Observer class. However, this method is not where Sweet Tooth adds its discount to the discount description. Quite the opposite. Sweet Tooth's discounts are automatically added to Magento's list of discounts on the cart (and the discount description is generated automatically from this list of discounts). The problem is that even the Sweet Tooth discounts that shouldn't be added to the cart will show up there - the discounts that apply to the cart based on the rule you created, but the customer hasn't actually selected to spend their points yet. The resetDiscountLabels() method exists to remove the unwanted discount descriptions from the cart, not add any.

The solution to your problem comes in two steps, and the second step is the more taxing.

First you must modify the above-mentioned method to remove all Sweet Tooth discount descriptions from the cart, rather than just those that don't apply. I would suggest copying the file to your app/code/local codepool first, and modifying that file instead of the original. If you loop through all rule IDs on the cart, then load the rule model, you can tell if it's a Sweet Tooth rule or not if its points_action field is set, i.e. $rule->getPointsAction() !== null. If any of the rules are Sweet Tooth rules, you can unset them from the discount description the way that method is already doing it. After this, Sweet Tooth discounts should no longer appear in that row of your totals box.

The second step is to add a new row to the totals box, a.k.a. add a new total model to the quote. This will be the more complicated step - much more complicated than I can describe in this answer, but here is a tutorial on adding new total columns: http://turnkeye.com/blog/magento-development-add-total-row-checkout/ In your new total model's collect() method, you should check the quote's applied_redemptions field to get a list of Sweet Tooth rule IDs that the customer has applied to their cart. You can then regenerate the total Sweet Tooth discount using these values.

As I said, this is not a simple task, and unfortunately this is the only semi-clean way to do it. Hopefully it's not too much. You could also always hire a development firm to do it for you, if you'd rather focus your own dev time on other tasks.

Hopefully this is useful!

  • 11
Reply Report
    • @Richard Parnaby-King: could you let us know if you ever successfully solved your problem? I'm very curious!

You would need to modify /TBT/Rewards/Model/Salesrule/Observer.php - check checkRedemptionCouponBefore() for the discount amount and check resetDiscountLabels() - this is where Sweet Tooth adds its discount to the discount description.

You may also need to modify /app/design/frontend/base/default/template/rss/order/details.phtml - after the lines if ($_order->getDiscountAmount() > 0)

  • 4
Reply Report
    • If he didn't call resetDiscountLabels() he would lose the Sweet Tooth discount label entirely, but it sounds like he just wants to separate them.
      • 2
    • It's not about not calling that function but extending it to show the breakdown. I've pointed out the exact points where the 2 discounts are put into a single line.

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions