Home > widget-integration > CartSelectors > getCartSelectorAndUpdateAction

CartSelectors.getCartSelectorAndUpdateAction() method

Get cart selector configuration for current theme

Detects which Shopify theme is active by checking for theme-specific selectors Returns the first matching theme configuration found

Signature:

getCartSelectorAndUpdateAction(): {
		selector: string;
		action: (cartItemCount: number) => void;
		theme?: string;
	} | undefined;

Returns:

{ selector: string; action: (cartItemCount: number) => void; theme?: string; } | undefined

Theme cart configuration or undefined if no match found

Example

const config = cartSelectors.getCartSelectorAndUpdateAction();
if (config) {
  config.action(5); // Update cart count to 5
}