Ecommerce Shopify WordPress Discussion

Free shipping on entire order once a specific product is added to cart

Product A is added in cart and it has shipping fees. Product B is added in cart and once its added, shipping should be free. However Woocoomerce charges shipping, because Cart includes product with fees and without fees. I Tried this code but it didn't work function wcs_my_free_shipping( $is_available ) { global $woocommerce; // set the product ids that are eligible $eligible = array( '560' ); // get cart contents $cart_items = $woocommerce->cart->get_cart(); // loop through the items looking for one in the eligible array foreach ( $cart_items as $key => $item ) { if( in_array( $item['product_id'], $eligible ) ) { return true; } } // nothing found return the default value return $is_available; } add_filter( 'woocommerce_shipping_free_shipping_is_available', 'wcs_my_free_shipping', 20 );
I used two codes function wcs_my_free_shipping( $is_available ) { global $woocommerce; // set the product ids that are eligible $eligible = array( '560', '562', '563', '564'); // get cart contents $cart_items = $woocommerce->cart->get_cart(); // loop through the items looking for one in the eligible array foreach ( $cart_items as $key => $item ) { if( in_array( $item['product_id'], $eligible ) ) { return true; } } // nothing found return the default value return $is_available; } add_filter( 'woocommerce_shipping_free_shipping_is_available', 'wcs_my_free_shipping', 20 ); and function wcs_my_free_shipping( $is_available ) { global $woocommerce; // set the product ids that are eligible $eligible = array( '560', '562', '563', '564'); // get cart contents $cart_items = $woocommerce->cart->get_cart(); // loop through the items looking for one in the eligible array foreach ( $cart_items as $key => $item ) { if( in_array( $item['product_id'], $eligible ) ) { return true; } } // nothing found return the default value return $is_available; } add_filter( 'woocommerce_shipping_free_shipping_is_available', 'wcs_my_free_shipping', 20 );

January 17, 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.