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.
<?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.
Now, as plugin is activated so edit the main file and add function to change price display.
<?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 –
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.
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.
function cw_change_product_price_display( $price ) {
$price .= ‘ At Each Item Product’;
return $price;
}
add_filter( ‘woocommerce_get_price_html’, ‘cw_change_product_price_display’ );
add_filter( ‘woocommerce_cart_item_price’, ‘cw_change_product_price_display’ );