![](/img/trans.png)
[英]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.