php - add a default value to an array -


i have following code in opencart product.php control file.

$product_option_value_data = array();          foreach ($product_option['product_option_value'] $product_option_value) {             $product_option_value_data[] = array(                 'product_option_value_id' => $product_option_value['product_option_value_id'],                 'option_value_id'         => $product_option_value['option_value_id'],                 'quantity'                => isset ($product_option_value['quantity']) ? $product_option_value['quantity'] : '1',                 'subtract'                => $product_option_value['subtract'],                 'price'                   => isset ($product_option_value['price'])? $product_option_value['price'] : '27.99',                 'price_prefix'            => $product_option_value['price_prefix'],                 'points'                  => $product_option_value['points'],                 'points_prefix'           => $product_option_value['points_prefix'],                                         'weight'                  => $product_option_value['weight'],                 'weight_prefix'           => $product_option_value['weight_prefix']              );         } 

i need add default value quantity, price, subtract. highly appreciated.

you there. have done 2 of elements. add same check subtract one.

$product_option_value_data = array();     foreach ($product_option['product_option_value'] $product_option_value) {         $product_option_value_data[] = array(             'product_option_value_id' => $product_option_value['product_option_value_id'],             'option_value_id'         => $product_option_value['option_value_id'],             'quantity'                =>                     isset ($product_option_value['quantity']) ?                           $product_option_value['quantity'] :                           '1', // default quantity             'subtract'                =>                       isset ($product_option_value['subtract']) ?                             $product_option_value['subtract'] :                            '22', // default subtrack             'price'                   =>                      isset ($product_option_value['price']) ?                             $product_option_value['price'] :                             '27.99', //the default price             'price_prefix'            => $product_option_value['price_prefix'],             'points'                  => $product_option_value['points'],             'points_prefix'           => $product_option_value['points_prefix'],                                     'weight'                  => $product_option_value['weight'],             'weight_prefix'           => $product_option_value['weight_prefix']          );     } 

hope helps


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -