This client-side implementation provides a deterministic reference for customer login status in Shopify. Open the flems example by pressing the badge to see it in action:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Step 1. Add and initialize your third-party JavaScript pixel (make sure to exclude HTML) | |
| // Replace with you GA4 Tag | |
| const TAG_ID = 'G-XXXXXXXXXX'; | |
| const script = document.createElement('script'); | |
| script.setAttribute('src', `https://www.googletagmanager.com/gtag/js?id=${TAG_ID}`); | |
| script.setAttribute('async', ''); | |
| document.head.appendChild(script); | |
| window.dataLayer = window.dataLayer || []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const browserSync = require('browser-sync'); | |
| const {getStoreValue, getThemeIdValue} = require('@shopify/slate-env'); | |
| const {getSSLKeyPath, getSSLCertPath} = require('../utilities'); | |
| class DevServer { | |
| constructor(options) { | |
| this.bs = browserSync.create(); | |
| this.target = `https://${getStoreValue()}`; | |
| this.themeId = getThemeIdValue(); | |
| this.port = options.port; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha | |
| // for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page. | |
| // Retrieves input data from a form and returns it as a JSON object: | |
| function formToJSON(elements) { | |
| return [].reduce.call(elements, function (data, element) { | |
| data[element.name] = element.value; | |
| return data; | |
| }, {}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Build the Shopify Parameters | |
| //---------------------------------------*/ | |
| var action = '/contact?'; | |
| action += encodeURIComponent('form_type') +'='+ encodeURIComponent('contact'); | |
| action += '&'+ encodeURIComponent('utf8') +'='+ encodeURIComponent('✓'); | |
| action += '&'+ encodeURIComponent('contact[email]') +'='+ encodeURIComponent(contact_email); | |
| action += '&'+ encodeURIComponent('contact[body]') +'='+ encodeURIComponent(contact_body); | |
| /* Submit the form | |
| //---------------------------------------*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implementation in ES6 | |
| function pagination(c, m) { | |
| var current = c, | |
| last = m, | |
| delta = 2, | |
| left = current - delta, | |
| right = current + delta + 1, | |
| range = [], | |
| rangeWithDots = [], | |
| l; |