Sending Commerce7's Cancel membership button to Garde
Paste one snippet into your Commerce7 Storefront Template or your own website so members who click Cancel membership reach your Garde flow, on Garde's page or in a panel on your site.
This is for wineries on Commerce7. You copy one snippet from Garde and paste it into your website. After that, when a signed-in member clicks Cancel membership on their Commerce7 profile (Club Memberships), they reach your Garde cancel flow instead of Commerce7's own cancel pop-up. You don't need a developer.
Garde's Install tab has three snippets. Use one of them:
| Snippet | Where it goes | What members see |
|---|---|---|
| 1. Open Garde's page | Commerce7's Storefront Template, or your own website | They leave your website for your Garde cancel page. |
| 2. Panel on your Commerce7 Storefront Template | Commerce7's Storefront Template | Garde opens in a panel over the page (full screen on phones). Closing it takes them back to their profile. |
| 3. Panel on your own website | Your own website | The same panel, opened from Commerce7's button or from your own button. |
The panel snippets show only after Garde support has turned the panel on for your website's address (for example https://shop.yourwinery.com). Until then, the Install tab says so; use Open Garde's page.
Pasting into Commerce7's Storefront Template
Use this for snippet 1 or 2 if your website is Commerce7's own storefront.
- In Garde, open Install and click Copy snippet under the snippet you chose.
- In Commerce7 admin, go to Settings → Storefront Template.
- Next to Custom HTML and Tags, click the pencil to edit.
- In Closing Body Tags, paste the snippet after anything already there. If a
Garde snippet is already there, replace it (everything from <!-- Garde: to the closing </script>).
- Save.
- Sign in to your website as a test member, open Club Memberships and click
Cancel membership. You should see your Garde cancel flow.
Pasting into your own website
Use this for snippet 1 or 3 if Commerce7 runs inside your own site (WordPress, Squarespace, Wix or a custom site).
- In Garde, open Install and click Copy snippet under the snippet you chose.
- Paste it on every page, just above
</body>:
- WordPress: your theme's footer, or a header-and-footer plugin.
- Squarespace: Settings → Advanced → Code Injection → Footer.
- Wix: Settings → Custom Code, all pages, end of body.
- Custom site: your shared page footer.
- Test it the same way: sign in as a test member, open your Commerce7 profile's
Club Memberships and click Cancel membership.
Opening Garde from your own button
Every snippet can also open Garde from a link you add anywhere on your site. Add data-garde-cancel to a link to your Commerce7 profile:
``html <a href="/profile/club-membership" data-garde-cancel>Cancel my membership</a> ``
- A signed-in member who clicks it opens your Garde cancel flow (the panel with
snippets 2 and 3, Garde's page with snippet 1).
- Anyone who isn't signed in follows the link as normal. Point it at your Commerce7
profile so they sign in first, then click Cancel membership there.
Developers can call window.GardeCommerce7.cancel() instead. It returns true when Garde has taken over, and false when it can't (for example, nobody is signed in). On false, send the member to your profile page.
What members see
- A signed-in member who clicks Cancel membership opens your Garde cancel flow.
If they have more than one club membership (active or on hold), Garde asks which one.
- Garde checks the member's Commerce7 sign-in with Commerce7 before showing anything.
- In the panel, Close (or Back to my account at the end) returns them to
their profile. If they changed something, the profile reloads to show it. While Garde is confirming a change, the panel can't be closed; if confirmation takes more than 30 seconds, it offers Return to your account.
When Commerce7's own cancel still runs
The snippet steps aside, and Commerce7's own cancel pop-up opens as before, when:
- Nobody is signed in, or the sign-in can't be read.
- The page belongs to a different Commerce7 store.
- The member was sent to Garde's page in the last 10 minutes from this browser tab,
or Garde couldn't start in the panel (for example Garde or Commerce7 had a problem), so a problem on Garde's side can't trap them.
- The address has
?garde=off. - Commerce7 changes its profile page so the snippet no longer recognises the
button.
With a panel snippet, if the panel can't open (for example the website's address isn't the one Garde turned the panel on for, or Garde doesn't answer within 5 seconds), the member goes to Garde's page instead (or, if their browser can't remember that hand-off, to Commerce7's own cancel). After a member changes something in the panel, the next click in that tab opens Garde again, which shows what happened, rather than Commerce7's pop-up. If they're no longer signed in by then, the page asks them to check their membership first.
Members can always cancel. Keep members allowed to cancel online switched on in Commerce7: the snippet takes over that button.
Good to know
- Skip isn't sent to Garde: Commerce7's profile has no skip button.
- If you change your website template or theme, check the snippet is still there.
- To build links yourself, see