Remove coupon code from new order email and insert label of coupon instead

Does anyone know how to edit the following to have the name of the coupon as the label on the new order sales email instead of the coupon code?

<?php foreach ($this->getTotals() as $_code => $_total): ?>
    <?php if ($_total->getBlockName()): ?>
        <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
    <?php else:?>
    <tr class="<?php echo $_code?>">
            if ($_code=="discount") {
              $code_used = trim(str_replace(array("Discount (",")"),array(""),$this->escapeHtml($_total->getLabel())));
              $coupon = Mage::getModel('salesrule/coupon');
              $coupon->load($code_used, 'code');
              $rule = Mage::getModel('salesrule/rule')->load($coupon->getRuleId());
              $rule_name = $rule->getName();

         <td <?php echo $this->getLabelProperties()?>>
            <?php if ($_total->getStrong()):?>
            <strong><?php echo $this->escapeHtml($_total->getLabel());?></strong>
            <?php else:?>
            <?php echo $this->escapeHtml($_total->getLabel());?>
            <?php endif?>
        <td <?php echo $this->getValueProperties()?>>
            <?php if ($_total->getStrong()):?>
            <strong><?php echo $this->formatValue($_total) ?></strong>
            <?php else:?>
            <?php echo $this->formatValue($_total) ?>
            <?php endif?>
    <?php endif?>
<?php endforeach?>


Magento offers the possibility to add labels to your coupons. Check the 'Labels' tab while editing a discount rule. You can set a default value for the label (Default Rule Label for All Store Views) and/or separate labels for each store view.
That label is used everywhere the rule is used: in the cart totals, in the checkout totals, in the e-mail templates, in the order details view... I would use that one instead of trying to display the name of the rule.

This feature is available starting Magento CE1.4/ EE1.9 (I think). If you are using that version or something higher it should be available.

Tags: Email / Sales

Similar questions

How to get option label and there value's label from params passed by product page?
I have created a new action which is called when the customer select the options on product page and submit the product form. I get this array when i print the params posted. Now how should i get the option labels so that i can save the information what customer have selected in the custom table i have created in the database. As you can see there ...
Adding attributre label and attribute option value label to get cart rest api in magento2
Hi I want to add attribute label and attribute option value label to Magento 2 Guest cart REST API response like below screen shot by overriding default magento 2 files. Please help to me
Add coupon to order programmatically with modified coupon code
I've modified the coupon validation function to check for grouped SKUs as well as the simple SKU. It works great on the Magento front end, but I have a process that creates an order programmatically, and I'm not able to get the coupon to work there. I've traced it down to the fact that since the programmatic order doesn't use the checkout/cart, it ...
How to remove bundle product new and sale label in product list page
I would like to remove bundle product new and sale label in product list page. How can i do that Eg: My code
Adding custom generated coupon code from observer to New Account email template
I have written a custom observer during customer save after event to generate unique coupon codes and append in welcome email during that is sent during Customer Registration. The coupon code functionality is working fine. Using send() I am trying to pass the custom variables I stored in an array. But I am unable to add it in the template. Please f...
How do i find the variable name for coupon code and coupon value?
Can anyone tell me how I can include the coupon code and value of the coupon in an Order CSV that gets sent to the order fulfillment company? I am using Magento CE 1.8.1. Basically when an order is generated, it also generates a CSV file with the order details and uploads this to the order fulfillment company. Looking through the code I can see tha...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.