Reading list Switch to dark mode

    How To Change The Format Of Price In WooCommerce

    Updated 17 April 2024

    How To Change The Format Of Price In WooCommerce – In this post, we’ll see how we can change or override price format or display in WooCommerce shop. As we know we can do these types of custom changes using filters and actions with proper hook. So, we’ll use hooks provided by WooCommerce for this.

    If you require expert assistance or want to develop custom unique functionality, hire WooCommerce Developers for your project.

    To update price display on shop page, we’ll use hook ‘woocommerce_get_price_html’. Let’s create an example plugin to perform this –
    <?php
    
    /**
     *   Plugin Name: WooCommerce Custom Price Format Change
     *   Description: An example plugin to change price display in WooCommerce Shop
     *   Author: Webkul
     *   Author URI: https://webkul.com
     *   Plugin URI: https://webkul.com
     *   Text Domain: webkul
     */

    And then in admin end, please activate same plugin.

    How To Change The Format Of Price In WooCommerce

    Now, as plugin is activated so edit the main file and add function to change price display.

    Searching for an experienced
    WordPress Company ?
    Find out More
    <?php
    
    /**
     *   Plugin Name: WooCommerce Custom Price Format Change
     *   Description: An example plugin to change price display in WooCommerce Shop
     *   Author: Webkul
     *   Author URI: https://webkul.com
     *   Plugin URI: https://webkul.com
     *   Text Domain: webkul
     */
    
    function wk_change_price_display( $price ) {
      return $price . ' per item';
    }
    
    add_action( 'woocommerce_get_price_html', 'wk_change_price_display' );

    This action will update price in front end by appending ‘per item’ string. Please have a look –

    How To Change The Format Of Price In WooCommerce

    The above hook updates the price display on shop, category search, etc and if you want same changes on cart as well then we need to add same function to one other hook as well named ‘woocommerce_cart_item_price’.

    function wk_change_price_display( $price ) {
      return $price . ' per item';
    }
    
    add_action( 'woocommerce_get_price_html', 'wk_change_price_display' );
    
    add_action( 'woocommerce_cart_item_price', 'wk_change_price_display' );
    

    This will change price display of product in cart page also.

    How To Change The Format Of Price In WooCommerce

    Support

    For any technical assistance kindly raise a ticket or reach us by email at [email protected]. Thanks for Your Time! Have a Good Day!

    Also, discover various solutions to add more features and enhance your online store by visiting the WooCommerce plugins.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    2 comments

  • Alvina
    • Varun Kumar (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content