Skip to content

Hooks for Integrations

Filters for adding support for custom plugins and integrations.

If you use a custom multi-currency solution, you can add support using these filters.

apply_filters( 'wpify_woo_discounts_convert_price', $converted, $price, $from_currency, $to_currency );
ParameterTypeDescription
$convertedfloat|nullConverted price (null = use fallback)
$pricefloatOriginal price
$from_currencystringSource currency
$to_currencystringTarget currency
/**
* Custom currency conversion for a custom plugin
*
* @param float|null $converted Converted price
* @param float $price Original price
* @param string $from_currency Source currency
* @param string $to_currency Target currency
*
* @return float|null
*/
function custom_currency_conversion( $converted, $price, $from_currency, $to_currency ) {
// Get exchange rate from a custom plugin
$rate = my_currency_plugin_get_rate( $from_currency, $to_currency );
if ( $rate ) {
return $price * $rate;
}
return $converted; // Fallback to detected plugin
}
add_filter( 'wpify_woo_discounts_convert_price', 'custom_currency_conversion', 10, 4 );
apply_filters( 'wpify_woo_discounts_detect_currency_plugin', $detected );
ParameterTypeDescription
$detectedstring|nullName of the detected plugin
/**
* Register a custom currency plugin
*
* @param string|null $detected Detected plugin
*
* @return string|null
*/
function detect_my_currency_plugin( $detected ) {
if ( function_exists( 'my_currency_plugin_init' ) ) {
return 'my_currency_plugin';
}
return $detected;
}
add_filter( 'wpify_woo_discounts_detect_currency_plugin', 'detect_my_currency_plugin' );

Hooks for custom translation of message and label fields.

apply_filters( 'wpify_woo_discounts_rule_message', $message, $rule );
ParameterTypeDescription
$messagestringDiscount message
$rulearrayRule data
apply_filters( 'wpify_woo_discounts_rule_label', $label, $rule );
ParameterTypeDescription
$labelstringDiscount label
$rulearrayRule data
/**
* Translate message via a custom system
*
* @param string $message Message
* @param array $rule Rule
*
* @return string
*/
function translate_discount_message( $message, $rule ) {
$rule_id = $rule['id'] ?? 0;
$current_lang = my_get_current_language();
// Get translation from a custom table
$translated = my_get_translation( 'discount_message', $rule_id, $current_lang );
return $translated ?: $message;
}
add_filter( 'wpify_woo_discounts_rule_message', 'translate_discount_message', 10, 2 );
add_filter( 'wpify_woo_discounts_rule_label', 'translate_discount_message', 10, 2 );

Universal Cart Manager (UCM) iterates all cart items tagged with DISCOUNTED_PRODUCT_TYPE and recalculates prices on every cart event. External modules that own discount-style cart items (e.g. coupon-driven free gifts) can claim them so UCM does not touch them.

apply_filters( 'wpify_woo_discounts_ucm_skip_item', $skip, $cart_item_key, $cart_item );
ParameterTypeDescription
$skipboolWhether to skip UCM lifecycle for this item. Default false.
$cart_item_keystringWC cart item key.
$cart_itemarrayThe cart item array.

Return true when your module wants exclusive control over an item’s price and lifecycle (you set the price yourself via woocommerce_before_calculate_totals, handle removal yourself, etc.). UCM then ignores the item in change_discounted_prices().

add_filter( 'wpify_woo_discounts_ucm_skip_item', function ( $skip, $key, $item ) {
if ( isset( $item['_my_module_marker'] ) ) {
return true;
}
return $skip;
}, 10, 3 );

This is what the Coupons module uses internally for its Free Gift on Coupon items.


You can add custom functions either in your child theme’s functions.php or using the Code Snippets plugin.