Created
March 19, 2019 14:13
-
-
Save bernattorras/39717d448bc767474670615919e5c41b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check the "shipping to different address" checkbox on the Checkout page if the cart contains a gifted item | |
add_filter('woocommerce_ship_to_different_address_checked','check_shipping_if_gifting', 11, 1); | |
function check_shipping_if_gifting($val){ | |
foreach ( WC()->cart->cart_contents as $key => $item ) { | |
if ( '' !== WCSG_Cart::get_recipient_from_cart_item( $item ) ) { | |
return true; | |
} | |
} | |
return $val; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment