WC_Cart::find_product_in_cart( mixed $cart_id = false )

Check if product is in the cart and return cart item key.


Description Description

Cart item key will be unique based on the item and its properties, such as variations.


Parameters Parameters

$cart_id

(Optional) id of product to find in the cart.

Default value: false


Top ↑

Return Return

(string) cart item key


Top ↑

Source Source

File: includes/class-wc-cart.php

	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 '';
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.