VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: VMx on December 04, 2018, 00:24:42 AM

Title: Change weight after changing selection from Custom field
Post by: VMx on December 04, 2018, 00:24:42 AM
I use product with weight information which is than used for shipping calculation. And the product has "2 versions" which user selects by drop down menu (custom field). Now the problem which I have is that if user selects second option I don't want them to pay for shipping, so I need to somehow set weight to 0 for that product when user selects specific value from custom field drop down. Does anyone know how/where to do that? Is it even possible or maybe if not on product page maybe I can check at checkout if product has custom field X, than change weight to 0...
Title: Re: Change weight after changing selection from Custom field
Post by: GJC Web Design on December 04, 2018, 13:59:59 PM
if u use parent/childs ( multivariant) each selection is an ind. product and can have its own weight
Title: Re: Change weight after changing selection from Custom field
Post by: balai on December 04, 2018, 14:13:15 PM
Yes child products is the way.
You can also check the stockable custom fields
https://breakdesigns.net/extensions/stockable-custom-fields
Title: Re: Change weight after changing selection from Custom field
Post by: VMx on December 04, 2018, 14:52:15 PM
Yeah, I could solve this problem with child products, but my shop is very modified and a lot of other things would get broken with that. I must keep those 2 versions on selection box (because a lot of things rely on it - in basket, checkout, administration,...). That's the reason why I am searching for a way to change weight (and I will also need to change tax) for product after user selects another version or at least at checkout.
Title: Re: Change weight after changing selection from Custom field
Post by: balai on December 04, 2018, 16:00:30 PM
I don't think that you can change weight on the fly. This is a database field and called also in the cart and checkout.

Btw. I don't understand what you mean with " must keep those 2 versions on selection box".
You can use "selection box" with child products as well.
Title: Re: Change weight after changing selection from Custom field
Post by: VMx on December 04, 2018, 16:36:15 PM
So the best way than is to modify code for checkout, to check which version is selected and there change information. Or would it maybe be possible to pass parameter to add to cart button to change weight/tax?

By " must keep those 2 versions on selection box" I meant as I wrote- this can not be removed and if I use another drop down what's the point in having 2 drop downs with same selections? :) It would be very confusing for users. The only way I could do this is by hiding current drop down and than later change default (selected) value according to the product/child I am at. But that is same if not more work as to do other changes, and also I am not sure how other things (like bundles) would handle child products,...
Title: Re: Change weight after changing selection from Custom field
Post by: Milbo on December 06, 2018, 00:08:14 AM
Of course there is a way, for example with the customsizeplugin
https://extensions.virtuemart.net/product/products/custom-size-detail

never hack the core, write plugins. There is a trigger for that. You can change anything in the product, also name, or so