Look at the beginning of the add to cart templates in WooCommerce. At the beginning there is a check to determine whether the product is purchasable. Inside the is_purchasable()
method in the product class is a filter. By default the product is not purchasable if there is no price set at all, but that can be extended to cover products for which the price is set to 0.
function wpa_109409_is_purchasable( $purchasable, $product ){
if( $product->get_price() == 0 )
$purchasable = false;
return $purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'wpa_109409_is_purchasable', 10, 2 );
Related Posts:
- Creating 20,000 Posts or Pages using a .csv file?
- code is working properly in Core PHP but writing coding in WordPress
- CSV syntax for WP All Import upload without ACF
- Creating a CSV with PHP inside the plugin directory
- Can export gallery but can’t import it Wp all import
- best way to upload a large file to wordpress using wp all import
- Creating categories while importing via CSV
- Export to csv adding html to file
- multiple string replace of post’s content for large data
- Products aren’t detected if CSV importer are used
- How can I automatically send an email with an excel file containing submissions for a form rather than an email per submission?
- Issue: CSV file upload works only when “View page source” is done
- Create csv file in plugin
- CSV file header
- How to set an exact search box in tablepress plug-in
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Why does WordPress still not support SFTP?
- Hide wordpress plugins from list
- WordPress plugin from own server
- How to avoid plugin name conflicts from the upgrade notifier?
- How does WordPress Multisite know that a Plugin is installed?
- Is it a bad practice to go directly to the mysql database while developing a plugin?
- Need a WordPress Plugin for Google Analytics, Favicon, Meta Keywords & Description?
- How does WordPress update plugins, without running into permissions issues?
- How to hide fields from my user profiles
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Register Custom Post Type from Plugin
- How to make my plugin theme-independent?
- How can I enqueue a style only when a particular widget is active?
- How should I handle errors within a plugin?
- How to handle the Plugin Version on Update using Tortoise SVN and the worpdress.org Plugin Repository?
- 403 Forbidden – You don’t have permission to access /wp-admin/admin-ajax.php on this server
- How to find installed plugins
- Setting up a multilingual wordpress site
- Automatically adding post and pages to new blog setups
- 500 Internal Server Error when updating htaccess
- Storing Options in a Shortcode
- Add Product Subtitle to Woocommerce Product Page
- How to delete Passwrd Protected posts cookies when a user logged out from the site
- What are wsm tables for?
- How to fix the woocommerce – adaranth.com redirection issue [closed]
- How do I make a child theme I made POST through a 3rd party plugin?
- Adding regex filter to feedwordpress
- w3 total cache and sitemap.xml
- Test if php document executed by WordPress or directly
- How to move the “create new account” higher in woocommerce
- My plugin won’t return anything [closed]
- Get all woocommerce comments/reviews
- WordPress contact form 7 to show the form dropdown menus as like [closed]
- What is generating Similar Posts and Related Posts on my blog?
- custom uploader in the admin area
- How do I add the same contact form to multiple wordpress sites and capture the response in one place or database?
- How to do the simplest possible frontend ajax call from a plugin?
- New bulk action to resend welcome emails
- I receive taxonomy id
- How do we update a custom file upload field with the Advanced Custom Field plugin?
- How to Include Fields in Query String When Making Request of WordPress.org Plugin API?
- Custom plugin – load enqueue only for this plugin
- Where do plugin variables live in the db?
- Function added to hook “new_to_publish” not executing – custom plugin
- Meta slider plugin only works after first refresh – Object has no method ‘flex slider’
- How to display a number of posts based on a Advanced Custom Field (ACF)
- How do I use a custom theme for the WP Maintenance Mode plugin?
- Javascript from Easy-Fancybox place into footer
- How to get Facebook comment plugin in blog? [closed]
- value not set in contact form 7 plugin of wordpress [closed]
- How to translate user added content in a plugin
- How to call php file in theme directory from plugin
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- How do I minify a plugins CSS/JS code?
- Elementor Pro display featured image on section -> style -> image using shortcode
- Error when adding extensions to wordpress version 5.9 with a DIVI install
- Create a pdf from the entries in DB
- I need plugin or method suggestion
- Litespeed brokes my css
- Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /../plugins/rm-payment.php
- Trying to add a new feature in my wordpress website
- How can I implement radio buttons with icons in Contact form 7?
- Having multiple URL structure for wordpress blog
- SEO Site Title appearing in google search despite not being added
- Missing files in enqueue actions causes WordPress to reload
- Adding/ Removing actions for plugins
- Why user profile update creates Additional Capabilities
- Add new post using a page inside the website
- Adding list of Indexes in wordpress document
- API calls on plugin activation or init?
- Get page content by ID (from a plugin)
- how to protect wordpress website
- Unfortunately removed myself as plugin committer
- Plugin won’t activate, fatal error (widget class not found)
- Google analytics not working on WordPress
- Is it possible to recover Deleted users?
- ACF Taxonomy Object term Null [closed]
- Remove on behalf of in wordpress emails?
- Plugin problem. Question is not appearing.
- Embed php code in custom field of a plugin [closed]
- How to make a rest style plugin?
- How to Allow Users to Select Recipients In a WordPress Comment section?
- Product customizing quiz – quiz adding products to the cart
- How to change all the urls of the WordPress site?