以下挂钩函数将允许您购买所有内容:
// Change all products stock statuses to \'instock\'
add_filter( \'woocommerce_product_get_stock_status\', \'filter_get_stock_status_callback\', 10, 2 );
add_filter( \'woocommerce_product_variation_get_stock_status\', \'filter_get_stock_status_callback\', 10, 2 );
function filter_get_stock_status_callback( $stock_status, $product ){
return is_admin() ? $stock_status : \'instock\';
}
// Enable backorders on all products
add_filter( \'woocommerce_product_get_backorders\', \'filter_get_backorders_callback\', 10, 2 );
add_filter( \'woocommerce_product_variation_get_backorders\', \'filter_get_backorders_callback\', 10, 2 );
function filter_get_backorders_callback( $backorders_status, $product ){
return \'yes\'; // Enable without notifications
}
// Remove the stock quantity from displayed stock status
add_filter( \'woocommerce_get_availability_text\', \'filter_get_availability_text_callback\', 10, 2 );
function filter_get_availability_text_callback( $availability_text, $product ){
return __( \'In stock\', \'woocommerce\');
}
代码进入功能。活动子主题(或活动主题)的php文件。已测试并正常工作。