回显virtuemart购物车中产品的价格

Echo price of product in virtuemart cart

我使用 joomla 2.5 和 virtuemart 2。我试图回显从 php 构建的脚本。 因此,在遍历每个产品的 foreach 函数内的购物车文件中,我需要保存到可变的产品 ID、数量和销售价格。

我可以这样显示产品编号和数量:

$wantedproductid = $product->virtuemart_product_id;
$wantedproductquantity = $product->quantity;

但我对价格有疑问。我回应了 $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
                   ...
...

我需要的是例如这个值:[salesPrice] => 54.32

如何保存 [salesPrice] 的值?

这应该可以解决问题:

echo $this->pricesUnformatted['salesPrice']

这是错误的,无论是答案还是答案下方的评论都不起作用。 这有效:

echo $this->cart->pricesUnformatted[$wantedproductid]['salesPrice'];

但它只显示购物车中最后一个产品的销售价格,而不是每个产品的销售价格。 foreach 条件正常