這裏Magento的優惠券代碼是我的代碼,動態創建的優惠券代碼:飛創建,但無法正常工作
$productId = (int) $this->getRequest()->getParam('id');
$discountprice=$_POST['product']['discountprice'];
$model = Mage::getModel('salesrule/rule');
$couponCode=generateUniqueId(8);
$model->setName($couponCode);
$model->setCouponCode($couponCode);
$model->setDescription('Discount coupon for Surger.');
$model->setUsesPerCoupon(1);
$model->setUsesPerCustomer(1);
$model->setCustomerGroupIds('0,1');
$model->setIsActive(1);
// $model->setConditionsSerialized('a:6:{s:4:\"type\";s:32:\"salesrule/rule_condition_combine\";s:9:\"attribute\";N;s:8:\"operator\";N;s:5:\"value\";s:1:\"1\";s:18:\"is_value_processed\";N;s:10:\"aggregator\";s:3:\"all\";}');
//$model->setActionsSerialized('a:6:{s:4:\"type\";s:40:\"salesrule/rule_condition_product_combine\";s:9:\"attribute\";N;s:8:\"operator\";N;s:5:\"value\";s:1:\"1\";s:18:\"is_value_processed\";N;s:10:\"aggregator\";s:3:\"all\";}');
$model->setStopRulesProcessing(0);
$model->setIsAdvanced(1);
$model->setProductIds($productId);
$model->setSortOrder(1);
$model->setSimpleAction('by_percent');
$model->setDiscountAmount($discountprice);
$model->setDiscountStep(0);
$model->setSimpleFreeShipping(0);
$model->setTimesUsed(0);
$model->setIsRss(0);
$model->setWebsiteIds('1');
$model->save();
但是當我結帳特定產品的折扣自動應用,我的要求是折扣必須在我在折扣碼框中輸入代碼後申請,同樣當我在折扣碼中輸入代碼時,它顯示代碼無效...
請幫助任何人。我也在盡力解決這個問題。如果我找到任何解決方案,我會放在這裏。
小記:$模型 - > setUsesPerCoupon(1)在代碼中增加了一倍。 – Alekc 2013-01-11 09:42:09