• Resolved Dakid

    (@myiah)


    is there a way to create packages then only oallow free shipping for one package if it is over 25 dollars just for that package.?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    This plugin does not allow for creating packages, my Advanced Shipping Packages plugin does allow for that.

    The ‘Subtotal’ condition is based on the cart amount, not package based, but it is possible to change this behaviour with a custom code snippet.

    Cheers,
    jeroen

    Thread Starter Dakid

    (@myiah)

    DO you know what the code snippet is for that.. Can you email or paste it here please?

    Thread Starter Dakid

    (@myiah)

    Here is what I have using pure code no plugin but it is not correctly working after i impleted it. It works as in applies free shipping to threads once it reaches 25 or more but if in the future if i wanted to use a coupon of 20% off of products It doesnt seem to work for the other products that are not threads. Also another problem is that when i go to check out the item list is grey out with a loading spinning icon like it is trying to load but cannot because of my code snippet.

    Can you take a look at it Please and point me in the right direction.

    add_filter( 'woocommerce_cart_shipping_packages', 'threads_woocommerce_cart_shipping_packages' );
    
    function threads_woocommerce_cart_shipping_packages( $packages ) {
        // Reset the packages
        $packages = array();
      
        // threads items
        $threads_items = array();
        $regular_items = array();
        
        // Sort threads from regular
        foreach ( WC()->cart->get_cart() as $item ) {
            if ( $item['data']->needs_shipping() ) {
                if ( $item['data']->get_shipping_class() == 'threads' ) {
                    $threads_items[] = $item;
                } else {
                    $regular_items[] = $item;
                }
            }
        }
        
      
      
          $threads_shipping   = array_sum( wp_list_pluck( $threads_items, 'line_total' ) );
    	  echo $threads_shipping;
    	  
    	  if(($threads_shipping) > 25) {
    		
    		   $packages[] = array(
    		  'ship_via' => array( 'free_shipping' ),
                'contents' => $threads_items,
                'contents_cost' => array_sum( wp_list_pluck( $threads_items, 'line_total' ) ),
                'applied_coupons' => WC()->cart->applied_coupons,
                'destination' => array(
                    'country' => WC()->customer->get_shipping_country(),
                    'state' => WC()->customer->get_shipping_state(),
                    'postcode' => WC()->customer->get_shipping_postcode(),
                    'city' => WC()->customer->get_shipping_city(),
                    'address' => WC()->customer->get_shipping_address(),
                    'address_2' => WC()->customer->get_shipping_address_2()
    			  
    			  
    			  
                )
            );
    		
            } else {
    		
    		 $packages[] = array(
    		   'ship_via' => array( 'flat_rate' ),
                'contents' => $threads_items,
                'contents_cost' => array_sum( wp_list_pluck( $threads_items, 'line_total' ) ),
                'applied_coupons' => WC()->cart->applied_coupons,
                'destination' => array(
                    'country' => WC()->customer->get_shipping_country(),
                    'state' => WC()->customer->get_shipping_state(),
                    'postcode' => WC()->customer->get_shipping_postcode(),
                    'city' => WC()->customer->get_shipping_city(),
                    'address' => WC()->customer->get_shipping_address(),
                    'address_2' => WC()->customer->get_shipping_address_2()
    			  
    			  
    			  
                )
            );
    		
    	  }
      
      
      
        if ( $regular_items ) {
            $packages[] = array(
    		  	'ship_via' => array( 'flat_rate' ),
                'contents' => $regular_items,
                'contents_cost' => array_sum( wp_list_pluck( $regular_items, 'line_total' ) ),
                'applied_coupons' => WC()->cart->applied_coupons,
                'destination' => array(
                    'country' => WC()->customer->get_shipping_country(),
                    'state' => WC()->customer->get_shipping_state(),
                    'postcode' => WC()->customer->get_shipping_postcode(),
                    'city' => WC()->customer->get_shipping_city(),
                    'address' => WC()->customer->get_shipping_address(),
                    'address_2' => WC()->customer->get_shipping_address_2()
                )
            );
        }    
        
        return $packages;
    }
    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Unfortunately I won’t be able to assist with customizations like this within the support. I’d advise to get in touch with the developer on the project for assistance with customizations.

    Cheers,
    Jeroen

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Free Shipping Packages’ is closed to new replies.