Skip to content

Hooks for UI and Info Blocks

Filters for modifying discount display on product pages and in the cart.

This filter allows you to modify the label (discount name) in the info block.

apply_filters( 'wpify_woo_discounts_info_block_item_label', $label, $rule, $product );
ParameterTypeDescription
$labelstringLabel text (rule name)
$rulearrayArray with rule settings
$productWC_ProductCurrent product
/**
* Add emoji to label based on discount type
*
* @param string $label Label text
* @param array $rule Rule
* @param WC_Product $product Product
*
* @return string
*/
function add_emoji_to_label( $label, $rule, $product ): string {
$emoji = match ( $rule['rule_type'] ?? '' ) {
'bulk' => '📦 ',
'bundle' => '🎁 ',
'free_gift' => '🎀 ',
'buy_x_get_x' => '🔥 ',
default => '💰 ',
};
return $emoji . $label;
}
add_filter( 'wpify_woo_discounts_info_block_item_label', 'add_emoji_to_label', 10, 3 );

This filter allows you to modify the info block content (message and countdown) on the product page.

apply_filters( 'wpify_woo_discounts_info_block_item_content', $content, $rule, $product );
ParameterTypeDescription
$contentstringHTML content (message + countdown)
$rulearrayArray with rule settings
$productWC_ProductCurrent product
/**
* Add free shipping information to the info block
*
* @param string $content HTML content
* @param array $rule Rule
* @param WC_Product $product Product
*
* @return string
*/
function add_free_shipping_info( $content, $rule, $product ): string {
$content .= '<p class="free-shipping-note">+ free shipping on orders over $50</p>';
return $content;
}
add_filter( 'wpify_woo_discounts_info_block_item_content', 'add_free_shipping_info', 10, 3 );
/**
* Add badge based on discount type
*
* @param string $content HTML content
* @param array $rule Rule
* @param WC_Product $product Product
*
* @return string
*/
function add_discount_badge( $content, $rule, $product ): string {
$badge = '';
switch ( $rule['rule_type'] ?? '' ) {
case 'bulk':
$badge = '<span class="discount-badge bulk">Volume Discount</span>';
break;
case 'bundle':
$badge = '<span class="discount-badge bundle">Bundle Discount</span>';
break;
case 'buy_x_get_x':
case 'buy_x_get_y':
$badge = '<span class="discount-badge bogo">BOGO Deal</span>';
break;
}
return $badge . $content;
}
add_filter( 'wpify_woo_discounts_info_block_item_content', 'add_discount_badge', 10, 3 );

This filter allows you to modify the HTML output of the pricing table (for bulk/bundle discounts).

apply_filters( 'wpify_woo_discounts_info_block_item_pricing', $html, $rule, $product );
ParameterTypeDescription
$htmlstringPricing table HTML
$rulearrayRule settings (since v1.0.2 contains only valid subrules)
$productWC_ProductCurrent product
/**
* Add a custom header above the pricing table
*
* @param string $html Table HTML
* @param array $rule Rule
* @param WC_Product $product Product
*
* @return string
*/
function add_pricing_table_header( $html, $rule, $product ): string {
$header = '<h4 class="pricing-table-title">The more you buy, the more you save!</h4>';
return $header . $html;
}
add_filter( 'wpify_woo_discounts_info_block_item_pricing', 'add_pricing_table_header', 10, 3 );
/**
* Hide pricing table for products in the "clearance" category
*
* @param string $html Table HTML
* @param array $rule Rule
* @param WC_Product $product Product
*
* @return string
*/
function hide_pricing_for_clearance( $html, $rule, $product ): string {
if ( has_term( 'vyprodej', 'product_cat', $product->get_id() ) ) {
return ''; // Hide table
}
return $html;
}
add_filter( 'wpify_woo_discounts_info_block_item_pricing', 'hide_pricing_for_clearance', 10, 3 );

This filter allows you to modify the complete arguments for the info block template.

apply_filters( 'wpify_woo_discounts_info_block_args', $args, $product );
ParameterTypeDescription
$argsarrayTemplate arguments
$productWC_ProductCurrent product
$args = array(
'items' => array(
array(
'label' => '...', // Label text (rule name)
'content' => '...', // HTML content (message + countdown)
'pricing' => '...', // Pricing table HTML
'rule' => array(), // Rule data
),
// more items...
),
'classes' => array(
'block' => array( 'wpify-woo-discount-info-block' ),
'item' => array( 'wpify-woo-discount-info-block__item' ),
'label' => array( 'wpify-woo-discount-info-block__label' ),
'content' => array( 'wpify-woo-discount-info-block__content' ),
'pricing' => array( 'wpify-woo-discount-info-block__pricing' ),
),
'product' => WC_Product,
);
/**
* Add a custom CSS class to the info block
*
* @param array $args Template arguments
* @param WC_Product $product Product
*
* @return array
*/
function add_custom_class_to_info_block( $args, $product ): array {
$args['classes']['block'][] = 'my-custom-discount-block';
// Add class based on product category
if ( has_term( 'premium', 'product_cat', $product->get_id() ) ) {
$args['classes']['block'][] = 'premium-product-discount';
}
return $args;
}
add_filter( 'wpify_woo_discounts_info_block_args', 'add_custom_class_to_info_block', 10, 2 );
/**
* Sort info block items by rule priority
*
* @param array $args Template arguments
* @param WC_Product $product Product
*
* @return array
*/
function sort_info_block_items( $args, $product ): array {
usort( $args['items'], function( $a, $b ) {
$priority_a = $a['rule']['priority'] ?? 10;
$priority_b = $b['rule']['priority'] ?? 10;
return $priority_a - $priority_b;
} );
return $args;
}
add_filter( 'wpify_woo_discounts_info_block_args', 'sort_info_block_items', 10, 2 );

Limiting the Number of Displayed Discounts

Section titled “Limiting the Number of Displayed Discounts”
/**
* Display a maximum of 2 discounts on the product page
*
* @param array $args Template arguments
* @param WC_Product $product Product
*
* @return array
*/
function limit_displayed_discounts( $args, $product ): array {
if ( count( $args['items'] ) > 2 ) {
$args['items'] = array_slice( $args['items'], 0, 2 );
}
return $args;
}
add_filter( 'wpify_woo_discounts_info_block_args', 'limit_displayed_discounts', 10, 2 );

The $rule parameter in UI filters is now a rule settings array, previously it was a subrule array. If you use these filters, verify compatibility.


Filters for modifying product badges.

This filter allows you to modify the list of badges for a product.

apply_filters( 'wpify_woo_discounts_product_badges', $badges, $product );
ParameterTypeDescription
$badgesarrayArray of badges for the product
$productWC_ProductCurrent product
/**
* Add a "Bestseller" badge for products with high sales
*
* @param array $badges Array of badges
* @param WC_Product $product Product
*
* @return array
*/
function add_bestseller_badge( $badges, $product ): array {
$total_sales = $product->get_total_sales();
if ( $total_sales > 100 ) {
$badges[] = array(
'type' => 'custom',
'label' => 'Bestseller',
'class' => 'bestseller-badge',
);
}
return $badges;
}
add_filter( 'wpify_woo_discounts_product_badges', 'add_bestseller_badge', 10, 2 );

This filter allows you to modify the resulting badge HTML.

apply_filters( 'wpify_woo_discounts_product_badges_html', $html, $badges, $product );
ParameterTypeDescription
$htmlstringBadge HTML output
$badgesarrayArray of badges
$productWC_ProductCurrent product

This filter allows you to modify the badge text including placeholders.

apply_filters( 'wpify_woo_discounts_badge_text', $result, $replacements, $label, $data );
ParameterTypeDescription
$resultstringResulting text after replacements
$replacementsarrayReplacement array ({discount}, {price}, etc.)
$labelstringOriginal label template
$dataarrayBadge data
/**
* Add a custom {stock} placeholder for stock quantity
*
* @param string $result Resulting text
* @param array $replacements Replacement array
* @param string $label Template
* @param array $data Data
*
* @return string
*/
function add_stock_placeholder( $result, $replacements, $label, $data ): string {
if ( isset( $data['product'] ) && strpos( $label, '{stock}' ) !== false ) {
$stock = $data['product']->get_stock_quantity() ?? 0;
$result = str_replace( '{stock}', $stock, $result );
}
return $result;
}
add_filter( 'wpify_woo_discounts_badge_text', 'add_stock_placeholder', 10, 4 );

This filter allows you to disable automatic badge injection.

apply_filters( 'wpify_woo_discounts_skip_badge_injection', $skip );
ParameterTypeDescription
$skipboolDefault false, return true to skip
/**
* Disable badges on the "clearance" page
*
* @param bool $skip Skip injection
*
* @return bool
*/
function skip_badges_on_clearance( $skip ): bool {
if ( is_page( 'vyprodej' ) ) {
return true;
}
return $skip;
}
add_filter( 'wpify_woo_discounts_skip_badge_injection', 'skip_badges_on_clearance' );

This filter allows you to modify the generated CSS for badges.

apply_filters( 'wpify_woo_discounts_badge_css', $css );
ParameterTypeDescription
$cssstringCSS string

This filter allows you to modify the logic for determining a “new” product.

apply_filters( 'wpify_woo_discounts_is_product_new', $is_new, $product, $days );
ParameterTypeDescription
$is_newboolWhether the product is new (default: published within $days days)
$productWC_ProductProduct
$daysintNumber of days for “new”

This filter allows you to add custom CSS selectors for detecting the product gallery on the product page.

apply_filters( 'wpify_woo_discounts_badge_gallery_selectors', $selectors );
ParameterTypeDescription
$selectorsarrayArray of CSS selectors

Example: Adding a Selector for a Custom Theme

Section titled “Example: Adding a Selector for a Custom Theme”
/**
* Add selector for a custom theme
*
* @param array $selectors CSS selectors
*
* @return array
*/
function add_my_theme_gallery_selector( $selectors ): array {
$selectors[] = '.my-theme-product-gallery';
return $selectors;
}
add_filter( 'wpify_woo_discounts_badge_gallery_selectors', 'add_my_theme_gallery_selector' );

This action fires when the Product Badge module is initialized.

do_action( 'wpify_woo_discounts_product_badge_init', $module );
ParameterTypeDescription
$moduleProductBadgeModuleModule instance

This filter allows you to add a countdown badge from the Countdown module or a custom solution.

apply_filters( 'wpify_woo_discounts_countdown_badge', $badge, $product );
ParameterTypeDescription
$badgearray|nullBadge data (null = do not display)
$productWC_ProductCurrent product
$badge = array(
'type' => 'countdown', // Badge type for CSS class
'text' => '2:30:45', // Text displayed on badge
);
/**
* Add countdown badge for limited-time products
*
* @param array|null $badge Existing badge
* @param WC_Product $product Product
*
* @return array|null
*/
function add_custom_countdown_badge( $badge, $product ): ?array {
$end_date = get_post_meta( $product->get_id(), '_sale_end_date', true );
if ( ! $end_date ) {
return $badge;
}
$remaining = strtotime( $end_date ) - time();
if ( $remaining <= 0 ) {
return $badge;
}
$hours = floor( $remaining / 3600 );
$minutes = floor( ( $remaining % 3600 ) / 60 );
return array(
'type' => 'countdown',
'text' => sprintf( '%d:%02d', $hours, $minutes ),
);
}
add_filter( 'wpify_woo_discounts_countdown_badge', 'add_custom_countdown_badge', 10, 2 );

Filters for modifying the selection block (free gift, BOGO).

This filter allows you to modify the positions where the selection block is displayed.

apply_filters( 'wpify_woo_discounts_selection_hooks', $hooks_map );
ParameterTypeDescription
$hooks_maparrayMap of positions and WooCommerce hooks
/**
* Add a custom position for the selection block
*
* @param array $hooks_map Hooks map
*
* @return array
*/
function add_custom_selection_position( $hooks_map ): array {
$hooks_map['my_custom_position'] = array(
'hook' => 'my_theme_after_cart',
'priority' => 10,
);
return $hooks_map;
}
add_filter( 'wpify_woo_discounts_selection_hooks', 'add_custom_selection_position' );

This filter allows you to modify the data for the selection block template.

apply_filters( 'wpify_woo_discounts_selection_html_data', $data );
ParameterTypeDescription
$dataarrayTemplate data (CSS classes, texts)

This filter allows you to modify the data of an individual item in the selection.

apply_filters( 'wpify_woo_discounts_selection_html_item_data', $item_data, $product, $settings, $hidden_elements );
ParameterTypeDescription
$item_dataarrayItem data (image, name, etc.)
$productWC_ProductProduct
$settingsarrayManual Select group settings
$hidden_elementsarrayList of hidden elements

This filter allows you to modify the price display in the selection block.

apply_filters( 'wpify_woo_discounts_selection_html_item_price_data', $price_data, $product, $rule );
ParameterTypeDescription
$price_dataarrayPrice data (original, discount, final)
$productWC_ProductProduct
$rulearrayRule data

Filters for modifying the progress bar (upsell bar).

This filter allows you to modify the data for a specific upsell bar.

apply_filters( 'wpify_woo_discounts_upsell_bar_data', $data, $bar, $index );
ParameterTypeDescription
$dataarrayBar data (progress, messages, goal)
$bararrayBar settings
$indexintBar index
/**
* Modify message based on current progress
*
* @param array $data Bar data
* @param array $bar Settings
* @param int $index Index
*
* @return array
*/
function custom_upsell_message( $data, $bar, $index ): array {
$progress = $data['progress'] ?? 0;
if ( $progress >= 75 ) {
$data['message'] = 'Almost there! ' . $data['message'];
}
return $data;
}
add_filter( 'wpify_woo_discounts_upsell_bar_data', 'custom_upsell_message', 10, 3 );

This filter allows you to modify the CSS classes of the upsell bar wrapper.

apply_filters( 'wpify_woo_discounts_upsell_bar_wrapper_classes', $classes, $bar, $index );
ParameterTypeDescription
$classesarrayArray of CSS classes
$bararrayBar settings
$indexintBar index

In addition to filters, action hooks are available for adding custom content.

This action fires when rendering selection blocks in the cart.

do_action( 'wpify_woo_discounts_render_selections' );
/**
* Add custom content before selection blocks
*/
function add_content_before_selections(): void {
echo '<div class="my-custom-selection-header">';
echo '<h3>Choose your gift</h3>';
echo '</div>';
}
add_action( 'wpify_woo_discounts_render_selections', 'add_content_before_selections', 5 );

This action fires when rendering an individual item in the selection block.

do_action( 'wpify_woo_discounts_selection_html_item', $product, $rule );
ParameterTypeDescription
$productWC_ProductProduct
$rulearrayRule settings
/**
* Add stock availability information to the item
*
* @param WC_Product $product Product
* @param array $rule Rule
*/
function add_stock_info_to_selection_item( $product, $rule ): void {
$stock = $product->get_stock_quantity();
if ( $stock !== null && $stock < 5 ) {
echo '<span class="low-stock-warning">Only ' . $stock . ' left in stock!</span>';
}
}
add_action( 'wpify_woo_discounts_selection_html_item', 'add_stock_info_to_selection_item', 10, 2 );

Action hooks are available in the info block template for adding custom content.

do_action( 'wpify_woo_discounts_info_block_html_before' );
do_action( 'wpify_woo_discounts_info_block_html_after' );
do_action( 'wpify_woo_discounts_info_block_html_item_before', $item, $product );
do_action( 'wpify_woo_discounts_info_block_html_item_after', $item, $product );
ParameterTypeDescription
$itemarrayItem data (content, pricing, rule)
$productWC_ProductCurrent product
/**
* Add CTA button after info block
*/
function add_cta_after_info_block(): void {
echo '<a href="/akce" class="discount-cta-button">View all deals</a>';
}
add_action( 'wpify_woo_discounts_info_block_html_after', 'add_cta_after_info_block' );
/**
* Add icon before each info block item
*
* @param array $item Item data
* @param WC_Product $product Product
*/
function add_icon_before_info_item( $item, $product ): void {
$rule_type = $item['rule']['rule_type'] ?? '';
$icon = match( $rule_type ) {
'bulk' => '📦',
'bundle' => '🎁',
default => '💰',
};
echo '<span class="discount-icon">' . $icon . '</span>';
}
add_action( 'wpify_woo_discounts_info_block_html_item_before', 'add_icon_before_info_item', 10, 2 );

Action hooks are available in the Savings Summary template for adding custom content.

do_action( 'wpify_woo_discounts_savings_summary_start', $tracking, $total_saved );
do_action( 'wpify_woo_discounts_savings_summary_end', $tracking, $total_saved );
ParameterTypeDescription
$trackingarrayDiscount tracking data
$total_savedfloatTotal saved amount
/**
* Add motivational message before savings summary
*
* @param array $tracking Tracking data
* @param float $total_saved Saved amount
*/
function add_savings_motivation( $tracking, $total_saved ): void {
if ( $total_saved > 500 ) {
echo '<p class="savings-motivation">Great purchase! You saved more than $500!</p>';
}
}
add_action( 'wpify_woo_discounts_savings_summary_start', 'add_savings_motivation', 10, 2 );
/**
* Add link to more deals after savings summary
*
* @param array $tracking Tracking data
* @param float $total_saved Saved amount
*/
function add_more_deals_link( $tracking, $total_saved ): void {
echo '<a href="/akce" class="more-deals-link">View more deals →</a>';
}
add_action( 'wpify_woo_discounts_savings_summary_end', 'add_more_deals_link', 10, 2 );

Filters for modifying inline checkbox offers in cart item rows (Upsell in Cart Item mode).

This filter allows you to modify the upsell item data before template rendering.

apply_filters( 'wpify_woo_discounts_upsell_cart_item_data', $item_data, $product, $rule, $cart_item_key );
ParameterTypeDescription
$item_dataarrayItem data (image, name, price, etc.)
$productWC_ProductTarget product
$rulearrayRule settings
$cart_item_keystringCart item key of the trigger product
/**
* Add "FREE" badge to upsell items with 100% discount
*
* @param array $item_data Item data
* @param WC_Product $product Product
* @param array $rule Rule
* @param string $key Cart item key
*
* @return array
*/
function add_free_badge_to_upsell( $item_data, $product, $rule, $key ): array {
$price_data = $item_data['price_data'] ?? [];
if ( isset( $price_data['discounted_price'] ) && 0.0 === (float) $price_data['discounted_price'] ) {
$item_data['item_title'] = '🎁 ' . $item_data['item_title'];
}
return $item_data;
}
add_filter( 'wpify_woo_discounts_upsell_cart_item_data', 'add_free_badge_to_upsell', 10, 4 );

This filter allows you to modify the price data of an upsell item.

apply_filters( 'wpify_woo_discounts_upsell_cart_item_price_data', $price_data, $product, $rule );
ParameterTypeDescription
$price_dataarrayPrice data (original_price, discounted_price, discount_amount)
$productWC_ProductTarget product
$rulearrayRule settings

This filter allows you to modify the complete HTML output of the upsell checkboxes for a given cart item.

apply_filters( 'wpify_woo_discounts_upsell_cart_item_html', $html, $cart_item, $cart_item_key );
ParameterTypeDescription
$htmlstringComplete HTML of all upsell checkboxes
$cart_itemarrayCart item data of the trigger product
$cart_item_keystringCart item key
/**
* Wrap upsell checkboxes in a custom wrapper
*
* @param string $html Checkbox HTML
* @param array $cart_item Cart item
* @param string $cart_item_key Cart item key
*
* @return string
*/
function wrap_upsell_checkboxes( $html, $cart_item, $cart_item_key ): string {
return '<div class="my-upsell-wrapper">' . $html . '</div>';
}
add_filter( 'wpify_woo_discounts_upsell_cart_item_html', 'wrap_upsell_checkboxes', 10, 3 );

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