Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Cart collaterals hook.
- *
- * @hooked woocommerce_cross_sell_display
- * @hooked woocommerce_cart_totals - 10
- */
- $categories = array( 39 );
- foreach ( WC()->cart->get_cart() as $cart_item ) {
- if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
- $found = true; // Set to true
- break; // Stop the loop
- }
- }
- if( $found ) {
- echo 'Category with ID = 39';
- }
- else if ($found != $cart_item['category_ids']) {
- echo "Category with ID = 39 and other ID('s)";
- }
- else {
- "Category with ID != 39";
- }
- ["category_ids"]=>
- array(1) {
- [0]=>
- int(39)
- }
- /// another stuff in the array
- ["category_ids"]=>
- array(2) {
- [0]=>
- int(32)
- [1]=>
- int(33)
- }
Add Comment
Please, Sign In to add comment