English (United Kingdom)Russian (CIS)
Dynamic change of price in VirtueMart product card at selection of its attributes (Virtuemart Price Calculator) PDF Print E-mail
Wednesday, 11 May 2011
It often happens that price for a product changes depending on its attributes, for example, size or weight. A customer chooses the type of product he needs, selects the appropriate parameters, adds the product to the cart. During this in the program vitruemart the product price on the page differs from the one in the cart. This confuses the customers.

Let’s review the situation on an example. Let’s suppose that we have an online shop of jewelry. The product is a golden ring with diamonds that costs 20452 roubles. We choose the size 16 – other 4 thousands roubles are added, 750 standard – other 2 thousands, then add the product to the cart and the price is 27952 roubles. The price on the page is former.

We offer to make such a change of virtuemart price so that the changes can be immediately viewed on product’s page. The total final cost in this case will be shown yet at page’s loading, if the current feature is not null. Also we won’t make any changes to the code of the online shop, we’ll limit ourselves with an is js file.

So the result should be (base price is 21 952,00 roubles):

Golden ring with diamonds

Golden ring with diamonds

Price for 1 item (items): 21 952,00 roubles
Golden ring with diamonds, rose gold, 14-carat. The ring is adorned with 3 diamonds each 0,36 carat, characteristics not less than 4/5. Average weight of the ring is 4,70 grams.
:
:







The simplest code of script that changes the price will look like:

 
<script type="text/javascript">
//@author: http://bigemot.ru
window.addEvent('domready', function() {
  var vmStr= $('vmMainPage').getElement('.productPrice'); 
  var Box=$$('.vmAttribChildDetail select');
  var vmPrice= vmStr.innerHTML; 
  sumBox();
  Box.addEvent('change', function() {
    sumBox();
    });
 
  function strNum(x) {
     var r = ""; 
    for(var n=0; n<x.length; n++) {
      var base= x.charAt(n);
      if (base!=' '&&isNaN(base)==false||base==',')
      r = r + base;
    }
    return parseFloat(r.replace(/,/g,"."));
  }
  function strPrice(x) {
    x = x.toString();
    var y = x.charAt(0);
    for(var n=1; n<x.length; n++) {
      if (Math.ceil((x.length-n)/3) == (x.length-n)/3) y = y + " ";
      y = y + x.charAt(n);
    }
     return y; 
  }
  function adPrice(x) {
    var add=x.options[x.selectedIndex].innerHTML;
    var n=add.lastIndexOf("(");
    var operand=add.slice(n+1,n+2);
    return operand+strNum(add.slice(n));
  }
  function sumBox() {
    var price=strNum(vmPrice);
    for(var n=0; n<Box.length; n++) {
      price=eval(price+adPrice(Box[n]));
    }
    vmStr.innerHTML=vmPrice.replace(strPrice(strNum(vmPrice)), strPrice(price));
  }
});
</script>
 


Now when we choose size 16 of the ring with standard 750, we immediately see the change of price virtuemart – 27952 roubles.

Of course, before applying the script in a shop, it should be improved. At least it’s necessary to consider several details, in particular, work at absence of extra cost or at its assignment (=20 000,00 roubles), consider discounts on a product etc. Most of these points have been already considered when developing the plug-in VM DynamicPrice (plug_VirtueMart_dynamic_price).

Plug-in is offered on commercial base.

It may be purchased using the section "Contacts". Its cost is $28. Or download it:


Download plug-in VM DynamicPrice (28 WMZ):




What do you get for this price?
  • You do not need to know js and php, which would make the script on your site, everything is already working,
  • Plug-in is installed as an average Joomla plug-in. No changes (hacks) are made to VirtueMart code. In the settings you may mark the plug-in scope, i.e. it may be loaded only on the page with the product and not loaded on other pages,
  • It’s possible to switch dynamic price change at increase (diminution) of the quantity of the selected products, not only at attributes change,
  • It’s possible to hide the extra cost (+2000,00 roubles), what is mentioned in parentheses becomes not important any more,
  • If the shop uses the crossed out price, it also changes,
  • If a product is assigned a discount, all the calculations are performed considering it,
  • VM DynamicPrice also works on category’s page, but special discounts will not be considered there,
  • Plug-in works correctly if extra cost is not indicated for product’s option in attribute, and if the product price is assigned (=20 000,00 roubles),
  • Plug-in doesn’t force the work of cart functions and other VirtueMart functions, it works with all shop versions and Joomla 1.5. It’s made according to principle “once installed everything works".


Settings:



More articles:



 

Comments 

 
0 #1 Othello 2012-02-15 16:06
How to buy through PayPal?

Here you can buy a credit card.
http://juice-lab.ru/en/dev/plugins/14-vmdynamicprice
Quote
 
 
-3 #2 francishift 2012-10-03 21:36
Hello, ¿work this plgin in virtuemart 2.0 and joomla 2.5?
Quote
 
 
-2 #3 Administrator 2012-10-03 21:51
Quoting francishift:
Hello, ¿work this plgin in virtuemart 2.0 and joomla 2.5?


VM1 & J1.5 only
Quote
 
 
0 #4 michele 2013-09-03 00:06
are you going to implement it for joomla 2.5 and virtuemart 2?
Quote
 
 
0 #5 Administrator 2013-09-03 12:35
Quoting michele:
are you going to implement it for joomla 2.5 and virtuemart 2?

I have not worked actively with VM2. But, if I'm not mistaken, there is already integrated this functionality natively. Tell me if I'm wrong.
Quote
 
 
0 #6 temp 2016-02-17 17:12
unfortunately there is not.
Quote
 
 
0 #7 TESSA 2016-08-31 13:43
mine is a Virtuemart 3.0.0. will it work?
Quote
 
 
0 #8 TESSA 2016-08-31 13:44
in case it does not...how to proceed with my Joomla 3.2.0 and VM 3 ?
Quote
 
 
-1 #9 Administrator 2016-08-31 14:08
Quoting TESSA:
in case it does not...how to proceed with my Joomla 3.2.0 and VM 3 ?

this is an old plugin. 2011. It's for VM1 & J1.5 only
Quote
 
 
0 #10 TESSA 2016-08-31 19:13
how to export all the prices and reimport them in virtuemart 3.0.0
Quote