WordPress filter hook

woocommerce_get_cart_item_from_session

Defined by WooCommerce and fired by 8 plugins in total, running on 7M+ sites between them.

“Filter to modify or add session data to the cart contents.”

How to use woocommerce_get_cart_item_from_session

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_get_cart_item_from_session', function( $session_data, $values, $key ) {
	// Change $session_data here.
	return $session_data;
}, 10, 3 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

8 plugins that fire woocommerce_get_cart_item_from_session

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ) includes/class-wc-cart-session.php:263
  2. Pay with Vipps and MobilePay for WooCommerce icon Pay with Vipps and MobilePay for WooCommerce5,000+ installs apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ) payment/Vipps.class.php:2826
  3. Address Book & Multiple Shipping for WooCommerce icon Address Book & Multiple Shipping for WooCommerce1,000+ installs apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ) public/class-thmaf-public.php:3183
  4. Bolt Checkout for WooCommerce icon Bolt Checkout for WooCommerce100+ installs apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ) includes/bolt-payment-gateway-helpers.php:611
  5. Products Wizard Lite for WooCommerce icon Products Wizard Lite for WooCommerce10+ installs apply_filters( 'woocommerce_get_cart_item_from_session', array_merge($item, ['data' => wc_get_product($productId)]), $item, $key ) includes/classes/Cart.php:238
  6. Sales Igniter Rentals & Bookings Lite icon Sales Igniter Rentals & Bookings Lite10+ installs apply_filters( 'woocommerce_get_cart_item_from_session', array_merge( $item, [ 'data' => $product ] ), $item, $key ) Includes/SameDatesCart.php:182
  7. Stan Checkout icon Stan CheckoutFewer than 10 installs apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ) includes/wc-stan-utils.php:90
  8. Blazo Checkout icon Blazo CheckoutFewer than 10 installs apply_filters( 'woocommerce_get_cart_item_from_session', array_merge($values, ['data' => $product]), $values, $key ) includes/coupon.php:266

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.