Skip to content

For Developers

Allows you to modify custom price data before display.

Parameters:

  • $price (array) - Price data containing label, value, type, suffix, etc.

Example:

add_filter( 'wpify_woo_prices_data', function( $price ) {
// Add suffix to all prices
$price['suffix'] .= ' incl. VAT';
return $price;
} );

Controls whether a custom price should be displayed.

Parameters:

  • $display (bool) - Whether to display the price
  • $custom_price (array) - Custom price settings
  • $product (WC_Product) - Product

Example:

add_filter( 'wpify_woo_prices_should_display_price', function( $display, $custom_price, $product ) {
// Don't display custom prices for virtual products
if ( $product->is_virtual() ) {
return false;
}
return $display;
}, 10, 3 );

Filter for WPML multi-currency support. The module automatically applies this filter for correct currency conversion.

Example:

add_filter( 'wcml_raw_price_amount', function( $price ) {
// Custom currency conversion
return $price * get_exchange_rate();
} );

The module uses this WooCommerce filter with priority 999.

Example of adding custom content:

add_filter( 'woocommerce_get_price_html', function( $price, $product ) {
if ( ! is_product() ) {
return $price;
}
// Add badge to discounted products
if ( $product->is_on_sale() ) {
$price = '<span class="sale-badge">SALE</span>' . $price;
}
return $price;
}, 1000, 2 );

In the module settings, you can enter a custom WordPress hook for displaying the custom prices block:

// Example: display below short description
add_action( 'woocommerce_single_product_summary', function() {
do_action( 'my_custom_prices_location' );
}, 25 );

In the module settings, enter: my_custom_prices_location

ClassDescription
.wpify-woo-pricesWrapper block for custom prices
.wpify-woo-prices__priceIndividual custom price
.wpify-woo-prices__price-infoInfo icon (question mark)
.wpify-woo-prices__price-info__textTooltip text
.wpify-woo-prices__regular-price-labelRegular price label
.wpify-woo-prices__badgeBadge label for products not on sale

Custom prices are stored in product post meta.

// Get custom price values
$custom_prices = get_post_meta( $product_id, '_custom_prices', true );
// Structure:
// [
// 'uuid-1234' => 150.00, // For type 'custom'
// 'uuid-5678' => [ // For type 'by_unit'
// 'unit' => 'kg',
// 'quantity' => 0.5
// ]
// ]

To get the lowest price programmatically:

$prices_log_module = wpify_woo_container()->get(
\WpifyWoo\Modules\PricesLog\PricesLogModule::class
);
$lowest_price = $prices_log_module->get_lowest_price( $product_id );
add_action( 'woocommerce_single_product_summary', function() {
global $product;
if ( ! $product->is_on_sale() ) {
return;
}
$prices_log = wpify_woo_container()->get(
\WpifyWoo\Modules\PricesLog\PricesLogModule::class
);
$lowest = $prices_log->get_lowest_price( $product->get_id() );
if ( $lowest ) {
printf(
'<div class="omnibus-notice">%s: %s</div>',
__( 'Lowest price in 30 days', 'my-theme' ),
wc_price( $lowest )
);
}
}, 15 );