繁体   English   中英

在opencart php中将数字解析为货币

[英]parse number as currency in opencart php

首先,使用Opencart 1.5.1.3

对于我的一系列产品,我需要创建一个MAP(制造商宣传的定价)定价字段以及一个常规定价字段。 一些制造商只允许我显示他们设置的最低价格,即使我的价格更低,他们也必须将其添加到购物车中。

为了完成这项工作,我使用了数据库中的“位置”字段,然后将地图价格上传到了该位置...

通过使用$ product ['location'](一个数字值)并去除$ product ['price']以显示为数字值,然后使用一系列if语句确定要显示的价格。

我相信我已经追究到了这个问题:由于$ product ['location']不是价格,opencart并没有告诉它处理汇率(在转换货币时),因此我的$ product ['location ']的值没有改变。

我认为可以通过在category.php中编辑以下行来解决此问题,但我不确定该放置什么...

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
               $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
            } else {
               $price = false;
            }

任何帮助,将不胜感激。

链接: https//arkmarine.ca/instruments/autopilots

您将需要将值设置为浮点数,然后将其传递给$ this-> currency-> format方法。 您可以使用值前的(float)类型转换来设置浮点类型

$this->currency->format( (float) $variable);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM