Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce - is Product in Cart
<?php
function is_product_in_cart( $prodID ) {
$cartID = WC()->cart->generate_cart_id( $prodID );
$in_cart = WC()->cart->find_product_in_cart( $cartID );
if ( $in_cart ) {
return true;
}
return false;
}
/* USAGE:
-------------------- */
// Product ID
$myProd = 1234;
// See if Product is in Cart
if ( is_product_in_cart( $myProd ) {
// do stuff
return true;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment