• Resolved apg1912

    (@apg1912)


    I’m still relatively new to using woocommerce and wordpress and am trying to find my way around it.

    I have used the ‘Products by Tag’ block to display a grid of products with the selected tag. What I would like to do is add a small image to products that contain certain words in their short description.

    I’m not asking how to do this, but I’d appreciate any pointers to what woocommerce php files or action hooks I should be looking at to help me achieve this.

    I did it for the normal shop pages by adding code to the woocommerce_template_loop_product_link_open() function, but that obviously doesn’t work for a custom page such as this.

    What I’m looking for is the code that generates the html to display the products.

    I shall carry on looking, but any pointers would be appreciated.

    thanks

    • This topic was modified 3 years, 10 months ago by apg1912.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter apg1912

    (@apg1912)

    The code that displays the products in the grid is at:

    woocommerce / packages / woocommerce-blocks / src / BlockTypes / AbstractProductGrid.php

    There are no actions in this file. I found where the code would go to achieve what I want to do, but it would involve editing this file. I presume that’s not advised because it is likely to be updated in the future. Is there another option I haven’t considered?

    • This reply was modified 3 years, 10 months ago by apg1912.

    Hi @apg1912,

    In this case, you might want to take a look at using the product shortcode instead of the block.

    https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-9

    That way you can customize it with PHP directly and still create the grid of products.

    Just a thought ??

    Hi @apg1912,

    Hopefully, you were able to clear up this issue. Since it’s been a while since we last heard from you, I’m going to mark this thread resolved.

    If you still have trouble, please feel free to open up a new topic. We’d be happy to jump back in and help you out.

    Cheers

    Thread Starter apg1912

    (@apg1912)

    Yes, this can be closed now. Thanks for the shortcode idea. I like the look of that as well and so will give it a try.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customising Products by Tag block?’ is closed to new replies.