简体   繁体   中英

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. 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.

I can show product id and quantity like this:

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

but I have a problem with price. I echoed $this and I get 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

How can I save [salesPrice] in a value?

这应该可以解决问题:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM