Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php“售价”至$price_Php_Joomla_Calculator - Fatal编程技术网

php“售价”至$price

php“售价”至$price,php,joomla,calculator,Php,Joomla,Calculator,My Joomla和virtuemart的产品价格salesPrice如下所示: echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices); 现在我需要将salesPrice转换为$customprice,这样我就可以用如下代码计算它: <?php $customprice = ('salesP

My Joomla和virtuemart的产品价格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; 

?>
问题是$customprice='salesPrice';不能给你任何价值

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

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

如果在类别浏览页面中:

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


现在,$customprice会有你可以计算的销售价格。

这个问题似乎离题了,因为它没有显示出之前的研究,也没有显示出对正在解决的问题的最低理解。你实际上没有问任何问题。我们不知道你所说的转换是什么意思。我是php新手,据我所知,“salesPrice”返回的是以前定义的每种产品的价格,我需要在代码中添加自定义折扣,计算所有产品的8%折扣。当我添加像上面这样的代码时,它将返回0,00,结果我看不到在任何地方定义$custompricefinal。。。你希望$customprice='salesPrice'做什么?我想你忘了在那里添加函数名,或者其他什么…谢谢emmanuel第一个函数正是我需要的。很高兴听到这个消息,不客气!