[英]Echo price of product in virtuemart cart
I use joomla 2.5 and virtuemart 2. I tried to echo a script that is built from php. 我使用的是joomla 2.5和Constancemart2。我试图回显从php构建的脚本。 So inside cart file inside foreach function that goes through each product I need to save to a variable product id, quantity and sales price. 因此,在遍历每种产品的foreach函数中的购物车文件中,我需要保存为可变的产品ID,数量和销售价格。
I can show product id and quantity like this: 我可以显示产品ID和数量,如下所示:
$wantedproductid = $product->virtuemart_product_id;
$wantedproductquantity = $product->quantity;
but I have a problem with price. 但我对价格有疑问。 I echoed $this
and I get this: 我回应了$this
,我得到了:
VirtueMartCart Object
(
[products] => Array
(
[812] => stdClass Object
(
[virtuemart_manufacturer_id] => 11
[slug] => hill-s-puppy-healthy-development-large-breed-koutavia-anaptyksi-kotopoulo-11kg
[published] => 1
...
...
[pricesUnformatted] => Array
(
[basePrice] => 70.6
[basePriceWithTax] => 0
[discountedPriceWithoutTax] => 60.31
[salesPrice] => 60.31
[taxAmount] => 0
[salesPriceWithDiscount] => 60.31
[discountAmount] => 57.4
[priceWithoutTax] => 70.6
[subTotalProducts] => 0
[2Diff] => -9.585
[812] => Array
(
[costPrice] => 63.90000
[basePrice] => 63.9
[basePriceVariant] => 63.9
[basePriceWithTax] => 0
[discountedPriceWithoutTax] => 54.32
[priceBeforeTax] => 63.9
[salesPrice] => 54.32
[taxAmount] => 0
[salesPriceWithDiscount] => 54.32
[salesPriceTemp] => 54.32
[unitPrice] => 0
[discountAmount] => 14.99
[priceWithoutTax] => 63.9
[variantModification] => 0
...
...
What I need is for example this value: [salesPrice] => 54.32
我需要的是例如这个值: [salesPrice] => 54.32
How can I save [salesPrice]
in a value? 如何保存[salesPrice]
值?
这应该可以解决问题:
echo $this->pricesUnformatted['salesPrice']
This is wrong, that did't work not the answer nor the comment below the answer. 这是错误的,这对答案或答案下方的评论均无效。 This works: 这有效:
echo $this->cart->pricesUnformatted[$wantedproductid]['salesPrice'];
but it shows sales price only of the last product of the cart not for each product. 但它仅显示购物车最后一个产品的销售价格,而不是每个产品的销售价格。 The foreach condition works fine foreach条件正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.