• I have a store setup, and was wondering if there is a way to show the stock quantity (for variations, if there are any).
    The link referenced show the message “Hurry, we’re almost out of this one!” below the cart, but does not say how many are left. Also, what is the default threshold for this message, and how can that be changed.
    Additionally, when I enable the Singe Product Shop WP Layout template, that message does not appear anymore.
    Below is another example of a product without variations, and would like to also show the stock available, and control the notice threshold on single prducts.
    https://zappeducation.com/products/black-skull-red-rose-decor-heart-shape-pendant-necklace/

    Thanks!

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

Viewing 1 replies (of 1 total)
  • Plugin Author andrewmrobbins

    (@andrewmrobbins)

    Hey there!

    To customize the text, you can use the product.leftInStockText JavaScript filter. Below is an example code snippet you can use as a starting point.

    wp.hooks.addFilter('product.leftInStockText', 'shopwp', function (defaultText, quantityLeft, productState) {
    return 'Only' + quantityLeft + ' left in stock!'
    })

    You can add this within the “Misc” section of the ShopWP settings.

    The filter gives you access to the quantityLeft variable that will be the current available inventory for the specific variant.

    To control the threshold, you’ll want to adjust the left_in_stock_threshold attribute. The default threshhold is 10. https://docs.wpshop.io/shortcodes/wps_products#left_in_stock_threshold

    You can either set this on a shortcode [wps_products left_in_stock_threshold=”5″] or globally by adding the below PHP to your theme’s functions.php

    add_filter('shopwp_products_default_settings', function($settings) {

    $settings['left_in_stock_threshold'] = 5;

    return $settings;

    });
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.