Author Topic: SOLVED: Custom Attrib/Childs to Change Weight of Product- Working in Cart  (Read 4971 times)


  • Beginner
  • *
  • Posts: 14
**If a mod could possibly sticky this, as its a really basic core function of any shopping cart that I have found at least 10 newbie unanswered posts to in this in one night and no simple direct answer!!**

Original Question:
I've been working with Virtue-mart for years now, and have in the last 6 or so months taken to vmart 2.0 on both joomla 2.5 and 3. (Vmart .20b)

Getting down to the point, I've been reading up on many of the changes and am finding 2.0 incredibly confusing in some areas, so I can only imagine how confusing it must be those unfamiliar with virtue-mart.

I simply need to have custom weights on my products, that show in a drop down, these weights will change not only the price of the product, but the shipping/package weight for the shipping module to correctly work out shipping cost.

I've read about child products but cannot get them to operate correctly with weight after following numerous guides. I've looked around for hours trying to work this out only to find numerous unanswered weight related posts, and people also having issues with child's and product weights not being taken into account.


After another hour of hunting and some more trial and error, this is now solved, to assist others, and hopefully save them looking for as long as I did here is the solution, ive written this guide up fairly simply.

My Scenario to assist understanding the solution is as follows:
Vmart 20b, Joomla 2.5.11

*A product of Muscle Gainer comes in either a 600g or 3.1kg variety. This will be one product page, with a single "size" drop down, that will change price, and weight of product without page reload.*

You must first change a core plugin file for the stock variant so that it will properly add child weights and dimensions to the cart.
You can find the details of this change here:

Please note, there is a bug in this code where the word 'product' is mis-spelt 'prfoduct' make sure you fix this error!
I have attached my stockable.php with a .txt extension, you can copy this to: /plugins/vmcustom/stockable/stockable.php
(remember to backup the original and remove the .txt extension)

  • Create the parent product, it contains all the main product details, this is the only product you will see. I added two child products in this area also which can be simply done on the main product edit page.
  • Each of these child products have some basic identifiable attributes, and the correct weight for each product  under "Product Dimensions and Weight" -> "Product Weight" (you will need to go into the actual child product to edit this field)
  • In the 'Custom Field' attributes I added a new custom field of type plugin, I switched "Cart Attribute " to yes, press save/apply, then I chose 'stock variant' down the bottom.
  • Under 'Option Name' i used size.
    Enter each size on a line. Press Save and close.
  • Go back to your parent product, add this new custom field to the custom field tab, tick 'parent attribute' and then enter your price variations (0 for same price as parent, or add a value to add to the parents price for larger sizes)

Done. This should now work, it did for me :)

Final Note: There is a bug with the stock variant where if you add the same variation twice it will at two 1x XYZ products instead of adding a 2x XYZ product to the cart, this is not ideal, and is a current issue I believe devs are working on, I dont have the time to fix this and it works as is so im leaving it.

Hope this helps someone :)

[attachment cleanup by admin]


  • Beginner
  • *
  • Posts: 41
So this applies to child products.. however, is there a solution for not using stock, and jsut adding a weight option to the existing stock variant custom field?
"If you make yourselves sheep, the wolves will eat you." -- Benjamin Franklin
Knowledge is the price for freedom.]


  • Beginner
  • *
  • Posts: 1
You helped me very much Thank you.