php - Best Way convert PHP5.4 Array Dereferences To Be PHP5.3 Compatible -
issue
need convert array deference works in php 5.4 version works php 5.3. i'm unable update live site php i'm bit stuck. i'm trying accomplish create coupon code drupal 7 form submitted.
where i've looked:
php syntax dereferencing function result discussion. looks isn't possible @ all. there several solution examples haven't been able convert issue.
5.4 dereferencing valid 5.3 array call similar issue haven't been able figure out way using it.
original works in php 5.4:
$coupon->store_discount_reference = ['und'=>[['target_id'=>"57"]]]; $coupon->store_coupon_exclusive = ['und'=>[['value'=>"0"]]]; $coupon->store_coupon_conditions = ['und' => [ [ 'condition_name'=>'store_coupon_usage_evaluate_usage', 'condition_settings'=> ['max_usage'=>'1'], 'conditions_negative'=>0, 'remove_condition'=>'remove' ], ]];
what have tried
$coupon->store_discount_reference = array('und'=> array('target_id'=>"57")); $coupon->store_coupon_exclusive = array('und'=> array('value'=>"0")); $coupon->store_coupon_conditions = array('und' => array('condition_name'=>'store_coupon_usage_evaluate_usage','condition_settings'=> array('max_usage'=>'1'),'conditions_negative'=>0,'remove_condition'=>'remove'));
full chunk
$coupon = new stdclass(); $coupon->type = "discount_coupon"; $coupon->coupon_id = ''; $coupon->code = $code; $coupon->bulk = false; $coupon->created = ''; $coupon->status = 1; $coupon->uid = 0; $coupon->is_new = true; $coupon->commerce_discount_reference = ['und'=>[['target_id'=>"57"]]]; $coupon->commerce_coupon_exclusive = ['und'=>[['value'=>"0"]]]; $coupon->commerce_coupon_conditions = ['und' => [ [ 'condition_name'=>'commerce_coupon_usage_evaluate_usage', 'condition_settings'=> ['max_usage'=>'1'], 'conditions_negative'=>0, 'remove_condition'=>'remove' ], ]]; commerce_coupon_save($coupon);
you appear missing array level everywhere
$coupon->store_discount_reference = array('und'=> array(array('target_id'=>"57"))); $coupon->store_coupon_exclusive = array('und'=> array( array('value'=>"0"))); $coupon->store_coupon_conditions = array('und' => array( array('condition_name'=>'store_coupon_usage_evaluate_usage', 'condition_settings'=> array('max_usage'=>'1'), 'conditions_negative'=>0, 'remove_condition'=>'remove' ) ) );
Comments
Post a Comment