News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

how to make child image & description load when selected?

Started by dsrpmedia, June 13, 2012, 00:51:21 AM

Previous topic - Next topic

dsrpmedia

Hi

this used to be SOOO easy in vm 1.1, but I`ve been trying for months now to make a (what used to be) simple thing happen.

I want to have a parent product with child products, & when the child is selected then the child product image/description etc loads.

I finally got the stockable variant plugin working (sort of) - but that option only updated the price, not the image or description.

(eg using the sample data, I have the ladder parent with the wooden, plastic & metal children - but when the plastic ladder is selected from the dropdown the image & description of the plastic ladder doesn`t load, etc)

any help would be greatly appreciated

Parsimonious

You need to use the generic child variant for this. It seems to need to be set to cart attribute to show up, which if I recall correctly they didn't do in the sample data which made it confusing. I think it was used with one of the saws if you want to take a look.

dsrpmedia

looking at the circular saw (the one you were referring to?)

these are not actually child products
also - there is no option that I can see for adding variant specific images & descriptions

no ability to add a sku, no way to track stock.

unfortunatley as far as I can tell not really useful at all - but thanks for the suggestion

Parsimonious

#3
Sorry I should have included explanation. They just didn't set it up well, but it does work.

Create a custom field generic child variant. The title will be what shows up on the front end beside the dropdown. set cart attribute to yes. put ontop in the layout position field.

Create a parent product. Choose a category and add some descriptions. Go to the custom fields tab and under custom fields type choose the custom field you just created.
There should now be a dropdown menu under "value" with options like product name, product sku, etc. Choose product sku then hit save.
Now go to the product description tab and click add a child product. Click it more than once if you need multiple children.
You can now change the product child name - this is what will be in the dropdown, and what will be at the top of the product description (not a perfect setup because most people want a short clean dropdown option and a longer more descriptive title, but that's the way it is)
You can also enter a price and sku for each child.

Hit save & close and you will see you have a parent and seperate children. You can go into each child and add their own descriptions if you like.

Add images to your parent first, then add images to your children. Now if you look at your front end you should have a dropdown menu with your parent and all the children.
When you choose a child the page should refresh and the new info be displayed. Your page url will change too,
I suggest adding images to the parent first because it seems a bit buggy when you try to delete or rearrange the images for the parent your children lose their images (hopefully they're working on that)

You can pretty much customize the children as much as you want - dif description, availability, price, images. Anything you don't change will just display the parents settings.

I think that's it. Hope it help. It took me forever to figure out how to set it up. There are no clear instructions anywhere I could find.

EDIT: Forgot to mention that it's often best to use save & close then come back in the product. Especially right after your create the children. If you just hit save they "disappear" from the parent description tab. You just have to leave the product and come back in to see they are actually still there.

dsrpmedia

thank you for your beautifully clear instructions - I`ll give it a go this evening

athenken

I have tried following your steps here, but I am getting lost.  Basically I have these crosses that are available with different colored marbles placed in their centers.  I want to create a drop down list of the different colors to choose from.

I created a custom field for one of the colors with the "generic child variant" option.  From there I get stuck.  How do I get this setup?

dsrpmedia

Thank you very much!
I was able to get it working with unique images & descriptions for the child products.
This is definately the most functional I`ve gotten vm2 so far. (still missing some basic functionality of vm1.1, but getting closer)

QuoteI have tried following your steps here, but I am getting lost.  Basically I have these crosses that are available with different colored marbles placed in their centers.  I want to create a drop down list of the different colors to choose from.

I created a custom field for one of the colors with the "generic child variant" option.  From there I get stuck.  How do I get this setup?

you have to be sure that you are choosing the generic cart variant in step 1, then follow the instructions very carefully.
* existing children are`nt  loaded when the new cart variant is added - you have to create a new product   ( which I find weird, hopefully there won `t be problems importing products via csv).

a couple things I would wish for:

being able to make the parent basically a landing page with only the children orderable (like you used to be able to do in VM 1.1 by simply putting the parent price to 0.0)

being able to keep track of stock would be nice too

dsrpmedia

correction

the children do show in the existing parent/child sample data - just not in the way I expected
- and the existing pricing is ignored in the product details page - it has to be set on the custom fields page

dsrpmedia

Here`s a link to a page with everything working (unique images, descriptions for child images)
http://vm20b.fyica.com/index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=3&virtuemart_product_id=18

***note I also used a hack to show the price of the child product in the dropdown

go to administrator/components/com_virtuemart/models/customfields.php

change lines 762 - 764
foreach($uncatChildren as $k => $child){
$options[] = array( 'value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='.$virtuemart_category_id.'&virtuemart_product_id='.$child['virtuemart_product_id']) ,'text' =>$child['product_name']);
}


to

// function to get the price for child products
if (!function_exists("getChildPrice")) {
function getChildPrice($child) {
$db = JFactory::getDBO();
$db->setQuery('SELECT  `product_price` FROM `#__virtuemart_product_prices` WHERE virtuemart_product_id='.$child);
return $db->loadObject();
}
}
// end function to get the price for child products
foreach($uncatChildren as $k => $child){
$childprice = getChildPrice($child['virtuemart_product_id']); // get the price for child products
$childprice = rtrim($childprice->product_price, "000");
$options[] = array( 'value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='.$virtuemart_category_id.'&virtuemart_product_id='.$child['virtuemart_product_id']) ,'text' =>$child['product_name']." [$".$childprice."]");
}


now the only thing I need to figure out is how to have a parent with no price / add to cart which displays the dropdown to order the child products

kiscompany

Hello, I apply this code and it works brilliant. Thank you .

I have a question: My child product prices looks like this:

Au$ 13.4 instead of Au$ 13.40
Au$ 28.5 instead of Au$ 28.50
Au$ 17.85 - this is correct

The parent prices has 2 decimals and are correct.

Where can I change this? I want my child prices to show 2 decimals.

Thank you in advance.