con
(@conschneider)
Engineer
Hi there,
I’ve tried incognito browsing in case it’s a cache issue but that didn’t work.
What does your template file use for getting the value? Is it:
$product->get_stock_quantity();
or something else?
Kind regards,
I’m using the default template that comes with WooCommerce, the only change I’ve made is in the database. I did try this too and it still doesn’t display the actual DB value:
Your help is appreciated.
add_filter( 'woocommerce_get_availability_text', 'bbloomer_custom_get_availability_text', 99, 2 );
function bbloomer_custom_get_availability_text( $availability, $product ) {
$stock = $product->get_stock_quantity();
if ( $product->is_in_stock() && $product->managing_stock() ) $availability = __( 'Quantity: ' . $stock, 'woocommerce' );
return $availability;
}
-
This reply was modified 5 years, 10 months ago by
obtenmiweb.
-
This reply was modified 5 years, 10 months ago by
obtenmiweb.
con
(@conschneider)
Engineer
Hi again,
Let’s try:
function cowo_get_my_prod_info(){
global $product; // Get WooCommerce product instance.
$s = $product->get_stock_status(); // run.
$q = $product->get_stock_quantity();
echo('<h5>Stock info:</h5> Stock status: ' . $s . ' and we have: ' . $q . ' units left.<br><br>');
}
add_action( 'woocommerce_single_product_summary', 'cowo_get_my_prod_info' );
Kind regards,
con
(@conschneider)
Engineer
Hi there,
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.
Kind regards,