• Resolved Saqib Saeed

    (@saqibsaeed)


    Hello,

    I am using WooCommerce only for payment. But I am using WooCommerce products but not add to cart functionality. I have two questions.
    1. Can you please provide a hook by which I can enable cache on Shop page and Product Detail page only?
    2. Can you please provide a hook by which I can disable add to cart button on entire site.

    Your help in this regard will greatly be appreciated.
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello @saqibsaeed ,

    Thanks for reaching out.

    1. I am not fully clear about the query actually. Are you trying to remove caching from all other pages except the shop and product details page? Here is an article that can help you with this – How to Stop Caching Breaking Your WooCommerce Website?
    In case, you want to know more about available cookies see – WooCommerce Cookies

    2. You should be able to disable the cart functionality using this hook in your theme’s functions.php file –

    add_filter( 'woocommerce_is_purchasable', '__return_false' );

    You will find more examples here – Make Products Non-Purchasable

    I hope this information helps you.

    Thank you ??

    Thread Starter Saqib Saeed

    (@saqibsaeed)

    Rashed thank you for quick response.
    I am using WP Rocket. I want to cache my shop page and product detail page but per WooCommerce Docs it says “All WooCommerce pages are automatically detected and not cached”. How can I force enable cache on Product detail and shop page?

    Per WP Rocket Docs, It says “Most caching plugins for WordPress use a de facto standard to exclude pages from being cached: the constant DONOTCACHEPAGE. If defined as true during a request, WP Rocket would not cache the page in question, but allow a regular database request to WordPress.

    So here is my question: How can I enable cache on WC product and shop pages only?

    Thanks

    Hello @saqibsaeed ,

    Okay, thanks for the explanation.

    I am afraid I do not have the exact WP Rocket configuration details to sepcifically enable cache on WooCommerce pages. I will recommend that you contact the WP Rocket team via support ticket to get the exact information.

    Thank you ??

    Thread Starter Saqib Saeed

    (@saqibsaeed)

    Rashed,
    Thank you for your response. I contact WP Rocket and they said WooCommerce disables cache on it’s own pages. All I am looking for is a hook or filter by which I can enable cache on Product detail pages?

    Thanks

    Hello @saqibsaeed ,

    I have discussed this with other team members and it seems there is a misunderstanding.

    WooCommerce only tries to disable cache on the cart, checkout, and my-account pages to avoid issues. All other pages, like the product, shop archive pages are cachable and most of the caching plugin supports this.

    I will recommend reaching out to WP Rocket to get a proper suggestion regarding how you can enable cache for those WooCommerce pages.

    Thank you ??

    Hi there,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WooCommerce hook to enable cache on product pages only’ is closed to new replies.