Forum
perch_shop_product_variants() - display variants as individual products
Hi Drew,
I see that perch_shop_product_variants()
has been added in 1.0.9.
Does this make it possible to display variants in a list as if they were individual products?
I tested the function by creating a new product and generating variants for it. The output is just that main product. Are we at the point where we get variants to display as individual products in a product list?
Thanks!
What problem were you seeing with the output?
Looking again, I'm actually not getting anything output with
perch_shop_product_variants
I've tried to pass in some options, nothing.
I'm using the default template, and also added <perch:variants> tags to see if that would make a difference.
I have a product set up and variants generated.
Can you show me the function cal you're using?
<?php perch_shop_product_variants(); ?>
I've also tried passing in the main product id and slugs, as well as:
<?php perch_shop_product_variants('', array('template' => 'products/variant_list.html', 'variants' => true)); ?>
<?php perch_shop_product_variants('Variant-Test-BLK-BLK', array('template' => 'products/variant_list.html', 'variants' => true)); ?>
You need to pass in the product slug:
Okay :) I've got that working now, thank you!
Is there a way to display a list of all variants (cross-product) a la
perch_shop_products
?Not currently. When would that be useful?
I have a shop that has about 30 SKUs (variations) but only 5 "parent" products.
To make the shop look more robust, I'd like to display all of the SKUs in the main product listing.
Currently, I'm achieving this by setting up each SKU/variation as it's own product. Doing this with parent products and variations would be more manageable, especially as the shop expands.
Thanks Drew!
At the moment we filter out variants from product listings (variants are just products with a parent). I think we could probably add an option to include variants. Would you need to be able to exclude parent products when variants exist and not when they don't? That might be a bit more expensive.
:) Excluding parents would definitely be useful! And, yes, probably more important is including parents when variants don't exist.
I could see a simpler "include variants" option working though--maybe set up a parent as the "baseline" variant (i.e. color: black, and then add other colors as variants and display all).
I would also need to configure the detailed product view so that the appropriate info is there and the inappropriate info is not there for the parent vs. variants. At this point I've not had much success getting variants to look like their own products. I see how they are meant to supplement, not replace a product listing. The more I get into variants the less I'm sure about this approach. What do you think?