【问题标题】:Echo price of product in virtuemart cart德行购物车中产品的回显价格
【发布时间】:2016-06-11 10:16:30
【问题描述】:

我使用joomla 2.5 和mercurymart 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] 保存在一个值中?

【问题讨论】:

    标签: php joomla virtuemart


    【解决方案1】:

    这应该可以解决问题:

    echo $this->pricesUnformatted['salesPrice']
    

    【讨论】:

    • 感谢您的帮助!正确答案:$product->product_price
    【解决方案2】:

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

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

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

    【讨论】:

    • 你是对的。第一个响应不起作用,您的响应有效,但正如您仅对最后一个产品所说的那样。有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 2017-08-07
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多