I use the following code to generate the coupon code programatically
$coupon = commerce_coupon_create('commerce_coupon_pct');
commerce_coupon_save($coupon);
If these code run in xxx.module file, it will write two coupons in the database when I refresh the page .
If these code writed in a theme template file like page.tpl.php file , it runs well .
Do someone know why ?
Thanks !