• Resolved tlouwet

    (@tlouwet)


    I’m trying to list products that for example have a color = black variation, with the first gallery image being shown of that variation.

    Got it all working, except I don’t have a clue how to request the first image of that variation.

    Is there something like function getImages($variation, $product_id) ?

    Been trying to look through the plugin, but no success sadly (reason I’m asking here).

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author David Rosendo

    (@drosendo)

    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

    Thread Starter tlouwet

    (@tlouwet)

    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.

    Plugin Author David Rosendo

    (@drosendo)

    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

    Thread Starter tlouwet

    (@tlouwet)

    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!

    Plugin Author David Rosendo

    (@drosendo)

    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

    Thread Starter tlouwet

    (@tlouwet)

    @drosendo Sweet thanks!

    Plugin Author David Rosendo

    (@drosendo)

    No problem.

    Please take the time to review my plugin when possible.

    Cheers,
    David

    Thread Starter tlouwet

    (@tlouwet)

    Already done ??

    Keep up the sweet work.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘First gallery Image request of a variation’ is closed to new replies.