Magento – add discount coupon code in newsletter subscription

magento-1.9newsletter

How to add a unique coupon code for newsletter subscriber. I am beginner in magento so please help how to send subscription email with this coupon code. please help.

Best Answer

1) Manual solution:

  1. Create a coupon with your desired rules

  2. Set the number of uses to 1 per customer and unlimited for general usage.

  3. Copy the coupon code in the newsletter email

Path: app/design/frontend/{your package}/{your theme}/locale/language_ISO/template/email/newsletter_subscr_confirm.html for exemple.

2) The dynamic one:

Create an observer on the newsletter_subscriber_save_before or newsletter_subscriber_save_after that checks if the customer subscribes and if so, it creates a coupon with your desired settings. See this for creating coupons by code.
Then rewrite the method Mage_Newsletter_Model_Subscriber::sendConfirmationSuccessEmail so you can pass that code as a parameter to the e-mail template.
Something like this:

$email->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
        Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
        $this->getEmail(),
        $this->getName(),
        array('subscriber'=>$this, 'coupon_code'=>THE COUPON GENERATED IN THE EVENT)
    );

Then modify the newsletter subscription e-mail template to include this:

Your coupon code is: {{var coupon_code}}

Reference.

Related Topic