【问题标题】:php 'salesPrice' to $price [closed]php 'salesPrice' 到 $price [关闭]
【发布时间】:2014-08-13 13:22:25
【问题描述】:

我的 Joomla 和 measuremart 的产品价格 salesPrice 如下所示:

echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);

现在我需要将salesPrice 转换为$customprice,这样我就可以用这样的代码计算它:

<?php 

$customprice = ('salesPrice');
$cijenaraw = str_replace(' Kn','',$customprice);
$cijenaraw2 = str_replace('.','',$customprice);
$cijenaraw3 = str_replace(',','.',$cijenaraw2);
$dicscijena = ($cijenaraw3 / 100) * 92;
$novacijena = round($dicscijena, 2);
echo '<p style="margin-top:10px;color: #FF7800;"><strong>*Cijena: '. number_format($custompricefinal, 2, ',', '.') .' HRK</strong></p>';

endif; 

?>

【问题讨论】:

  • 这个问题似乎是题外话,因为它没有显示先前的研究,也没有对正在解决的问题的了解最少
  • 你实际上并没有问什么。我们不知道您所说的“转换”是什么意思。
  • 我是 php 新手,所以据我所知,“salesPrice”返回的是先前定义的每个产品的价格,我需要在代码中添加自定义折扣,以计算所有产品的 8% 折扣。
  • 当我添加上面这样的代码时,它会一直返回 0,00 作为结果
  • 我没有看到$custompricefinal 被定义在任何地方...您希望$customprice = ('salesPrice') 做什么?我想你忘了在那里添加一个函数名,或者什么......

标签: php joomla calculator


【解决方案1】:

问题是$customprice = ('salesPrice');不能给你任何价值。

如果您在产品详细信息页面中使用脚本,则必须添加:

$customprice = $this->product->prices['salesPrice'];

如果是在分类浏览页面:

$customprice = $product->prices['salesPrice'];

现在$customprice 将获得您可以计算的销售价格。

【讨论】:

  • 感谢伊曼纽尔,第一个正是我所需要的。
  • 很高兴听到这个消息,不客气!
猜你喜欢
  • 2013-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-13
  • 2017-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多