Use CRUD in Woocommerce loop to get custom meta field

foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
			$product = $cart_item['data'];
			if ( $product->is_type( [ 'variation' ] ) ) {
				$product = wc_get_product( $product->get_parent_id() );
			}

			$custom_meta_product = $product->get_meta( '_custom_meta_product', true );


			if ( $custom_meta_product ) {
				return true;
			}
		}

Leave a Reply

Your email address will not be published.