• Resolved joel

    (@joel2019)


    Hi,
    Previously we were using YITH’s Remy theme.
    There, we had the option to show a notification when there was only 1 item left in stock.
    How do we activate this on Proteo theme?

    Cheers,
    Joel

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author YITHEMES

    (@yithemes)

    Hi there,
    I’m sorry, Proteo theme don’t have this feature. But is quite simple to achieve with a bit of custom code, that I’m going to provide you ??

    PHP code for your child theme functions.php file:

    add_filter( 'body_class', 'yith_proteo_customization_custom_outofstock_body_class' );
    
    /**
     * Add body class if the product is only 1 on stock
     *
     * @param array $classes the body class array.
     * @return array
     */
    function yith_proteo_customization_custom_outofstock_body_class( $classes ) {
    
    	global $post;
    	if ( 'product' !== $post->post_type ) {
    		return $classes;
    	}
    	$product = wc_get_product( $post->ID );
    	if ( $product->get_stock_quantity() <= 1 ) {
    		$classes[] = 'low-stock-product';
    	}
    	return $classes;
    }

    You can change the minimum stock level to whatever you need (I’m using 1 now)

    CSS code for your Additional CSS:

    body.low-stock-product .stock {
        background: red;
        display: inline-block;
        padding: 5px 10px;
        color: #ffffff;
    }

    This will add a red background to the stock quantity level.

    I hope you will appreciate this ??

    Thread Starter joel

    (@joel2019)

    Perfect! Thans a bunch! ??

    Theme Author YITHEMES

    (@yithemes)

    Most welcome ??
    If you like Proteo, our help and the work we are doing, help us with a nice review on this theme!

    I’m setting this topic as solved, don’t hesitate to open a new one if you need further help with your site ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘stock notification – 1 item left’ is closed to new replies.