VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: vigier on September 15, 2012, 16:34:23 PM

Title: Event triggered when changing dropbox in productdetails/add-to-cart?
Post by: vigier on September 15, 2012, 16:34:23 PM
Hi,

I want to write some code that changes the product-image when changing the dropboxes for the product attributes.
Let's say I have a dropbox for color and one for size. When I select Red and Size L, I want to show the picture of the red shirt and the text "L" in it...

I can see that at least "calculateModificators" in calculationh.php is triggered, but I can't trace back to the original event.
Who knows?

Kind regards, Vigier
Title: Re: Event triggered when changing dropbox in productdetails/add-to-cart?
Post by: vigier on September 15, 2012, 16:48:51 PM
Some additional information: using VM2.0.10 and Joomla 2.5. The "highest" event/function I found is "recalculate" in productdetails.php.
Is this the right place? As in adding another function that is being called in function recalculate?
Title: Re: Event triggered when changing dropbox in productdetails/add-to-cart?
Post by: bytelord on September 17, 2012, 21:26:22 PM
Hello,

If you use child products / variants i think you can accomplish that.
btw, You can find here a good custom field plugin made by PRO. http://forum.virtuemart.net/index.php?topic=99678.0
May be is helpful for making easier custom field variants. After that you can change the images in your child products.

For the size you could use some CSS to place an "L" or "M" image over the product image as you which, you should use some PHP also.
Title: Re: Event triggered when changing dropbox in productdetails/add-to-cart?
Post by: vigier on September 17, 2012, 23:44:43 PM
Hi bytelord,

thnx for your reply. The characters on the image were just an example, I want to reload the image itself.
Downloading PRO's plugin is a good suggestion, maybe looking at his code makes the model more clear to me!

Kind regards, Vigier
Title: Re: Event triggered when changing dropbox in productdetails/add-to-cart?
Post by: bytelord on September 17, 2012, 23:51:38 PM
Hello,

You could use some javascript to fire the event for image changing but there will be an issue with the images itself (where will be stored, filenames, etc). For that reason i suggest you to use child products, for size or colors. You can search the forum to find similar issues with yours (mostly for products with size-color variants) and then try to fix up the images. I have seen some vm users have made color boxes for selecting color for example, without using child products.