View Categories

Add to Cart Button Label Shortcodes Reference

To show dynamic text in the WooCommerce Add to Cart button, type a shortcode such as [alg_wc_atcbl_product_price] into any label field of Change Add to Cart Button Text for WooCommerce at WPFactory > Add to Cart Button Labels. Seven shortcodes are available in the free version, covering title, price, stock, custom fields and language.

This is the full reference for the seven shortcodes the plugin registers. They resolve against the current product, so they are meant for use inside the plugin’s own label fields.

Where you can use them #

Every label field runs shortcodes: the All Products, Per Product Type & Condition, category, tag, user role and user group labels in the settings, and the Single product page and Shop page fields in the Custom Add to Cart Button Labels box on the product edit screen. The label is passed through WordPress do_shortcode() right before the button is printed, on both the single product page and shop and archive pages.

The shortcodes #

Shortcode Outputs
[alg_wc_atcbl_user_name] The logged-in customer’s user nicename (the URL-friendly form of the username). For logged-out visitors it outputs nothing.
[alg_wc_atcbl_product_title] The product title.
[alg_wc_atcbl_product_price] The product’s current price, formatted with your store currency, as plain text.
[alg_wc_atcbl_product_stock] The product’s stock quantity (blank if the product does not manage stock).
[alg_wc_atcbl_product_meta key="..."] A custom field value. Pass the meta key in the key attribute.
[alg_wc_atcbl_product_func name="..."] The return value of a WC_Product method. Pass the method in the name attribute, for example name="get_sku".
[alg_wc_atcbl_translate] Language-specific text on WPML or Polylang sites (see below).

Examples #

  • Add [alg_wc_atcbl_product_title] to cart
  • Buy now for [alg_wc_atcbl_product_price]
  • Buy now, [alg_wc_atcbl_user_name]! (best in a label shown only to logged-in users, such as a Per User Role group)
  • Only [alg_wc_atcbl_product_stock] left, add to cart
  • SKU [alg_wc_atcbl_product_func name="get_sku"]
  • Ships in [alg_wc_atcbl_product_meta key="ship_days"] days, where ship_days is a custom field you added to the product

How to add a shortcode to a label #

  1. Go to WPFactory > Add to Cart Button Labels (also reachable at WooCommerce > Settings > Add to Cart Button Labels).
  2. Open the section you use, for example All Products, and make sure Enable section is ticked.
  3. Type the label with the shortcode in Single product page or Shop page.
  4. Click Save changes and view a product to check the output.

The translate shortcode #

[alg_wc_atcbl_translate] shows different text per language on multilingual sites. It supports two forms:

  • Attribute form: [alg_wc_atcbl_translate lang="EN,DE" lang_text="Text for EN & DE" not_lang_text="Text for other languages"]
  • Enclosing form: [alg_wc_atcbl_translate lang="EN,DE"]Text for EN & DE[/alg_wc_atcbl_translate], paired with [alg_wc_atcbl_translate not_lang="EN,DE"]Text for other languages[/alg_wc_atcbl_translate]

Language codes are case-insensitive and comma-separated. The shortcode reads the current language from the ICL_LANGUAGE_CODE constant, which WPML and Polylang define. Full walkthrough: labels per language with WPML and Polylang.

Note: [alg_wc_atcbl_product_meta] reads a custom field by its exact meta key, not a WooCommerce attribute. If a shortcode has nothing to output (for example no product in context, or an unknown meta key) it returns an empty string.

If a shortcode does not work #

  • The label does not appear at all: the section holding it is not enabled, Enable plugin is off, or a more specific section is overriding it.
  • The value is blank: the product has no value for that field, stock is not managed, the meta key is misspelled, or the name is not a WC_Product method.
  • Translate always shows the “other languages” text: no multilingual plugin defines ICL_LANGUAGE_CODE, or the language code in lang does not match the site’s code.

FAQ #

Why does [alg_wc_atcbl_user_name] show nothing? #

The visitor is not logged in. For guests the shortcode returns an empty value, so use it only in labels that logged-in users see.

Do the shortcodes work in the free version? #

Yes. All seven are registered in the free plugin.

Can I use these shortcodes in a page or post? #

They are built for label fields. They read the current product, so outside a product context they return nothing.

Can I put HTML in a label with a shortcode? #

Settings labels keep basic post HTML. The product edit screen fields are saved as plain text, so HTML tags there are removed.

Get more control #

Shortcodes work in both the free and Pro versions. Change Add to Cart Button Text for WooCommerce Pro adds unlimited category, tag, user role and user groups, plus on-sale labels. See what Pro unlocks. Developers can also see the hooks and filters reference.

Need a hand? Our team answers every ticket on the Add to Cart Button Labels support forum.