VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Eden on May 25, 2013, 13:42:08 PM

Title: SOLVED: Custom Attrib/Childs to Change Weight of Product- Working in Cart
Post by: Eden on May 25, 2013, 13:42:08 PM
**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.

-----------------------------------
            SOLUTION:
-----------------------------------

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.*

Steps:
--------
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: http://forum.virtuemart.net/index.php?topic=103067.msg360263#msg360263 (http://forum.virtuemart.net/index.php?topic=103067.msg360263#msg360263)

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)



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]
Title: Re: SOLVED: Custom Attrib/Childs to Change Weight of Product- Working in Cart
Post by: leeburstroghm on August 10, 2013, 02:43:11 AM
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?
Title: Re: SOLVED: Custom Attrib/Childs to Change Weight of Product- Working in Cart
Post by: tuki on October 10, 2013, 20:27:50 PM
Working attributes with working stock control

http://awebsupport.com/vm2-set-up-child-product-with-stock-control

Demo: http://awebsupport.com/virtuemart-child-product-with-stock-control/productdetails/5
Title: Re: SOLVED: Custom Attrib/Childs to Change Weight of Product- Working in Cart
Post by: omarcixs on October 22, 2013, 18:11:09 PM
You helped me very much Thank you.