MoreConvert Documentation

How to Display Price Changes in the Wishlist Table?

In this comprehensive guide on how to display price changes in your Wishlist Table, you’ll discover the essential need for showcasing price changes. Understanding and visualizing price adjustments directly in the Wishlist Table is crucial for users seeking a dynamic and informed shopping experience.

The provided code snippet allows you to customize the display of prices in your Wishlist Table. By applying this filter, you can enhance the presentation of price information for products in your wishlist. Let’s break down the code and provide additional explanations.


How to Display Price Changes in the Wishlist Table: #

To Display Price Changes in the Wishlist Table, follow these steps:

  • Access your WordPress theme’s directory.
  • Locate the functions.php file.
  • Insert the following code snippet into the functions.php file:

    add_filter( 'wlfmc_item_formatted_price', 'wlfmc_separate_product_price', 10, 4 );
    * Change display price format.
    * @param string $formatted_price formatted price.
    * @param string $base_price base price.
    * @param WC_Product $product product object.
    * @param WLFMC_Wishlist_Item $item wlfmc wishlist item.
    * @return string
    function wlfmc_separate_product_price( $formatted_price, $base_price, $product, $item ) {
    $base_price = $product->is_type( 'variable' ) ? $product->get_variation_regular_price( 'max' ) : $product->get_price();
    $meta = $item->get_product_meta( 'view' );
    if ( is_array( $meta ) && isset( $meta['attributes'] ) ) {
    unset( $meta['attributes'] );
    if ( empty( $meta ) ) {
    $formatted_price = $base_price ? $product->get_price_html() : ( '0' === $base_price ? apply_filters( 'wlfmc_free_text', esc_html__( 'Free!', 'wc-wlfmc-wishlist' ), $product ) : '' );
    } else {
    $base_price = $item->get_product_price( 'edit' );
    $formatted_price = $base_price ? wc_price( $item->get_product_price( 'view' ) ) : ( '0' === $base_price ? apply_filters( 'wlfmc_free_text', esc_html__( 'Free!', 'wc-wlfmc-wishlist' ), $product ) : '' );
    return $formatted_price;

  • Save the functions.php file.


Result #

Here you can see the result for this feature:

How to Display Price Changes in the Wishlist Table?
Display Price Changes in the Wishlist Table


Explanation #

The function wlfmc_separate_product_price takes four parameters:

  • $formatted_price: The original formatted price.
  • $base_price: The base price of the product.
  • $product: The WooCommerce product object.
  • $item: The Wishlist item object.


This function then customizes the formatted price based on the type of product (variable or not) and the presence of additional meta data in the Wishlist item. The resulting formatted price is then returned for display in the Wishlist Table.

Feel free to integrate this code into your WooCommerce setup to enhance the presentation of prices within your wishlist feature. You can also Display SKU in Wishlist Table using this tutorial.

What are your feelings?
Updated on November 15, 2023