查看 product.php ( ) 中的 v1.4.9.4,ControllerProductProduct
我可以看到以下代码设置您正在谈论的 $price 的格式化值:
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'],$result['tax_class_id'], $this->config->get('config_tax')));
为什么不将其更改为以下内容...
if ($discount) {
$price_num = $this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'));
$price = $this->currency->format($price_num);
} else {
$price_num = $this->tax->calculate($result['price'],$result['tax_class_id'], $this->config->get('config_tax'));
$price = $this->currency->format($price_num);
然后再往下几行,您可以通过添加以下内容将此 $price_num 值传递给模板:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
...
'price' => $price,
'price_num' => $price_num,
...
应该做你需要的