Last active
July 12, 2021 15:51
-
-
Save jorpdesigns/33337de93122975a56665309eeda1838 to your computer and use it in GitHub Desktop.
Snippet to check if WooCommerce product is in cart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$product_id = 15; // Replace with your product id | |
$product_cart_id = WC()->cart->generate_cart_id( $product_id ); | |
if( ! WC()->cart->find_product_in_cart( $product_cart_id ) ){ | |
// Do something | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment