Skip to content

Instantly share code, notes, and snippets.

@madeincosmos
Created November 11, 2019 02:55
Show Gist options
  • Save madeincosmos/6e520711a572209d44f864a6811e41ec to your computer and use it in GitHub Desktop.
Save madeincosmos/6e520711a572209d44f864a6811e41ec to your computer and use it in GitHub Desktop.
Check if product add-ons are in cart
add_action( 'woocommerce_before_calculate_totals', 'custom_calculate_shipping_date_based_on_addons' );
function custom_calculate_shipping_date_based_on_addons() {
$cart_contents = WC()->cart->cart_contents;
foreach ( $cart_contents as $cart_item_key => $cart_item_data ) {
if ( ! empty( $cart_item_data['addons'] ) ) {
// addons in cart, add your code here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment