Remove Add To Cart for Products In Specific Categories by Users Length of Registration Period

The PHP code in this downloadable folder enables you to remove the add to cart button for products in 1 or more categories using WooCommerce based on the length of as users registration period.

In summary, the code removes the add to cart button when :

  • The user has been registered less than 30 days or any amount of time you specify in days.
  • The product has been assigned to a specific category or array of categories set by term id in the code.

Demo Video

Code Installation

Copy and paste both code snippets to the end of your child themes functions.php file.

Code Settings

  1. Set your category slugs on line 19. You can use one or more comma separated category slugs.
  2. Set the number of days since user registration on line 21 and 39.
  3. Set your message to displayed when the user has been registered less than the amount of days and the product is in the set category.

Usage With Other Taxonomy Terms

You can also use this code with product tags or any other default WordPress or custom taxonomy terms.

Modify the parameters in the code with your taxonomy name and type:

For product tags use product_tag like this :

has_term( 'discount', 'product_tag' )

Where discount is the name of your tag.

Download Folder

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.