This reference covers the shortcodes, notice placeholders and hooks in Conditional Payment Methods for WooCommerce. Shortcodes can be used in text-based condition values and in every Additional notice at WPFactory > Conditional Payment Gateways. All of them work in the free and Pro versions.
Shortcodes #
| Shortcode | Attributes | Returns |
|---|---|---|
[alg_wc_cpg_cart_total] |
exclude_taxes (default yes), exclude_shipping (default no), exclude_discounts (default no) |
The cart total as a number. Used by Cart Total Calculation > Cart total. |
[alg_wc_cpg_user_id] |
None | The current user ID (0 for guests). |
[alg_wc_cpg_if] |
value1, value2, operator, optional then and else |
The enclosed content (or then) when the comparison is true, otherwise else or nothing. |
[alg_wc_cpg_translate] |
lang, not_lang, lang_text, not_lang_text |
Text for the current WPML or Polylang language. |
[alg_wc_cpg_if] operators #
equal, not equal, greater than, less than, greater than or equal, less than or equal, between and between or equal. Underscored forms such as greater_than also work. For the two “between” operators, pass value2 as two comma-separated numbers. Inside attributes, write nested shortcodes with curly braces: {alg_wc_cpg_cart_total} is converted to [alg_wc_cpg_cart_total].
Example: use one date range for the Date/Time condition when the cart is under 1000 and another otherwise.
[alg_wc_cpg_if value1="{alg_wc_cpg_cart_total}" value2="1000" operator="less than" then="00:00:00-14:59:59" else="00:00:00-23:59:59"]
[alg_wc_cpg_translate] examples #
[alg_wc_cpg_translate lang="EN,DE" lang_text="EN and DE text" not_lang_text="Text for other languages"]
[alg_wc_cpg_translate lang="EN,DE"]EN and DE text[/alg_wc_cpg_translate][alg_wc_cpg_translate not_lang="EN,DE"]Text for other languages[/alg_wc_cpg_translate]
Language codes are compared without regard to case.
Where shortcodes are processed #
- Text-based condition values: Date/Time, Customer IP, User, Cart Total and Product Title.
- Every Additional notice text.
- The Cart total calculation field.
Dropdown conditions (roles, countries, currencies, products, terms, languages) take fixed selections and do not process shortcodes.
Notice placeholders #
| Placeholder | Replaced with |
|---|---|
%gateway_title% |
The hidden gateway’s checkout title. |
%value% |
The value you set for the gateway. Formatted as a price for Cart Total. |
%result% |
The rule result. For Cart Total, the current cart total formatted as a price. |
%raw_value%, %raw_result% |
The same values without price formatting. |
%current_raw% |
The customer’s current value for the condition, such as their country code or user ID. |
The admin lists only the placeholders most useful for each condition; the others are replaced in every notice too.
Hooks #
| Hook | Type | Arguments | Use |
|---|---|---|---|
alg_wc_cpg_gateway_settings_{condition_id} |
Filter | $gateway_settings, $rule, $gateway_key, $gateway |
Change the admin field for one gateway in one condition section, for example its options or attributes. {condition_id} is an ID such as country or product_cat. |
alg_wc_cpg_core_loaded |
Action | None | Runs after the plugin core has loaded (whether or not the plugin is enabled). |
The plugin filters gateways on woocommerce_available_payment_gateways at priority PHP_INT_MAX, so it runs after other plugins that use the same filter.
Example: limit the Country dropdown to a few countries #
add_filter( 'alg_wc_cpg_gateway_settings_country', function ( $settings, $rule, $gateway_key, $gateway ) {
$allowed = array( 'US', 'CA', 'GB' );
$settings['options'] = array_intersect_key( $settings['options'], array_flip( $allowed ) );
return $settings;
}, 10, 4 );
Options #
Settings are stored as regular WordPress options prefixed with alg_wc_cpg_. Per-gateway values are arrays keyed by gateway ID, for example alg_wc_cpg_country_incl. The full list is in the settings reference.
Need a hand? Our team answers every ticket on the Conditional Payment Methods support forum.