Site logo

Archived topic

Problema con plugin

18 replies · Started by Pedro on June 11, 2021

Viewing posts 1–15 of 19

Hola,

Acabo de instalar el plugin "WooCommerce Show Single Variations" de IconicWP.

Enlace del plugin: https://iconicwp.com/products/woocommerce-show-single-variations/

Y veo que cuando ya he configurado todo, al momento de ver cada variación de producto en el listado de productos, cuando hago hover en la imagen, no cambia.

(Estoy usando la función de GP para que se muestre la imagen secundaria del producto al hacer hover)

Me puse en contacto con los desarrolladores del plugin, ya que pensé que el problema era de ellos.

Esta fue la respuesta que me dieron:

Hi Pedro,

It looks like that your theme feature to show secondary image, only working for post type "product" please note that the post type of the variation is "product_variation".

For this, I would like to ask if you can contact Generate Press support and if they can have a look at this issue as well. Could you please ask them if their feature also supports and working with the "product_variation" post type. If they need anything from our end, let us know as we are happy to further assist you with this.

Let us know how it goes and if you need further assistance.

Hi there,

That's correct - we specifically check for the "product" post type.

You can add it manually for this specific post type if you'd like:

add_action( 'woocommerce_before_shop_loop_item_title', function() {
    $post_type = get_post_type( get_the_ID() );

    if ( 'product_variation' === $post_type && method_exists( 'WC_Product', 'get_gallery_image_ids' ) ) {
        $product = wc_get_product( get_the_ID() );
        $attachment_ids = $product->get_gallery_image_ids();

        if ( $attachment_ids && generatepress_wc_get_setting( 'product_secondary_image' ) && generatepress_wc_get_setting( 'product_archive_image' ) && has_post_thumbnail() ) {
            $secondary_image_id = $attachment_ids['0'];
            echo wp_get_attachment_image( $secondary_image_id, 'shop_catalog', '', $attr = array( 'class' => 'secondary-image attachment-shop-catalog' ) );
        }
    }
} );

Keep an eye on our GP Premium updates, as it looks like that post type check may not be necessary. If we remove it, you'll want to remove this function when you update to prevent the image from being added twice.

Hola Tom,

Gracias por responder.

He añadido el código al functions.php del tema pero no ocurrió nada.

Al hacer hover no cambia a la imagen secundaria.

Y sí, ya borre caché.

Por otro lado, uso este otro plugin para que cada variación tenga sus propias imágenes: https://woocommerce.com/products/woocommerce-additional-variation-images/

¿Tendrá algo que ver?

It may, but it's difficult to know for sure without digging into the functionality of that plugin. Can you link me to an example page where the hover image should be showing up with the function I shared active?

Let me know :)

Hola Tom, gracias por responder.

En este enlace puedes ver algunos productos que deberían cambiar la imagen al hacer hover:

https://raybasics.co/camisetas/

Estaré atento a cualquier novedad.

¡Gracias!

All of the products on that page seem to be the product post type. Can you confirm that the secondary image feature is turned on in the Customizer? Also, do the products have multiple images associated with them?

Hola Tom,

La función de "Mostrar imagen secundaria al pasar el ratón" está activada.

Con respecto al producto, es uno solo con variaciones de color.

Este es el enlace del producto original: https://raybasics.co/camisetas/camiseta-basica-cuello-redondo/

Lo que hice, fue ocultar el producto original del listado, y mostrar las variaciones de color con el plugin que mencioné antes.

Este es el plugin: https://iconicwp.com/products/woocommerce-show-single-variations/

Adicionalmente, a cada variación le agregué imágenes secundarias, con este plugin: https://woocommerce.com/products/woocommerce-additional-variation-images/

Ah, that could be the issue. How feature looks for the gallery of images:

$product = wc_get_product( get_the_ID() );
$attachment_ids = $product->get_gallery_image_ids();

It sounds like the images are being added differently here. You may need to ask that plugin developer how to get a list of the variation images so we can tweak the function above to include them.

Hola Tom,

He probado desactivando el plugin "WooCommerce Additional Variation Images", lo que debería solucionar el problema.

También he activado nuevamente el producto original en el listado. Con el cual funciona correctamente la opción de mostrar la imagen secundaria al hacer hover.

Ahora me doy cuenta que ese plugin no es el problema. Ya que a pesar que se muestran las variaciones del producto, deberían mostrar la imagen secundaria del producto principal al hacer hover.

¿No es así?

Por favor revisa nuevamente con los cambios: https://raybasics.co/camisetas/

Strange, it's working with the first one but not the others. What are the differences between the first and second product? Anything?

Hola Tom,

La diferencia es que el primer producto es el producto original / principal.

Los demás productos que aparecen, son variaciones del producto principal, que coloqué usando este plugin:

https://iconicwp.com/products/woocommerce-show-single-variations/

PD: Si revisas el URL de los productos variables podrás ver que es el mismo producto principal, con filtros de los atributos como talla y color.

Aha, I see. It's becoming clearer!

Ok, so does each variation have more than one image for it? If so, we need to know how to get those images for each variation using PHP. If there's a function we can use to fetch the images, we can then write a function to include the secondary image for those products.

This archived topic is closed to new replies.