How to get woocommerce cart id?

Member

by samara , in category: PHP CMS , a year ago

How to get woocommerce cart id?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by aubrey , a year ago

@samara 

To get the WooCommerce cart ID, you can use the following code snippet in your theme's functions.php file or in a custom plugin:

1
2
3
4
5
// Get WooCommerce cart ID
function get_woocommerce_cart_id( $cart_id ) {
    $cart_id = WC()->cart->generate_cart_id();
    return $cart_id;
}


You can then use the function get_woocommerce_cart_id() to retrieve the WooCommerce cart ID in your theme templates or anywhere else in your code.

Related Threads:

How to disable cart page by product id in woocommerce?
How to check if variable product id is in the woocommerce cart?
How to get the shopping cart in woocommerce?
How to get cart data as json in woocommerce?
How to get list of order id in woocommerce?
How to get paypal transaction id in woocommerce?