• Hi,
    I would like to use custom images for listed grouped products.
    A solution I have in mind is: add those manually with a hook.

    In woocommerce standard grouped product, i could use
    woocommerce_grouped_product_list_before_price
    Is there a hook I could use that call the same position?

    Alternatively: how could I call a custom-field-image instead of the featured one?

    Thanks

    • This topic was modified 3 years, 5 months ago by glanzi.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Were you able to solve this?

    Thx

    Thread Starter glanzi

    (@glanzi)

    Hi,
    Yes, I did find a solution, it was fairly simple, but I had to figure out the right filter.
    First, I added a custom field for products and called it opt_attachment and set the Return Format to ID.
    Then I used this code:

    add_filter('woosg_item_thumbnail' , 'woosg_item_thumbnail_cb' , 10 ,2);
    function woosg_item_thumbnail_cb($img , $prod ){
        $opt_attachment_id = get_post_meta( $prod->id, 'opt_attachment' , true);
        if($opt_attachment_id != ""){
            $img = wp_get_attachment_image( $opt_attachment_id , 'woocommerce_thumbnail', false, array() );
        }
        return $img;
    }

    That’s it.
    If there is a specific image selected, it will be used, otherwise the default featured image will.

    • This reply was modified 3 years, 1 month ago by glanzi.
    • This reply was modified 3 years, 1 month ago by glanzi.

    This is great.
    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Are there hooks for the grouped products to be called?’ is closed to new replies.