1

I am using Shopwise theme. In the category pages, the woocommerce shop loop is being used. The template for each product in the list view is retrieved from content-product.php.

Here's what I added in shopwise/woocommerce/content-product.php:

/**
     * Hook: woocommerce_shop_loop_item_title.
     *
     * @hooked woocommerce_template_loop_product_title - 10
     */
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); // doesn't work for some reason.
    do_action( 'woocommerce_shop_loop_item_title' );

I know that this file is being used as the template, because when I try other modifications (i.e. echo 'this', or commenting out all of the code), I do see an effect. However, when I add the remove_action line, nothing happens.

For now, I'm using CSS to hide the price on list view, but I want to know why the other approach is not working.

6
  • Where are you adding this code? It may be beneficial to wrap this in a plugins_loaded hook
    – Howdy_McGee
    Jan 3 at 18:41
  • @Howdy_McGee It's in my theme's woocommerce/content-product.php. Do you mean something like this? add_action( 'plugins_loaded', 'remove_list_price', 99 ); function remove_list_price() { remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); } I tried that in my functions.php, but it didn't work. Jan 3 at 19:15
  • Maybe move any add_action() calls and callbacks into the themes functions.php instead of inside the template.
    – Howdy_McGee
    Jan 3 at 19:54
  • @Professional_Helper try looking for do_action( 'woocommerce_after_shop_loop_item_title' ); in the template (content-product.php) and then move your remove_action() to above that do_action() instead.
    – Sally CJ
    Jan 4 at 4:23
  • @SallyCJ that's what I originally did. The code you're seeing in my post is exactly that. Jan 4 at 16:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.