Description:
I have use case where I need to check if a specific product has been added to cart before customer adds another products to cart.
Background:
We are renting products out based on packages(which are products). Packages include multiple products and products do not have price, packages do. So basically you would need to add a package(with price) and products(with no price) to cart.
Problem:
At the moment customers can add products before packages and they can continue to shopping cart with total zero.
Some of the progress what I have:
if ( ! WC()->cart->is_empty() )
foreach( WC()->cart->get_cart() as $cart_item )
// now i would need to check if cart consists a package
And i could solve adding product to cart with no package in cart like this:
if (WC()->cart->is_empty() )
//then don't add product to cart, tell customer to add package first.