Created
February 18, 2015 02:52
-
-
Save bryceadams/221d9703f8fc0842887e to your computer and use it in GitHub Desktop.
WooCommerce no shipping available for certain products
This file contains hidden or 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
function wcs_no_specific_shipping( $rates ) { | |
global $woocommerce; | |
// set the product ids that are eligible | |
$eligible = array( '963' ); | |
// 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 false; | |
} | |
} | |
// nothing found return the default value | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'wcs_no_specific_shipping', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment