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
- How can I load the css and jquery explicitly for the login screen
- Overriding an Array in a Plugin’s Class/Function from functions.php
- wp_redirect doen’t work
- Canvas | Bouncing balls within a container (with gravity and collisions and background-images on the balls)
- Plugin translation not working on WordPress.org
- PHP if statement with German umlauts [closed]
- Send email with list of active plugins upon activation/deactivation
- OceanWP settings are missing from Add New Post [closed]
- Built a second plugin but it overwrote the first one
- WordPress gtag.js with User ID tracking
- Creating a functionality plugin to edit seriously simple podcasting
- Override plugin class which has namespace
- in source code but I can’t find it in files or plugins
- Historical customisations won’t go away [closed]
- Is it unethical to remove another plugin’s meta keys?
- Disable plugin If slug contains specific word
- How to include a custom field in the woocommerce email?
- get_comments_number() giving wrong results! What are alternatives?
- Plugin temporary files and files to download via FTP
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- Why does this code snippet create a critical error on my site? [closed]
- What is the purpose of a companion plugin
- woocommerce search by sku and title ajax
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- jQuery Click event is not fired at all
- WordPress: Add custom add_filter for custom functions
- WordPress Site is Broken, Cannot see wp-admin page [closed]
- Is there a script to collect all hooks and filters provided by a plugin?
- How to manipulate the content within wp_head
- Getting error “Warning: mysql_query(): Can’t connect to local MySQL server through socket ‘FILEPATH/cccatalog-plugin.php on line 1656”
- Change in one place the data about the company, which are placed on several pages
- Programatically upload a file to be stored inside blob field in database, NOT on filesystem
- Woocomerce add info after order email prouct item
- Updating WordPress plugin admin panel footer text
- WordPress super admin login issue. (Automatically logout)
- How do I add a plugin dependency to my customized theme?
- WordPress – source link plugin – how to modify it?
- How WordPress core manage the plugin installation
- Flickering sidebar when scrolling page [closed]
- How to add table class for tables of TinyMCE advanced wordpress plugin? [closed]
- All in One SEO Pack error message
- Shortcode not working – quotes seems strange
- Displaying content based on drop-down menu selection sitewide
- How do I make a shortcode to display the shop name on Dokan?
- Background Music WP [closed]
- How to fix broken media library?
- WordPress failing to update plugins
- Image tooltip enable/disable
- Using custom fields for image alt and title
- DB Query not working in Plugin
- Remove Pagination for Product Category Pages WooCommerce
- Is there a plugin or a way in the wordpress that would let us have different versions of a post or page accessibe to users?
- Error trying to update plugins
- Get all the URLs of the pages that uses a specific shortcode
- WordPress permissions error with admin account
- Deactivation Hook does not remove database
- Looking for Gallery Plugin [closed]
- How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?
- Notice: Undefined index: mtral_field_subscriber
- Why is my WordPress Plugin page requesting my FTP Login Credentials?
- Delete free version plugin will also delete premium plugin
- add seperate suffix for low price and high price in woocommerce
- WordPress Editor completely blank [closed]
- Moving FB comments at the end of page
- Change the layout of action links under the plugin names
- Assign all Post in Wp to a specific Category
- How can i add simple code in only in posts by function.php
- Passing Parameters from shortcode to enqueue script
- Get products list by url key in WordPress Woocommerce [closed]
- URL rewrite with external JSON query
- Cross Sells are not being shown in Cart Page. Please Help!
- Possibility to login without password
- How to display registered customer list as dropdown in WooCommerce checkout?
- Using custom php file for ajax url inside plugin
- How do I create a custom permalink structure for a page template
- How do I get the Payzone WooCommerce payment gateway plugin to show up in the settings? [closed]
- simple-job-board Plugin throws an error on live server [closed]
- Where Should i write the code for wordpress ajax voting?
- How to remove a class function from a plugin by using remove_action()?
- Sending HTML email containing custom fields to site users from WordPress
- How to get images using taxonomy ( WP Media Folder)
- Plugin – Admin menu page broken url
- Error with get_price (and others) in self-written plugin to show price
- Hide DIV if empty – Plugin Gallery
- Easy WP SMTP plugin test email failed