Hooks for Integrations
Filters for adding support for custom plugins and integrations.
Custom Currency Conversion
Section titled “Custom Currency Conversion”If you use a custom multi-currency solution, you can add support using these filters.
Price Conversion
Section titled “Price Conversion”apply_filters( 'wpify_woo_discounts_convert_price', $converted, $price, $from_currency, $to_currency );Filter Parameters
Section titled “Filter Parameters”| Parameter | Type | Description |
|---|---|---|
$converted | float|null | Converted price (null = use fallback) |
$price | float | Original price |
$from_currency | string | Source currency |
$to_currency | string | Target currency |
Usage Example
Section titled “Usage Example”/** * 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 );Custom Plugin Detection
Section titled “Custom Plugin Detection”apply_filters( 'wpify_woo_discounts_detect_currency_plugin', $detected );Filter Parameters
Section titled “Filter Parameters”| Parameter | Type | Description |
|---|---|---|
$detected | string|null | Name of the detected plugin |
Usage Example
Section titled “Usage Example”/** * 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' );Text Field Translation
Section titled “Text Field Translation”Hooks for custom translation of message and label fields.
Discount Message Translation
Section titled “Discount Message Translation”apply_filters( 'wpify_woo_discounts_rule_message', $message, $rule );Filter Parameters
Section titled “Filter Parameters”| Parameter | Type | Description |
|---|---|---|
$message | string | Discount message |
$rule | array | Rule data |
Discount Label Translation
Section titled “Discount Label Translation”apply_filters( 'wpify_woo_discounts_rule_label', $label, $rule );Filter Parameters
Section titled “Filter Parameters”| Parameter | Type | Description |
|---|---|---|
$label | string | Discount label |
$rule | array | Rule data |
Example: Custom Translation
Section titled “Example: Custom Translation”/** * 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 );Where to Place the Code
Section titled “Where to Place the Code”You can add custom functions either in your child theme’s functions.php or using the Code Snippets plugin.