在virtmart购物车中回收产品的价格

时间:2016-06-11 10:16:30

标签: php joomla virtuemart

我使用joomla 2.5和virtuemart 2.我试图回显一个用php构建的脚本。 因此,通过每个产品的foreach功能内的购物车文件我需要保存到可变的产品ID,数量和销售价格。

我可以像这样显示产品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]保存在某个值中?

2 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

echo $this->pricesUnformatted['salesPrice']

答案 1 :(得分:0)

这是错误的,这不是答案,也不是答案下面的评论。 这有效:

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

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