rachael-portier
4/22/2020 - 1:39 PM

Multiple Cart Notices

function cart_notice() {
	
	$guide_rails = array( 2926,2924 );
	$mft = array( 1814,1810 );
    $in_cart = false;
	 $subtotal = WC()->cart->get_subtotal();

    // Iterating through cart items and check
    foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item )
		
		
        if( in_array( $cart_item['data']->get_id(), $guide_rails ) && $subtotal <= 900 ){
            $in_cart = true; // We set it to "true"
   
	   echo '<notice>A 118" or 106" guide rail can only be shipped with a cart subtotal of $900 or in a track saw package. Please add more to your cart to be eligible for shipping.</notice>';
  
   }
		
		
		
        elseif( in_array( $cart_item['data']->get_id(), $mft ) ){
            $in_cart = true; // We set it to "true"
   
	   echo '<notice>Please note: The MFT tables(s) in your cart will only be shipped to a verified commercial location. Otherwise, they will have to be retrieved from your nearest shipping terminal.</notice>';
  
   }
	
	
}

add_action('woocommerce_proceed_to_checkout', 'cart_notice');