Install Sam free

★ 4.9 (107 reviews) Built for Shopify Free plan available

Guides

Keeping Cart Drawer and Checkout Protection Toggles in Sync

TL;DR

Keep your cart drawer and Shopify Plus checkout protection toggles in sync by waiting to write the protection line until the buyer clicks Checkout, matching the active protection product ID in your Checkout UI Extension, and deduplicating lines. In Sam Shipping Protection, both widgets share your title, pricing rules, and exclusions automatically without creating duplicate line items.

Getting checkout extensibility cart sync right is critical when your Shopify Plus store runs a shipping protection toggle in both your slide-out cart drawer and your checkout steps. If those two placements do not read from the same product IDs, pricing rules, and cart state, shoppers can end up with two protection line items on the same order, a checkout switch that looks turned off after they already opted in, or a stale fee left behind when they hit the browser Back button.

With Sam Shipping Protection, the theme app embed in your cart drawer and the Sam Checkout UI block in Shopify Plus checkout extensibility share one configuration and synchronize cart lines automatically. This guide explains what causes cart-to-checkout desyncs on Shopify Plus, how to sync your cart widget and checkout toggle, and the exact steps to prevent a duplicate protection item across every buyer path.

Why do cart drawer widgets and Shopify Plus checkout toggles fall out of sync?

A storefront cart drawer and a Shopify Plus Checkout UI Extension run in two completely different environments. Your cart drawer shipping protection widget runs in the browser DOM through a theme app embed and talks to the storefront Ajax Cart API (/cart.js, /cart/add.js, and /cart/update.js). Your Shopify Plus shipping protection checkout widget runs inside Shopify’s sandboxed UI Extension worker and updates the cart through Shopify’s cart lines change API.

When a protection setup is stitched together without a shared state model, four common bugs appear:

  1. Duplicate protection line items: The cart drawer adds a protection variant immediately when the drawer opens, and the checkout extension fails to recognize that variant—or adds a second variant when the cart total changes in checkout.
  2. Stale tier prices after Back-button navigation: A shopper opts in on a $90 cart in the drawer, proceeds to checkout (which writes the $90 tier variant to the cart), hits the browser Back button, and adds another $80 item. If the cart widget does not clear the checkout-added line item on return, the cart now holds an outdated protection variant alongside the live preview.
  3. Double checkout widgets: A merchant places the checkout app block in two checkout drop zones at once (for example, both under the shipping methods and inside the order summary section), rendering two competing toggles in checkout.
  4. Mismatched exclusion or pricing rules: A wholesale customer or small cart is hidden in the cart drawer, but the checkout extension re-offers or auto-adds protection because the exclusion state was not passed into checkout.
Desync symptomRoot cause in cart / checkout flowHow Sam Shipping Protection prevents it
Two protection lines on one orderEager cart writes in the drawer or unrecognized variant IDs when switching price tiersDefers the cart write until the buyer clicks Checkout, deduplicates by protection product ID, and forces protection quantity to 1
Checkout toggle shows “Off” when protection is already in cartCheckout extension checks only one hardcoded variant ID instead of all active/legacy protection product IDsSam Checkout UI scans checkout cart lines against your store’s protection product IDs and sets the toggle to match the existing line
Stale protection line stuck in cart after clicking BackProtection variant added before checkout stays in /cart.js when the buyer navigates back to shopSets a checkout session flag on departure and clears the protection line item on the pageshow event when returning from checkout
Orphaned protection line when all physical items are removedBuyer removes physical products or triggers an exclusion rule after protection was addedClears the protection line automatically when a rule hides the widget, backed by the Shipping protection: require another product checkout rule
Widget appears twice on the checkout pageApp block placed in two spots inside the Shopify checkout editorResolved by placing the Sam Checkout UI block in one spot only in Settings > Checkout

How do you sync a cart widget and checkout toggle in Sam Shipping Protection?

To sync your cart widget and checkout toggle in Sam Shipping Protection, you do not need custom theme JavaScript or manual webhook scripts. Instead, you configure your pricing, text, and rules once on the Protection page, enable the theme app embed for your cart and cart drawer, and place the checkout extension block once in your Shopify Plus checkout editor.

Note that showing a widget inside the information, shipping, or payment steps of Shopify checkout requires both a Shopify Plus store (including Shopify Plus Trial stores) and the Sam Plus plan ($29/month). Stores on any Shopify plan and any Sam plan—including the free Starter plan for up to 50 protected orders a month and the Standard plan at $9/month—can pair the cart drawer widget with the post-purchase thank-you page offer.

Step 1: Turn on the theme app embed for your cart and cart drawer

Start by enabling the storefront script so the widget renders on your cart page and inside your theme cart drawer or supported third-party side cart app (detailed in the installation and app embed guide):

  1. Open Sam Shipping Protection in your Shopify admin. On the Home page, check the status badge at the top.
  2. If it says App embed off, click Turn on in theme inside the Setup guide.
  3. The Shopify theme editor opens to App embeds with Sam Shipping Protect switched on. Click Save in the theme editor.
  4. Return to the Sam Home page and confirm the badge updates to App embed on.

Once the app embed is active, Sam automatically hooks into standard theme cart drawers as well as third-party cart drawer events and host slots (the App Store listing notes compatibility with Essential, UpCart, AOV Bundle, iCart Cart, and Snap Cart Drawer; if your custom drawer uses non-standard selectors, ShopWil support adjusts it for free).

Step 2: Set shared pricing and widget content once

Open Protection in the Sam app menu. Everything you set in the Insurance pricing and Content cards is shared automatically between the cart widget and the checkout widget (see the pricing setup guide and widget text and translations guide):

  • Pricing model (Fixed or Percentage): Choose Fixed (a flat fee, or click Set price by cart value to define cart-value bands where each tier starts 0.01 above the last) or Percentage (a percentage of the cart items’ value, with optional Set min/max price floors and caps on the Plus plan).
  • Shared title, descriptions, note, and translations: In the Content card, set your Title (up to 50 characters, which also syncs one-way to your protection product title in Shopify Products when you save), Description, optional Show a different description when protection is off, and optional Note (up to 500 characters, always visible below the description). On Standard and Plus, any language translations you add in the Content card apply to both your cart drawer and your checkout widget.

(Reminder: “Shipping insurance” and “Insurance pricing” are only default setting labels in the UI—Sam is not an insurance company and does not underwrite policies. Use clear wording that describes your store’s own protection terms.)

Step 3: Enable the Checkout Page widget and add the block in the checkout editor

Next, turn on the checkout extension and place it in Shopify’s checkout editor (walked through with screenshots in Add protection at checkout on Shopify Plus):

  1. On the Protection page in Sam, expand Checkout Page under Where it shows.
  2. Switch on Enable widget (it starts off by default).
  3. Choose your checkout-specific visual settings: Accept offer style (toggle switch or checkbox), Icon size, Appearance, and Typography. While the card is expanded, the live preview on the right switches to Checkout so you can inspect the look.
  4. Click Save in the top save bar.
  5. In your Shopify admin, go to Settings > Checkout and click Edit on your active checkout configuration.
  6. Click Add app block, select Sam Checkout UI, and drag it into one spot only—for example, directly below the shipping methods list or inside a single checkout section.
  7. Click Save in the top-right corner of the checkout editor.

How does the state handoff prevent a duplicate protection item?

Understanding how Sam handles the cart-to-checkout handoff under the hood makes it much easier to test your storefront and verify that a shopper can never accidentally buy two protection lines. Here is the exact lifecycle that runs to prevent a duplicate protection item:

1. Preview-first in the cart drawer, single write on Checkout click

When a shopper switches protection On in your cart page or cart drawer using a toggle layout (Standard or Minimal) or clicks the protected checkout button in a button layout (Expanded or Detailed, covered in the widget design guide), Sam does not flood the /cart/add.js endpoint on every toggle click.

Instead, while the shopper is still browsing or adjusting quantities in the cart drawer:

  • Sam tracks the toggle state and updates the displayed subtotal estimate in the cart drawer in real time.
  • If the shopper unchecks a pre-selected toggle, Sam saves a dismissal flag in session storage so the toggle stays off across page loads during that browsing session instead of nagging the buyer on every page.
  • Only when the shopper clicks the Checkout button (or an accelerated wallet button wrapper, or triggers the pre-checkout hook in a supported cart drawer) does Sam write the protection variant to the Shopify cart right before redirecting to /checkout.

2. Built-in deduplication and quantity capping on cart write

When the cart-write step runs at the moment of checkout, it inspects the live items in /cart.js against your store’s protection product IDs (fixed, percentage, and any legacy protection product IDs):

  • If a protection line with the exact target variant ID is already in the cart with a quantity greater than 1, Sam sends a /cart/update.js request to reset its quantity back to 1.
  • If the cart somehow contains multiple protection lines or an outdated tier variant from an earlier cart total, Sam zeros out (quantity: 0) every extra or mismatched protection line in a single update before proceeding.
  • If the exact matching variant is already present at quantity 1, Sam skips /cart/add.js entirely and proceeds straight to checkout.

3. Automatic line detection inside the Shopify Plus checkout extension

When the shopper lands in Shopify Plus checkout, the Sam Checkout UI extension reads the checkout cart lines and checks whether any cart line belongs to your store’s protection product IDs:

  • If the shopper opted in from the cart drawer: The protection line is already in the checkout cart lines. The checkout extension detects it, displays the actual protection line price in the buyer’s checkout currency, and renders the checkout switch or checkbox in the checked (On) position. It does not add a second line.
  • If the shopper turns the toggle Off inside checkout: The checkout extension locates the exact protection cart line ID and calls Shopify’s cart line update API to set quantity: 0, cleanly removing the line item from the order summary.
  • If the shopper skipped protection in the cart drawer (or jumped straight to checkout): The checkout extension sees no protection line in the cart, calculates the fee for the current cart (using your Fixed price, cart-value tiers, or Percentage rules in the buyer’s market currency), and renders the toggle in the unchecked (Off) position—or auto-selects it once if auto-enable is active. If the buyer toggles it On at checkout, the extension adds the line with the checkout source attribute so your Protected orders CSV export records checkout in the Source column (versus cart or thank_you).

4. Browser Back-button cleanup (pageshow)

What if a shopper enables protection in the cart drawer, clicks Checkout (which writes the protection line item to the cart), and then clicks the browser Back button to add more items?

When the shopper clicks Checkout, Sam writes a checkout marker in local storage. As soon as the shopper navigates back to any storefront page—including when the browser restores the page from the back-forward cache (bfcache) via the pageshow event—Sam detects the marker, removes it, and clears the protection line from /cart.js. The cart widget remains visually toggled on from the shopper’s session state, recalculates the fee dynamically as they add or remove products, and writes the fresh tier or percentage variant when they click Checkout again.

How do targeting rules and Shopify Checkout rules stay aligned across cart and checkout?

If you use visibility rules or checkout validations, you should know which rules execute in both placements and which ones use Shopify’s native Checkout Validation Functions.

Targeting & exclusions sync (Hide from and Minimum cart total)

In Protection > Rules > Targeting & exclusions (explained in the visibility and exclusions guide):

  • Customer exclusions (Hide from on Standard and Plus): You can hide protection from Logged-in customers, Guests, or Customers with certain tags (such as wholesale, b2b, or vip). When a signed-in customer with an excluded tag visits the cart, the cart widget hides itself and syncs an excluded-customer cart attribute. If that customer already had a protection line in their cart or moves into Shopify Plus checkout, the checkout extension reads both the customer state and the cart attribute, hides the checkout widget, and automatically zeros out (quantity: 0) any existing protection line so they are never charged.
  • Minimum cart total (Only show when the cart total reaches a minimum on Plus): Both the cart widget and the Shopify Plus checkout widget check the cart subtotal (excluding the protection fee itself and converted to the buyer’s currency) and hide the toggle when the cart falls below your minimum threshold.
  • Country rule (Only show in certain countries on Plus) and Learn more popups: Note two documented differences at checkout. First, the Only show in certain countries rule applies to the cart widget only and does not hide the checkout widget. Second, if your Learn more action is set to Show a popup, the modal popup opens in the cart widget, whereas at checkout (and on the thank-you page) Learn more renders as plain text or a link.

Adding Sam’s two native Shopify Checkout rules

Even when your cart and checkout widgets are synced, a shopper could still select Local pickup during checkout after opting into shipping protection in the cart drawer, or remove every physical product from their cart at the last second.

To close both gaps at the server level, enable Sam’s two built-in checkout validation rules in your Shopify admin (see how to block protection on local pickup orders):

  1. Go to Settings > Checkout in your Shopify admin and scroll down to Checkout rules.
  2. Click Add rule and select Shipping protection: block on local pickup. Set its status to Active and click Save. If a buyer has protection in their cart and chooses local pickup at checkout, Shopify halts checkout with a localized message asking them to remove shipping protection before continuing.
  3. Click Add rule again and select Shipping protection: require another product. Set its status to Active and click Save. This rule stops checkout if a cart ever holds only the shipping protection product without a physical item.

If you also experience repeat claim abusers, reship fraudsters, or high-risk buyers trying to check out using disposable emails or flagged addresses, you can pair Sam’s protection rules with a server-side Checkout Validation Function in LabX Fraud & IP Blocker, which blocks abusive email domains, phone numbers, or shipping addresses on Shopify’s servers where browser tools cannot bypass it. For more on pre-checkout risk filtering, see our guide on stopping high-risk orders before they turn into shipping claims.

How should you test your cart drawer and checkout sync before going live?

Before announcing your protection program—or right after switching themes or installing a new cart drawer app—open an incognito browser window and run this five-minute QA checklist:

  1. Path A — Opt in at the cart drawer, verify at checkout: Add a physical item to your cart, open the cart drawer, and make sure the protection toggle is On. Click Checkout. On the Shopify Plus checkout page, confirm that:
    • Only one Sam Checkout UI widget is visible on the page.
    • The checkout toggle is already switched On, and the order summary shows a single protection line item with quantity 1 and the matching fee.
  2. Path B — Toggle Off inside checkout: While still in checkout from Path A, flip the Sam Checkout UI switch Off. Confirm that the protection line item disappears from the order summary right away and the order total drops by the exact fee amount. Flip it back On and verify it re-adds a single line item.
  3. Path C — Browser Back button and tier change: With protection in your cart at checkout, click the browser Back button to return to your storefront. Open your cart drawer, increase the product quantity so the cart crosses into a higher cart-value price band (or changes the percentage total), and click Checkout again. Confirm that checkout shows only the new, updated fee—never the old tier variant alongside the new one.
  4. Path D — Skip in the cart drawer, add at checkout: Turn the protection toggle Off in the cart drawer and click Checkout. Confirm the checkout toggle starts Off (even if you use auto-preselect in the cart, because your dismissal in the cart drawer is respected; if the shopper skipped the cart entirely via a direct checkout path, checkout follows your setting). Toggle it On at checkout and confirm the fee appears in the order summary.
  5. Path E — Local pickup validation: With protection toggled On in checkout, switch the delivery method from Ship to Pick up. Confirm that checkout blocks progression with the message “Shipping protection isn’t needed for local pickup. Please remove it from your cart to continue.” until you flip the checkout protection toggle Off.

If any step fails—for example, if the widget does not appear in your cart drawer or checkout—walk through the five checks in Can’t see the protection widget? or message the ShopWil team from the in-app live chat for a free theme and checkout inspection. For a full walkthrough of initial installation, see how to add shipping protection to Shopify checkout.

Frequently asked questions

How does Sam Shipping Protection prevent duplicate protection items between the cart drawer and checkout?

Sam waits to write the protection product to the cart until the shopper clicks the checkout button, and its cart manager checks existing lines by protection product ID before adding a variant—removing any extra or mismatched lines and capping the protection quantity at 1. Inside Shopify Plus checkout, the Sam Checkout UI block detects the existing protection line, renders the switch as checked, and updates that exact line quantity to 0 if the buyer turns it off.

What happens if a buyer adds shipping protection in the cart, reaches checkout, and clicks the browser Back button?

When the shopper clicks Checkout in the cart or cart drawer with protection enabled, Sam records a local checkout flag before adding the protection variant and redirecting. When the shopper returns to the storefront via the browser Back button, Sam listens for the page show event, clears the protection line item from the cart, and lets the cart widget recalculate cleanly as the shopper edits their cart.

Do I need to configure separate prices or translations for the cart drawer widget and the Shopify Plus checkout widget?

No. In Sam Shipping Protection, the Checkout Page widget automatically pulls its title, description, disabled description, note, translations, and pricing rules (Fixed, cart-value tiers, or Percentage) from your main Protection Settings. The Checkout Page card only controls checkout-specific visual styling such as the switch or checkbox style, icon size, border, and typography.

Which targeting and exclusion rules sync between the cart widget and the Shopify Plus checkout extension?

Customer exclusions under Hide from (logged-in customers, guests, or customers with specific tags) and the minimum cart total rule apply to both the cart widget and the Shopify Plus checkout widget. For tagged customer exclusions, the cart widget marks the cart attribute when the shopper passes through the cart, and the checkout extension reads that attribute and removes any protection line if the buyer is excluded.

Sources

  1. Sam Shipping Protection User Guide: Add protection at checkout (Shopify Plus)
  2. Sam Shipping Protection User Guide: Hide the widget from some customers or carts
  3. Sam Shipping Protection User Guide: Protection charged on pickup orders?
  4. Sam Shipping Protection User Guide: See protected orders and protection revenue

Part of our guide: Shipping protection →

Keep 100% of your protection fees

Sam Shipping Protection is free for your first 50 orders a month.

Install free on Shopify

★ 4.9 (107 reviews) Built for Shopify Free plan available