Virtuemart Price Doubles When Added To Cart

Virtuemart Fix Pricing Error

My Issue: On my Landscape Photography website I’m using Joomla for the Web Design, I’m trying to sell fine art prints through Virtuemart where I have Custom Fields setup for each print size. Example:

  • 8×10 Print – $85
  • 11×16 Print $120 etc

However, I have to have a base price setup in the product information tab in order to have the Add To Cart Button appear. My issue is, whenever I click on the custom field drop down and select 8×10, the custom field price of $85 get’s added to the original price.

I wanted the custom field price to change the product price and NOT add to it.

Here are our specs of installation as of this posting:

    • Joomla: 2.5.11 – 3.9.x
    • Virtuemart: 2.0.20b – 3.4.2

Here is the fix:

Go to: /administrator/components/com_virtuemart/helpers/calculationh.php

On Line 300 ( On Virtuemart 2.0.20b), Line 376 (VM 3.4.2) Change This code:


if (!empty($variant)) {
$basePriceShopCurrency = $basePriceShopCurrency + doubleval($variant);
$this->productPrices['basePrice'] = $this->productPrices['basePriceVariant'] = $basePriceShopCurrency;
}

Remove: $basePriceShopCurrency + to look like this:


if (!empty($variant)) {
$basePriceShopCurrency = doubleval($variant);
$this->productPrices['basePrice'] = $this->productPrices['basePriceVariant'] = $basePriceShopCurrency;
}

Additional – If you want to update the “+” symbol between the custom field text and price:

Go To: /administrator/com_virtuemart/models/customfields.php

On Line 973  (VM 2.0.20b), Line 907(VM 3.4.2) –

Change:  $price =”+”.$price;

Change the + to whatever you want it to be.

If you need any help with your Joomla or Virtuemart web design project, feel free to reach out. We’d love to help!

I hope that this helps! Please feel free to comment if you have any questions.

2 Comments to “ Virtuemart Price Doubles When Added To Cart”

  1. Mathew Benn says :Reply

    Thanks a million! I was looking in the Virtuemart code forever to find out what was going on with my product pricing and why it was double when I went to checkout. This worked perfectly.

    1. Jason Noel says :Reply

      I’m glad that this helped. It drove me crazy as well.

What are your thoughts? Write a comment below!

Your email address will not be published. Required fields are marked *