Hello,
I dont understand what you are trying to do but all data is store in get_post_meta woosvi_slug or you can add_filter for svi_gallery_images.
does it help?
Cheers,
David
Hi @drosendo
Yeah was wayyy late at night, I could have phrased it better.
Is there a way to call upon the gallery of a product’s variation, outside of the product page?
Lets say I have a product that has a few variations, attribute_pa_color orange blue and black, but I want to get the gallery of just the black one, is there a function I can use to get those?
Thanks for the quick reply.
Hey,
Use the get_post_meta of the product ID you want to fetch the information from and filter out the data you need.
Therw is no direct call to just get that specific variation. You get all the SVI data for the product.
The data is well organized I believe it will be simple to interpret.
Does it help?
Cheers,
David
Oh the meta of the main product.
Retrieved from an example:
a:2:{i:0;a:2:{s:5:"slugs";a:1:{i:0;s:6:"orange";}s:4:"imgs";a:1:{i:0;s:4:"2811";}}i:1;a:2:{s:5:"slugs";a:1:{i:0;s:5:"black";}s:4:"imgs";a:1:{i:0;s:4:"2814";}}}
Where I see 2814 as the image id for “black”.
Sadly I’m not accustomed to this format.
Got this to echo the wanted image:
$meta_variations = get_post_meta($product->get_id(),'woosvi_slug')[0];
foreach ($meta_variations as $variation) {
if ($variation['slugs'] == ['black']) {
echo wp_get_attachment_image($variation['imgs'][0]);
}
}
Would this be the correct way to do it?
And really appreciate the help!
Your example is a serielized data you have to unserielize it.
But yes, you can than cycle it until you find what you want.
Cheers,
David
No problem.
Please take the time to review my plugin when possible.
Cheers,
David