Home › Forums › WoodMart support forum › Shipping price display
Shipping price display
- This topic has 7 replies, 2 voices, and was last updated 3 weeks, 4 days ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
December 11, 2024 at 11:50 am #621519
zanParticipantHello.
I would like to ask how can I hide flat rate shipping option on the checkout page if free shipping is available? I tried code from woocommerce (https://developer.woocommerce.com/docs/free-shipping-customizations/) docs but it doesn’t work with this theme.December 11, 2024 at 6:03 pm #621666
Aizaz Imtiaz AwanKeymasterHello,
Please try to add the following snippet to your child theme’s functions.php file:
add_filter('woocommerce_package_rates', 'hide_flat_rate_when_free_shipping_available', 10, 2); function hide_flat_rate_when_free_shipping_available($rates, $package) { // Check if free shipping is available if (isset($rates['free_shipping'])) { // Remove flat rate shipping unset($rates['flat_rate']); } return $rates; }
Best Regards.
December 12, 2024 at 2:20 pm #621866
zanParticipantThe code doesn’t work.
Also I found another problem.
If I add 3 products the price is 50,7€ and in this case the option for free shipping is displayed.
If I add 6 products in total the option for free shipping is not even displayed any more. Only flat rate shipping is displayed in that case. I think there is some kind of additional error that for orders over 100€ free shipping is not available any more and that is not ok. For all orders over 50€ only free shipping option must be displayed.
Can you please check this.December 12, 2024 at 2:32 pm #621873
zanParticipantI found a solution for orders over 100€ I had to change the calculation setting in free shipping bar from custom to based of woocommerce.
But the first part of the problem is still there. The code you have sent to me for removing flat rage when free shipping is available doesn’t work.
December 12, 2024 at 6:34 pm #621972
Aizaz Imtiaz AwanKeymasterHello,
Please delete the old code and use this below code:
/** * Hide shipping rates when free shipping is available, but keep "Local pickup" * Updated to support WooCommerce 2.6 Shipping Zones */ function hide_shipping_when_free_is_available( $rates, $package ) { $new_rates = array(); foreach ( $rates as $rate_id => $rate ) { // Only modify rates if free_shipping is present. if ( 'free_shipping' === $rate->method_id ) { $new_rates[ $rate_id ] = $rate; break; } } if ( ! empty( $new_rates ) ) { //Save local pickup if it's present. foreach ( $rates as $rate_id => $rate ) { if ('local_pickup' === $rate->method_id ) { $new_rates[ $rate_id ] = $rate; break; } } return $new_rates; } return $rates; } add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
Best Regards.
December 16, 2024 at 3:27 pm #622867
zanParticipantThis code now works. Thank you.
I have another problem.
Attachments:
You must be logged in to view attached files.December 17, 2024 at 9:23 am #623061
zanParticipantCan you please help me solve the variation style problem as well?
December 17, 2024 at 6:52 pm #623323
Aizaz Imtiaz AwanKeymasterHello,
May be there is an issue with the 3rd party plugins. Please deactivate all the 3rd party plugins and activate only theme-required plugins on the site and then check the issue. I am sure your issue will be solved. Then Activate the 3rd party plugins one by one and check which plugin is creating the issue for you.
Otherwise, if the issue still exists then keep the 3rd party plugins deactivated and let me know so I will check and give you a possible solution.
Best Regards.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register