JSFiddle - React, Tailwind, and code Playground

by ian_smithz

HTML

<xxxscript src="https://hosted.curbside.com/1.0/curbside.dependencies.js"></xxxscript>
<xxxscript src="https://hosted.curbside.com/1.0/curbside.sdk.js"></xxxscript>
    
<script>
			var dataLayer=[{
	
				'customerId': '96000125',
        
				//'transactionId': 'J49583560',
        'transactionId': ('X'+ Math.floor(Math.random() * 10000000) + 1),
        
				'storeName': 'Glastonbury'

			  }];	
        
  
        
		</script>   
    


    <a href="/jsp/tradeCounter/tradeCounterDetailsPage.jsp?id=77" class="btn btn--sm btn--collections" target="_blank">Get directions <i class="icon-location"></i></a>

JavaScript

var screwfixCollectionHref = document.getElementsByClassName("btn--collections")["0"].href;
console.log(screwfixCollectionHref);

var screwfixCollectionHrefId = screwfixCollectionHref.split('=')[1];
console.log(screwfixCollectionHrefId);

var curbsideScrewfixStoreName = 'screwfix_' + screwfixCollectionHrefId;
console.log(curbsideScrewfixStoreName);

var curbsideScrewfixCustomerId = dataLayer["0"].customerId;
var curbsideScrewfixTransactionId = dataLayer["0"].transactionId;
//var curbsideScrewfixStoreName = dataLayer["0"].storeName;


console.log(curbsideScrewfixCustomerId);
console.log(curbsideScrewfixTransactionId);


if (curbsideScrewfixStoreName.match( /(screwfix_77|screwfix_59|screwfix_177)/ )) {

	Curbside.setAppId("screwfix.test.desktop");

  Curbside.setUsageToken("4a9606ec62bbf3bb2db48635bccbc0805ba169edc5c07dade175112e145a36ed");

	Curbside.setTrackingIdentifier(curbsideScrewfixCustomerId);

	Curbside.startTripToSiteWithIdentifier({ siteID: curbsideScrewfixStoreName, trackToken: curbsideScrewfixTransactionId });

}