VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: behemoth on July 10, 2014, 13:25:22 PM

Title: Unusual pricing behaviour
Post by: behemoth on July 10, 2014, 13:25:22 PM
VM2.0.24a

I've got a module on the home page which displays featured products (of which I have two and they change). I want to apply a discount to these products which I've done by adding them to a 'featured item' category and applying a calculation rule on that category. I've now tried to access the discount within the a template override of the mod_virtuemart_product (I'd like to have the flexibility to amend the discount) so I can display it on the product (eg "50% off!").

If I include:
print_r($product->prices);
within the override for each loop, I get inconsistent results. I'll try to explain:

From a clean start with no browser windows open, the discount shows as nothing:


Array
(
    [0] => Array
        (
            [virtuemart_product_price_id] => 72
            [product_price] => 3.32500
            [override] => 0
            [product_override_price] =>
            [product_tax_id] =>
            [product_discount_id] =>
            [product_currency] => 52
            [product_price_publish_up] => 0000-00-00 00:00:00
            [product_price_publish_down] => 0000-00-00 00:00:00
            [price_quantity_start] => 0
            [price_quantity_end] => 0
            [virtuemart_shoppergroup_id] => 0
        )

)

Array
(
    [0] => Array
        (
            [virtuemart_product_price_id] => 237
            [product_price] => 20.82500
            [override] => 0
            [product_override_price] =>
            [product_tax_id] =>
            [product_discount_id] =>
            [product_currency] => 52
            [product_price_publish_up] => 0000-00-00 00:00:00
            [product_price_publish_down] => 0000-00-00 00:00:00
            [price_quantity_start] => 0
            [price_quantity_end] => 0
            [virtuemart_shoppergroup_id] => 0
        )

)


If I browse to one of these featured products and then come back to the homepage, I get this instead (for that product only - the other is as above):


Array
(
    [0] => Array
        (
            [virtuemart_product_price_id] => 237
            [product_price] => 20.82500
            [override] => 0
            [product_override_price] =>
            [product_tax_id] =>
            [product_discount_id] =>
            [product_currency] => 52
            [product_price_publish_up] => 0000-00-00 00:00:00
            [product_price_publish_down] => 0000-00-00 00:00:00
            [price_quantity_start] => 0
            [price_quantity_end] => 0
            [virtuemart_shoppergroup_id] => 0
        )

)

Array
(
    [costPrice] => 3.32500
    [basePrice] => 3.325
    [basePriceVariant] => 3.325
    [basePriceWithTax] => 3.99
    [discountedPriceWithoutTax] => 1.6625
    [priceBeforeTax] => 1.6625
    [salesPrice] => 1.995
    [taxAmount] => 0.3325
    [salesPriceWithDiscount] => 0
    [salesPriceTemp] => 1.995
    [unitPrice] => 0
    [priceWithoutTax] => 1.6625
    [discountAmount] => 1.6625
    [variantModification] => 0
    [DBTax] => Array
        (
            [10] => Array
                (
                    [0] => Featured Products
                    [1] => 50.0000
                    [2] => -%
                    [3] => 0
                    [4] => 52
                    [5] =>
                    [6] => 1
                    [7] => 10
                )

        )

    [Tax] => Array
        (
        )

    [VatTax] => Array
        (
            [1] => Array
                (
                    [0] => UK VAT
                    [1] => 20.0000
                    [2] => +%
                    [3] => 0
                    [4] => 52
                    [5] =>
                    [6] => 1
                    [7] => 1
                )

        )

    [DATax] => Array
        (
        )

)


As you can see, I now have access to the 'Featured Products' discount of 50%.

This discount remains until I close the browser down. It doesn't matter if I browse to the featured item within a new tab or not. It also doesn't work if I browse to any other product - it must be one of these two.

I typically use Firefox, but I've just replicated it in IE10

Can anybody offer any direction on this? Is it a bug? Deliberate? Is there a better way to pick up that discount amount?
Title: Re: Unusual pricing behaviour
Post by: behemoth on July 10, 2014, 15:31:50 PM
Ok, I've gotten round my specific problem by pulling the featured item discount out of the database, but this still seems unusual.