[wcj_product_stock_availability]

Display WooCommerce product stock availability

Description

[wcj_product_stock_availability] shortcode displays WooCommerce product stock availability. Shortcode has no required attributes, optional attributes are listed below.

Args

product_id
(optional) The integer ID for a product.

Default: The current product ID, if exists
before
(optional) Text to place before the content. If content is empty this argument is ignored.

Default: None
after
(optional) Text to place after the content. If content is empty this argument is ignored.

Default: None
visibility
(optional) User visibility. Possible values are WordPress user roles (including custom), e.g. administrator, shop_manager, customer, guest etc.

Default: all
location
(optional) Make shortcode results visible only to customers from specific country (by user IP). Value is two letter country code.

Default: all
site_visibility
(optional) Restrict shortcode output to some pages only. Possible values: single, page, archive.

Default: None
wpml_language
(optional) Restrict shortcode output to certain WPML language only. Possible values are two letter language codes. Can be comma separated list.

Default: None
not_wpml_language
(optional) Restrict shortcode output to exclude certain WPML languages. Possible values are two letter language codes. Can be comma separated list.

Default: None

Examples

[wcj_product_stock_availability before="Product availability: "]
Recommended for WooCommerce Product Info module
Accessible through:
  • [wcj_product_stock_availability]
Tested on WooCommerce 3.2.6 and WordPress 4.9.2
Plugin can be downloaded here. If there are any locked fields in the module, you will need to get Booster Plus to unlock them.

Leave a Reply

Comments

4 Comments

  1. Tom January 20, 2018 at 11:05 am #

    Useful feature: give users the option to display the quantity AND/OR phrase “In Stock” or “Out Of Stock”.

    Right now, it outputs a “package deal of “5 in stock”.

    What if I want to show ONLY “In Stock”, but not the quantity?

    Reply to thread

    • Booster Support Team January 21, 2018 at 3:48 pm #

      Hi Tom,

      I’ve made some changes to the plugin. Please download the development version here – https://booster.io/dev/. You will need to uninstall the old plugin version first (don’t worry your saved settings won’t disappear). Now I’ve added new [wcj_product_stock_status] shortcode. You can just use it without any params, or if you need you can also customize the outputted messages:

      [wcj_product_stock_status outofstock="Custom out of stock message" instock="Custom in stock message"]

      P.S. If you are a Booster Plus user – please contact me on tom@booster.io with your order number and I will send you the dev version for Plus.

      P.P.S. If you like Booster, please leave us a rating.

      Best regards,
      Tom

      Booster Support Team
  2. Vane February 1, 2018 at 6:21 pm #

    I have a case when in WC / Product / Inventory both:
    Enable low stock notifications
    and
    Enable out of stock notifications
    are enabled,
    and I also want to show
    “In stock”
    status when it is true (and low stock notification is not)

    Would this work with dev version ( with B Plus 3.3.0 it doesn’t ) ?
    [wcj_product_stock_status instock=”In stock”]
    without overriding the default WC settings?
    ( I have a low stock threshold of 2, so what would be displayed if stock qty is 1 ? )

    BTW I would add this
    ABOVE or BELOW price… 🙂

    Best!

    Reply to thread

    • Vane February 1, 2018 at 6:38 pm #

      Additional info:
      my Stock Display Format set in WC is:
      “Only show qty … when low e.g. “Only 2 left in stock””