我在下面使用paypal脚本创建付款,我希望某些商品变体可以设置为setDescription();
(如果有),
目前,所有项目都会在下面的脚本中显示相同的描述(变体):
foreach($_SESSION['products'] as $key => $cart_itm) {
$keys = array_keys($cart_itm);
$matches = preg_grep('~^p_alt\-variation\-\d+~i', $keys);
//show variations if any
if(count($matches) > 1) {
foreach($matches as $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 ['产品']);
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
)
)
如果可用,如何将商品变体传递给->setDescription()
?