• Resolved shawian

    (@shawian)


    We are trying to show these conditions:

    1. In stock, less than 10 available: “Only n Available”
    2. In stock, more than 10 available: “More than 10 Available”
    3. Normally stocked but 0 available (or they order more than available): “Available on Backorder”
    4. Not normally stocked, can be ordered: “Available By Special Order”
    5. Normally stocked, 0 available, not backorderable: “Sold Out”
    6. Normally stocked, 0 available, awaiting supplies: “Arriving Soon”

    With Special Orders, we want the customer to pay a 50% deposit (whereas with all other sales, 100%).

    I can’t find a plugin that will handle these cases. Any help much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • corsonr – a11n

    (@corsonr)

    Automattic Happiness Engineer

    Hi there,

    You’ll need to get the product stock and create conditional statements based on its value, for instance:

    function show_stock() {
    	global $product;
    	
    	if ( $product->get_stock_quantity() ) { // if manage stock is enabled 
    		$product_stock = number_format($product->get_stock_quantity(),0,'','');
    		
    		if ( $product_stock < 10 ) { // less than 10
    			echo '<div class="remaining">Only ' . number_format($product->get_stock_quantity(),0,'','') . ' available</div>';
    		} else if( $product_stock > 10) {
    			echo '<div class="remaining">More than ' . number_format($product->get_stock_quantity(),0,'','') . ' available</div>';
    			// and you keep adding your conditions here...
    		} else {
    			// here you choose the default message if none of the conditions above match.
    		}
    	}
    }
    
    add_action('woocommerce_after_shop_loop_item','show_stock', 10);
    corsonr – a11n

    (@corsonr)

    Automattic Happiness Engineer

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom stock statuses and availability message’ is closed to new replies.