PHP PayPal REST API: display item descriptions if applicable -
i have below create payment paypal script, wanted of items variations able set setdescription();
if any,
currently items show same description (variations) below script:
foreach($_session['products'] $key => $cart_itm) { $keys = array_keys($cart_itm); $matches = preg_grep('~^p_alt\-variation\-\d+~i', $keys); //show variations if if(count($matches) > 1) { foreach($matches $matched_key) { $variations[] = $cart_itm[$matched_key]; } } $subtotal = $cart_itm['p_price'] * $cart_itm['p_qty']; $item[$key] = new item(); $item[$key]->setname($cart_itm['p_name']) ->setcurrency(paypal_currency) ->setquantity($cart_itm['p_qty']) ->setdescription(implode(' / ', $variations)) ->setprice($cart_itm['p_price']); $items[] = $item[$key]; $customdata[] = $cart_itm['p_id'].':'.$cart_itm['p_qty']; }
print_r($_session['products']);
array ( [0] => array ( [p_name] => motorbike helmet g88 [p_code] => 2102649 [p_coverimg] => 12-1466446199-wi5qx.png [p_id] => 12 [p_price] => 68.00 [p_alt-variation-1] => blue [p_alt-variation-2] => xl [p_qty] => 1 ) [1] => array ( [p_name] => digital ph meter [p_code] => 14171613 [p_coverimg] => 4-1460428321-i1pny.jpg [p_id] => 4 [p_price] => 31.00 [p_qty] => 2 ) )
how pass items variations ->setdescription()
if available?
Comments
Post a Comment