嘿伙计我有一个我创建的自定义购物车,将信息传递给Paypal并完成购买。它一切正常,但现在他们想要出售的物品。运费将按单项收取固定费用,但我想知道是否有办法专门通过运输或我只是将其作为另一项添加到购物车? 这是我用来将项目添加到名为items
的数组中的代码foreach($_SESSION['cart']['items'] as $item)
{
$item = array('name'=> $item['description'], 'quantity'=> $item_qty, 'price'=> $item['price'], 'sku'=> $item['category_id']."-".$item['target_id'], 'currency'=>PP_CURRENCY);
array_push($items, $item);
}
然后我打电话给
try{ // try a payment request
//if payment method is paypal
$result = create_paypal_payment($total_amount, PP_CURRENCY, '', $items, RETURN_URL, CANCEL_URL);
//if payment method was PayPal, we need to redirect user to PayPal approval URL
if($result->state == "created" && $result->payer->payment_method == "paypal"){
$_SESSION["payment_id"] = $result->id; //set payment id for later use, we need this to execute payment
header("location: ". $result->links[1]->href); //after success redirect user to approval URL
exit();
}
工作正常,但如何使用此方法添加运费?
我已尝试在Google上搜索一段时间,但我没有提供任何有价值的信息。我也尝试添加到项目阵列' shipping'和' shipping_price'但这只是从Paypal返回404错误。