I need to sent an coupon code while new user registration. coupon code i based on category and its valid for one month. How to generate the coupon code in registration page.
You can find here a script that will generate a coupon code.
An other approach you could take is to create a coupon code in the backend and just put a debug code inside
Mage_Adminhtml_Promo_QuoteController::saveAction to see how the data sent through post looks like.
Mage::log($data, null, 'discount.log', true);
Then check the file
You should find there how the structure of the coupon data should look like.
Then create an observer for the
customer_register_success where you build an array that has the same structure as what is contained in the log file and do this:
$data = ...;//build your array here $model = Mage::getModel('salesrule/rule'); $model->loadPost($data); $model->save();