I want to replace the stock quantity on the single product page with "5+", if the stock quantity is more than 5, else display the original quantity.
I tried to modify the hook as below
add_filter( 'woocommerce_product_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
add_filter( 'woocommerce_product_variation_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
function custom_get_stock_quantity( $value, $_product ) {
global $product;
if($_product->get_stock_quantity() > 5){
return "5+";
}
else{
return $_product->get_stock_quantity();
}
}
This gives me 502 server error. What could be the issue here?