WC_Cart::find_product_in_cart
Check if product is in the cart and return cart item key.
Cart item key will be unique based on the item and its properties, such as variations.
Method of the class: WC_Cart{}
No Hooks.
Returns
String. cart item key
Usage
$WC_Cart = new WC_Cart(); $WC_Cart->find_product_in_cart( $cart_id );
- $cart_id(mixed)
- id of product to find in the cart.
Default:false
WC_Cart::find_product_in_cart() WC Cart::find product in cart code WC 10.7.0
public function find_product_in_cart( $cart_id = false ) {
if ( false !== $cart_id ) {
if ( is_array( $this->cart_contents ) && isset( $this->cart_contents[ $cart_id ] ) ) {
return $cart_id;
}
}
return '';
}