Support » Plugin: WooCommerce Quick/Bulk Order Form » Add on stock

  • Resolved Viapositiva

    (@viapositiva)


    It would be great if there was a possibility to display “On stock” with extra field. Thank you in advance for the support.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! We’re releasing an update next week that will make this possible via a filter. I’ll follow up here as soon as the update is released!

    Plugin Contributor Ewout

    (@pomegranate)

    Hi! As promised, a follow up now that 3.1.1 is released. You can use the following filter to include “In stock” text in the search for products that are in stock:

    
    add_filter( 'wc_bulk_order_form_label','wc_bulk_order_form_label_stock', 10, 6 );
    function wc_bulk_order_form_label_stock( $label, $price, $title, $sku, $active_currency, $product = null ) {
    	if ( $product && $product->managing_stock() ) {
    		if ( $product->get_stock_quantity() > 0 ) {
    			$label = sprintf( "%s - %s", $label, __( 'In stock', 'woocommerce' ) );
    		}
    	} else {
    		$label = sprintf( "%s - %s", $label, __( 'In stock', 'woocommerce' ) );		
    	}
    	return $label;
    }
    

    Or a more advanced version that prints the amount that is in stock:

    
    add_filter( 'wc_bulk_order_form_label','wc_bulk_order_form_label_stock', 10, 6 );
    function wc_bulk_order_form_label_stock( $label, $price, $title, $sku, $active_currency, $product = null ) {
    	if ( $product && $product->managing_stock() ) {
    		$stock_amount = $product->get_stock_quantity();
    		$display = sprintf( __( '%s in stock', 'woocommerce' ), wc_format_stock_quantity_for_display( $stock_amount, $product ) );
    		$label .= " ({$display})";
    	}
    	return $label;
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add on stock’ is closed to new replies.