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 );

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