Ecommerce Shopify WordPress Discussion

Customize Shipping Label from WooCommerce Cart and Checkout Pages

I want to remove the shipping label value in the cart and checkout pages when the value get assigned to shipping. Ex:- Change ' flat rate 100.00$ ' to ' 100.00$ ' . That means i just want the value without label text. Could you please help me to achieve this? I have changed as $rates[$targeted_rate_id]->label = ''; in the shipping_package_rates_filter_callback function. but it is still showing ' : ' (colon symbol) at the start of the value. Ex:- :100.00$ . shipping_package_rates_filter_callback add_filter( 'woocommerce_package_rates', 'shipping_package_rates_filter_callback', 100, 2 ); function shipping_package_rates_filter_callback( $rates, $package ) { // HERE define your targeted rate id $targeted_rate_id = 'flat_rate:4'; if ( ! array_key_exists($targeted_rate_id, $rates) ) return $rates; $new_cost = WC()->session->get('shipping_cost'); // Get new cost from WC sessions if ( ! empty($new_cost) ) { // Set shipping label empty $rates[$targeted_rate_id]->label = ''; $rate = $rates[$targeted_rate_id]; $cost = $rate->cost; // Set the initial cost in a variable for taxes calculations $rates[$targeted_rate_id]->cost = $new_cost; // Set the new cost $has_taxes = false; // Initializing $taxes = array(); // Initializing foreach ($rate->taxes as $key => $tax_cost){ if( $tax_cost > 0 ) { $tax_rate = $tax_cost / $cost; // Get the tax rate conversion $taxes[$key] = $new_cost * $tax_rate; // Set the new tax cost in taxes costs array $has_taxes = true; // There are taxes (set it to true) } } if( $has_taxes ) { $rates[$targeted_rate_id]->taxes = $taxes; // Set taxes costs array } } else { unset($rates[$targeted_rate_id]); } return $rates; }
To remove the colon symbol ": " from a displayed shipping method, use the following code: add_filter( 'woocommerce_cart_shipping_method_full_label', 'display_only_shipping_method_price', 10, 2 ); function display_only_shipping_method_price( $label, $method ) { // HERE define your targeted rate id $targeted_rate_id = 'flat_rate:4'; if ( $method->id === $targeted_rate_id && 0 < $method->cost ) { $label = str_replace( $method->label . ': ', '', $label); } return $label; } Related: Change WooCommerce Checkout shipping method cost from a WC Session variable Change wc_cart_totals_shipping_method_label function in Woocommerce

February 13, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.