• Hello,I`m trying to check if a product has been added to the cart.
    I found this function

    function check_if_product_is_in_cart($product_id){
      global $woocommerce;
        $items = $woocommerce->cart->get_cart();
            foreach($items as $item => $values) {
                if($values['product_id'] == $product_id){
    			  return true;
    			}
            }
    
    		return false;
    }

    However it needs the product_id,how can I get it from the product page?

  • The topic ‘Woocommerce get product_id’ is closed to new replies.