无法在Smarty on Prestashop中将两个变量相乘

问题描述 投票:0回答:2

在我的prestashop商店中,我有两个变量per_sqft_priceper_box_price。 per_sqft_price之前使用货币($)签名。我正在尝试打印这两个变量的乘积值。但是它总是打印0。

{assign var = per_sqft_price value = $product.price}
{assign var = per_box_price value = $product.features[0].value}

<meta itemprop="per_sqft_price" content="{$per_sqft_price|replace:'$':''}"/>
{math equation = "x * y" x = $per_sqft_price  y = $per_box_price }

[请帮助我如何解决此问题。在此先感谢

在我的prestashop商店中,我有两个变量per_sqft_price和per_box_price。 per_sqft_price之前使用货币($)签名。我正在尝试打印这两个变量的乘积值。但是...

php prestashop smarty
2个回答
0
投票

使用$product.price_amount而不是$product.price,它会给出没有货币符号的数字价格输出。并且请确保$product.features[0].value也为数字,因为它可能是字符串,可能仅包含文本。另外,您可以将intval用于变量,例如:


0
投票

尝试此代码:

© www.soinside.com 2019 - 2024. All rights reserved.