Last active
October 14, 2016 06:46
-
-
Save MinaPansuriya/6599c704c939850f4a136bd13de1f75a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Title: WooCommerce Display Specific "Out of Stock" Products on Shop Pages | |
* @Author: Mina Pansuriya | |
* @Website: http://minapansuriya.com | |
* Note: For complete tutorial visit: http://minapansuriya.com/woocommerce-display-selected-out-of-stock-products-on-shopcategory-pages/ | |
*/ | |
add_filter( 'woocommerce_product_is_visible', 'pbs_woo_disp_selected_out_of_stock_products', 2, 99 ); | |
function pbs_woo_disp_selected_out_of_stock_products( $visible, $productId ) { | |
// Replace "6838" with your product post ID. If you want to hide multiple no. of out of stock products, | |
// add further product IDs in this if statement comparision. | |
if($productId == 6838) | |
{ | |
// All the product here will be displayed. | |
} | |
else | |
{ | |
$product = new WC_Product($productId); | |
if(!$product->is_in_stock()) | |
{ | |
$visible = false; | |
} | |
} | |
return $visible; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment