2

I need a help to create a 15% OFF coupon code for products.

This coupon is only for people who have subscribed to our newsletter.

As far as I know, there is no option in Magento to do so, but is there anyone who can help me in this?

0

First Create a Shopping Cart Price Rule for 15 % Off, now use that rule in your custom module.

class Namespace_Yourmodulename_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
{
public function getCouponCodecustom(){

    try {

        $data = array(
            'rule_id' => 123,
            'qty' => 1,
            'length' => 8,
            'format' => Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC,
            'uses_per_coupon' => 1,
            'uses_per_customer' => 1
        );
        $generator = Mage::getModel('salesrule/coupon_massgenerator');
        $generator->setData($data);
        $generator->generatePool();

    } catch (Mage_Core_Exception $e) {
        $session->addException($e, $this->__('There was a problem with coupon: %s', $e->getMessage()));
    }
    catch (Exception $e) {
        $session->addException($e, $this->__('There was a problem with coupon.'));
    }
 }
}

You can get the coupon code in Newsletter by short code {{var subscriber.couponCodecustom}}

Newsletter Subscription Success
Thank you for subscription, your coupon code <b>" {{var subscriber.couponCodecustom}} "</b>

Thats it!

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.