1

If I apply 2 discount codes, I end up with a caption in my sub-total area will be :

Discount (discount number one, discount number two)

with the discount labels in brackets and separated by a comma

I want them as below

Discount 
   - discount number one
   - discount number two

With the discount labels shown as a list

I can't locate which file is doing this generation of the Discount label.

It is for use in Magento EE

3

To create beautiful discount breakdown we:
1. changed the template app/design/frontend/base/default/template/checkout/total/default.phtml for the block Mage_Checkout_Block_Total_Default via rewrite;
2. added observer to the items validation and collected prices/names in the address object;
3. added collected info to the $address->addTotal() call inside Mage_SalesRule_Model_Quote_Discount class;

$address->addTotal(array(
            'code'      => $this->getCode(),
            'title'     => Mage::helper('sales')->__('Discount'),
            'value'     => $amount,
            'full_info' => $address->getDiscountDescription(), // <-- new data
        )); 

The result looks as:

discount

  • Can you please explain more? I did not understand which observer I have to use and where I add my above code? – Rajan Soni Jul 27 '17 at 7:55
1

The best way to debug issues like this is to Enable Template Path hint in Magento

Template

  • app/design/frontend/base/default/template/checkout/total/default.phtml

Block

  • Mage_Checkout_Block_Total_Default
  • thanks, already got that, but that did not help me enough. – Memes Sep 30 '14 at 11:10
0

The part where the description is set is in the fetch-method in app/code/core/Mage/SalesRule/Model/Quote/Discount.php.

The important lines are:

$description = $address->getDiscountDescription();
...
$title = Mage::helper('sales')->__('Discount (%s)', $description);

getDiscountDescription() refers to the discount_description column in the sales_flat_quote_address table.

According to Mage_Sales_Model_Quote_Address the discount description can be set as string or array:

 * @method Mage_Sales_Model_Quote_Address setDiscountDescription(string $value)
 * @method Mage_Sales_Model_Quote_Address setDiscountDescriptionArray(array $value)

So my guess would be to rewrite Mage_SalesRule_Model_Quote_Discount and adapt your $descriptionthere.

  • no, I have one discount for a product and another discount for another product. made through shopping cart rules. – Memes Sep 12 '14 at 12:03
  • and for the database thing, I do not check as they are surely not stored together, they are 2 separated rules, therefore, the caption is generated when creating the shopping cart page. – Memes Sep 12 '14 at 12:05
  • Hi, I updated my answer – justin Sep 12 '14 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.