Site logo

Archived topic

How to disable product-loop on shop-page?

5 replies · Started by Sascha on March 2, 2023

Viewing posts 1–6 of 6

Hi,

I have defined a custom-page "Angebote" as the default shop page, and only want to display products by custom query-loops (or by ninja-tables).

I checked GPP-Customizer and didn't find the relevant option.

Then I added this code-snippet, but does not work:

function remove_woocommerce_shop_loop() {
    remove_action( 'woocommerce_shop_loop', 'woocommerce_output_all_notices', 10 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_output_all_notices', 10 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_breadcrumb', 20 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_template_loop_product_link_open', 10 );
    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
    remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
    remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
    remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 5 );
}

add_action( 'init', 'remove_woocommerce_shop_loop' );

Can you help me hiding or removing the products from the shop page?

Thank you in advance and kind regards,
Sascha

Hi there,

Woocommerce handles that.
In Dashboard > Woocommerce > Settings -> Products, the Shop page option, if that is set then Woo will automatically add the shop loop to that page.
So the simple fix is to NOT set the shop page.

Then you need to change the return to shop url to match that with this snippet:

function return_to_static_shop_page() {
    return 'http://yourdomain.com/your-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'return_to_static_shop_page' );

Thanks for your clarification.

By the way, will it be possible to display products-fields via GB dynamic data in the future? Or do you know of any solution about how to do so?

Hi Sascha,

Product meta should be already retrievable through GB dynamic data.

Just set the source to Post meta, and the field name to_regular_price for instance. That should work.

Hey Fernando, that's great to hear, thanks!

Now, I have tried to find a list or guide about how to display product-meta correctly, any idea about where I find a list of possible meta to add to the custom meta field of a GB-Headline? Like for pricing variants, tax, "sales" badge etc.?

Thank you in advance and kind regards,
Sascha

This archived topic is closed to new replies.