Hello,
I want to updated conditions for an existing shopping cart price rule and am trying to achieve this using setConditionsSerialized like so:
$conditions = 'a:7:{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\";s:10:\"conditions\";a:2:{i:0;a:5:{s:4:\"type\";s:32:\"salesrule\/rule_condition_address\";s:9:\"attribute\";s:13:\"base_subtotal\";s:8:\"operator\";s:2:\">=\";s:5:\"'.$previousPriceLevel.'\";s:2:\"60\";s:18:\"is_value_processed\";b:0;}i:1;a:5:{s:4:\"type\";s:32:\"salesrule\/rule_condition_address\";s:9:\"attribute\";s:15:\"shipping_method\";s:8:\"operator\";s:2:\"==\";s:5:\"value\";s:15:\"'.$shippingMethod.'\";s:18:\"is_value_processed\";b:0;}}}';
$pCoupon = Mage::getModel('salesrule/rule')->load($gid.'level'.$previousPriceLevel.$shipCode, 'name');
$pRule = Mage::getModel('salesrule/rule')->load($pCoupon->getRuleId());
if($pRule->getData())
{
$pRule->setConditionsSerialized($conditions)->save();
//testLog(json_encode($pRule->getData(),128));
}
This method works when I create a coupon from scratch but for existing coupons it just removes the previous conditions. Is there a different method I should be using? Thanks in advance.