Instead of eliminating the loop/add-to-cart.php template all together, why not hook into the price html Woocommerce hooks?
/*
* Remove price HTML if stock is null
*
* Sources:
* http://woocommerce.wp-a2z.org/oik_api/wc_productget_stock_quantity/
*/
add_filter( "woocommerce_get_price_html", "wphelpsanjay_remove_price_if_no_stock", 10, 2 );
add_filter( "woocommerce_variable_price_html", "wphelpsanjay_remove_price_if_no_stock", 10, 2 );
function wphelpsanjay_remove_price_if_no_stock( $price, $product ) {
if ( null === $product->get_stock_quantity()) {
return "";
}
return $price;
}
Related Posts:
- how to use wc_create_order with subscription product
- Is it possible to add custom fields to a WooCommerce attribute term? [closed]
- Add custom variable to cart content [closed]
- WooCommerce changes lost password reset link
- Woocommerce My Account Endpoint – how to get ID parameter from URL?
- Default woocommerce placeholder image
- WooCommerce: Add New Report Tab
- How to add Woocomrce cart page shipping calculator to my country state list
- Custom Woocommerce image size [closed]
- Migrate WooCommerce Orders [closed]
- Button to update order status Woocommerce with WC Marketplace
- WooCommerce Subscriptions: Show monthly Price for annual Product
- WooCommerce: display text instead of raw checkbox value email
- How to add multiple product gallery images from front-end
- WooCommerce single products images doesn’t zoom on hover and doesn’t change clicking on gallery
- Disabling the free shipping method when the cart has product/s which assigned a certain shipping class [closed]
- woocommerce_email_subject_customer_completed_order
- is_shop, is_home, is_front_page doesn’t work for woocommerce
- Woocommerce – Show random product thumbnail from specific product category
- How to add a greeting message upon logging into WordPress for certain user role
- Modify some CSS with functions if (function_exists
- Limit total quantity of products in WooCommerce group product
- How can I change the functionality of breadcrumbs?
- Variation name in $product->get_name()
- WordPress keeps moving my widgets to other widget areas
- Woo-commerce Checkout Summarized in Pop-up Card Entry Only
- How do I add an extra field to comment form above the submit button?
- woocommerce email template detect email recipient
- WooCommerce – buying as well as selling
- how to remove or disable woocommerce order review in checkout page?
- WordPress and WooCommerce – How many products are too many? [closed]
- WooCommerce – Add product with image via REST API
- How to get woocommerce selected variation from order object
- JWT on Woocommerce cannot work with “Customer” role user
- Woocommerce – Add HTML around Product description [closed]
- relocate woocommerce notices/messages on Cart page
- Woocommerce emails from gmail not being sent
- lost password link not working for my site
- How to give each category name its own ACF background color?
- WooCommerce 4: Gallery size is too large in mobile
- How it it possible to disbale all WooCommerce scripts and styles, but keep wc-ajax=get_refreshed_fragments working? [closed]
- Woocommerce cart is not clear after logout
- WooCommerce event works in jQuery but not in JavaScript
- Filter default_content only for products
- Customizing WooCommerce
- Get Post ID from attachment ID (Redirect to product page)
- WooCommerce set a min order price for a single country [closed]
- “Reset my password” links to itself (page refreshes) [closed]
- Woocommerce custom taxonomy filtering
- Woocommerce product tab is not showing probably
- How to list best seller products in woocommerce
- Updating failed. The response is not a valid JSON response. Gutenberg + Woocommerce Products
- Add product image to Woocommerce downloads page
- How to check if woocommerce_order_item_name is use in email?
- Sharing data between filters on a snippet (user specific) for Woocommerce
- How to add custom checkboxes from loop to WooCommerce product variation options?
- Restrict product tags archive to certain users
- Logo showing on some page but not on product categories pages
- Woocommerce doesn’t work with theme, header missing and css messed up
- Woocommerce Product Variation – Add Price Logic
- Display related product categories by subcategory
- Woocommerce Multisite global search how to mod ajax function?
- How to let users create lists of woocommerce products?
- How to force Woocommerce to deliver the product to the paypal adress which was used?
- Order again Woocommerce inside View Order
- Photo cover in WooCommerce
- How to vary WooCommerce product prices based on order dates
- How to save one API response to WooCommerce order meta data
- WooCommerce and ACF: How to Redirect Upon Add to Cart – Partially Working Example
- Woocommerce: Search by custom attribute
- How to fix: “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.” after malware cleaning
- Can’t update WooCommerce payment method title
- Set Post Thumbnail to external URL
- Custom theme woocommerce product detail page template not working
- Increase the download speed of a large number of variations in WooCommerce
- remove add to cart for free (0 $) product woocommerce
- WooCommerce related products load random posts per page
- WooCommerce: Adding a setup fee to certain products
- Removing shipping for one product with coupon
- Awesome Support Custom Field for show Woocommerce orders
- Site with WooCommerce section moved to HTTPS – all pages except home and main store are 404s
- Multiple quantities with options
- How to adjust Related Page Thumb Sizes on single page?
- Adding more than one item to Woocommerce cart
- Woocommerce – get product in category with specific attribute
- Woocommerce make appear when items added to cart
- How do I change the woocommerce product gallery to show all thumbnails instead of three at a time in a carousel?
- How to add a menu page for options in wordpress for user that has the role of vendor?
- Testimonials/Reviews for Products
- add custom menu in woocommerce dashboard [closed]
- WooCommerce: Order Details Table > Add Product Meta
- Override function
- How to disable schema from Wocommerce? [closed]
- Updating order meta to have a meta entry from an item in the order
- Trying query woocommerce product order by menu order and stock status
- editing product page template – getting template for related products not working
- Woocommerce | I want to the button ‘Add to Cart’ on the (all) product-page changed by just ‘open product’ button
- Adding line breaks in WooCommerce order processing emails
- Add second price option based on payment method at cart item price
- Woocommerce backend sorting product drag drop by menu_order to date