Hooks & filters (developer reference)

Actions

sscwc_cart_saved Fires after a cart is successfully saved to the database.

  • $token (string) — the generated cart token
  • $cart_data (array) — the cart data array that was saved
  • $args (array) — the arguments used for saving (user_id, user_email, expires_in, cart_name, cart_hash)
add_action( 'sscwc_cart_saved', function( $token, $cart_data, $args ) {
    // e.g. send a confirmation email
}, 10, 3 );

Filters

sscwc_cart_data Filters the cart data array before it is saved to the database. Use this to add or modify what is stored.

  • $cart_data (array) — the cart data array with items, totals, and timestamp keys
add_filter( 'sscwc_cart_data', function( $cart_data ) {
    $cart_data['meta']['source'] = 'mobile';
    return $cart_data;
} );

sscwc_save_cart_response Filters the AJAX response returned to the browser after a cart is saved. Use this to add custom fields to the response.

  • $response (array) — the response array (includes token, share_url, qr_code_url, expires, message)
  • $token (string) — the cart token
  • $cart_data (array) — the saved cart data
add_filter( 'sscwc_save_cart_response', function( $response, $token, $cart_data ) {
    $response['item_count'] = count( $cart_data['items'] );
    return $response;
}, 10, 3 );

sscwc_share_url Filters the generated shareable URL for a cart token.

  • $url (string) — the generated URL
  • $token (string) — the cart token
  • $options (array) — options used to build the URL

 

add_filter( 'sscwc_share_url', function( $url, $token, $options ) {
    // e.g. use a custom domain for sharing
    return str_replace( home_url(), 'https://share.mystore.com', $url );
}, 10, 3 );

sscwc_qr_code_url Filters the QR code image URL.

  • $qr_url (string) — the QR code API URL
  • $token (string) — the cart token
  • $share_url (string) — the cart shareable URL
  • $options (array) — options including size and margin

sscwc_qr_provider Filters the QR code provider. Currently supports qrserver (default) and quickchart.

  • $provider (string) — the current provider key
add_filter( 'sscwc_qr_provider', fn() => 'quickchart' );

sscwc_require_cart_name Filters whether a cart name is required when saving a cart. Defaults to true.

  • $required (bool)
add_filter( 'sscwc_require_cart_name', '__return_false' );

sscwc_default_expiry_days Filters the cart expiration in days used for new saves. Applied on top of the admin setting.

  • $days (int) — the current expiry days value

sscwc_clear_current_cart_on_restore Filters whether the visitor’s current cart is cleared before restoring a shared cart. Defaults to true.

  • $clear (bool)
// Merge shared cart items into current cart instead of replacing
add_filter( 'sscwc_clear_current_cart_on_restore', '__return_false' );

sscwc_cart_token Filters the generated cart token string before it is used for saving.

  • $token (string) — the randomly generated 64-character hex token

sscwc_account_menu_items Filters the My Account navigation items array after the Saved Carts tab is added.

  • $items (array) — the full menu items array

sscwc_social_platforms Filters the social share platforms shown in the share dialog and the [sscwc_share_cart] shortcode.

  • $platforms (array) — associative array of platform configurations (url, icon, label)
add_filter( 'sscwc_social_platforms', function( $platforms ) {
    unset( $platforms['twitter'] ); // Remove Twitter/X
    return $platforms;
} );

sscwc_force_load_scripts Filters whether the plugin’s frontend scripts should be enqueued on the current page, even if it isn’t a cart, checkout, or product page. Defaults to false.

  • $force (bool)

sscwc_add_nonce_to_share_url Filters whether a security nonce is appended to the shareable URL. Defaults to false.

  • $add_nonce (bool)

sscwc_api_rate_limit Filters the number of REST API requests per minute allowed from a single IP address for unauthenticated saves. Defaults to 5.

  • $limit (int)