Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Stock/Out of stock/Backorder messages

$
0
0

Replies: 0

Hello,

For our website we wanted to change the stock messages, I have found some pieces of code that could edit those but we had a problem with them.

add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
    
    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('Op voorraad', 'woocommerce');
    }
    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('Niet op voorraad', 'woocommerce');
    }
    return $availability;
}

/* backorder text on single product page */
 
function so_42345940_backorder_message( $text, $product ){
  if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) {
      $text = __( 'Please allow 20 days for delivery of this item', 'your-textdomain' );
  }
  return $text;
}
add_filter( 'woocommerce_get_availability_text', 'so_42345940_backorder_message', 10, 2 );

This the code that I am using now, the only problem with this are the backorder products. They are now displayed as in stock products, which is not the case 😉

Can someone help me out with this?


Viewing all articles
Browse latest Browse all 59525

Trending Articles