[英]How to use cart total to change cart items prices in WooCommerce
[英]How do I change $cart_total to an actual number?
我正在將mercadopago(巴西版的paypal)集成到我現有的購物車中,該購物車當前已結帳,並且有人進行銀行存款。
除unit_price是一個固定數字外,其他一切似乎都不錯。
$preference_data = array(
"items" => array(
array(
"title" => "Shirt",
"quantity" => 1,
"currency_id" => "BRL",
"unit_price" => "10.00"
)
)
);
我試過說"unit_price" => "$cart_total"
但返回錯誤,說unit_price
必須是數字。 有沒有辦法解決?
我已經奇跡般地開發了自己的網站並擁有一個.php購物車,但我在這方面並不完全了解! 非常感謝! 對這個簡單的問題很抱歉,我找不到答案,因為我不知道如何正確地表達它。 我嘗試尋找“將php字符串轉換為整數”,但返回的結果並不適用...
只是在設置unit_price
時不要使用引號。 至於quantity
編號,而不是:
"unit_price" => "10.00"
做:
"unit_price" => 10.00
閱讀有關PHP類型的更多信息: http : //php.net/manual/en/language.types.php
嘗試-
"unit_price" => (float)$cart_total,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.