Shopping cart rule selain bisa dibuat melalui backend, bisa juga dibuat melalui kode. Kode ini hanya bisa diaplikasikan didalam extension.
$rule = Mage::getModel('salesrule/rule'); $customerGroupIds = Mage::getModel('customer/group')->getCollection()->getAllIds(); $kodevoucher = "ONTHROUGH-USD-10K"; $rule->setName('PROMO USD 10K'); $rule->setDescription('onthrough.link promo USD 10K. Dapatkan harga spesial produk dengan nilai tukar USD 10RB.'); $rule->setFromDate("2016-02-01"); $rule->setToDate("2016-05-01"); $rule->setCouponCode($email); $rule->setUsesPerCustomer(0); $rule->setUsesPerCoupon(0); $rule->setCustomerGroupIds($customerGroupIds); $rule->setIsActive(1); $rule->setConditionsSerialized(''); $rule->setActionsSerialized(''); $rule->setIsAdvanced(1); $rule->setProductIds(''); $rule->setSortOrder(5); $rule->setSimpleAction(Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION); $rule->setDiscountAmount('29'); $rule->setDiscountQty(0); $rule->setDiscountStep(0); $rule->setApplyToShipping(0); $rule->setStopRulesProcessing(1); $rule->setIsRss(0); $rule->setWebsiteIds(array(1)); $rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC); $rule->setStoreLabels(array('USD 10K')); $productFoundCondition = Mage::getModel('salesrule/rule_condition_product_found') ->setType('salesrule/rule_condition_product_found') ->setValue(1) // 1 == FOUND ->setAggregator('all'); $rule->getConditions()->addCondition($productFoundCondition); $attributeSetCondition = Mage::getModel('salesrule/rule_condition_product') ->setAggregator('all'); $rule->getActions()->addCondition($attributeSetCondition); $rule->save();
Demikian.
[…] panduan lengkap di kode nya kunjungi Nyingspot Shoping Cart Rule Sumber: […]