Created
August 6, 2018 20:58
-
-
Save NickGreen/8560ab5a946e72662d247ec31251b7ad to your computer and use it in GitHub Desktop.
Do something if order has subscription product in it
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
<?php | |
$order = wc_get_order( $order_id ); | |
$sub_in_order = false; | |
$items = $order->get_items(); | |
foreach ( $items as $item ) { | |
$product_id = $item['product_id']; | |
if ( has_term( 'subscription', 'product_type', $product_id ) || has_term( 'variable-subscription', 'product_type', $product_id ) ) { | |
$sub_in_order = true; | |
break; | |
} | |
} | |
if ( $sub_in_order ) { | |
// DO THINGS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment