Skip to content

Commit

Permalink
changed url to custom
Browse files Browse the repository at this point in the history
  • Loading branch information
Stubbe committed Jan 2, 2024
1 parent bba2a11 commit d86efdc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.php-cs-fixer.cache
21 changes: 18 additions & 3 deletions code/Block/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class Clerk_Clerk_Block_Tracking extends Mage_Core_Block_Template
{
const XML_PATH_PUBLIC_KEY = 'clerk/general/publicapikey';
const XML_PATH_COLLECT_EMAILS = 'clerk/general/collect_emails';
public const XML_PATH_PUBLIC_KEY = 'clerk/general/publicapikey';
public const XML_PATH_COLLECT_EMAILS = 'clerk/general/collect_emails';

/**
* Get public key
Expand Down Expand Up @@ -34,4 +34,19 @@ public function collectEmails()
{
return Mage::getStoreConfigFlag(self::XML_PATH_COLLECT_EMAILS);
}
}

/**
* Get store name
*/
public function getStoreName()
{
return Mage::app()->getStore()->getName();
}

public function getClerkJSUrl()
{
$storeName = $this->getStoreName();
$storeName = preg_replace('/[^a-z]/', '', strtolower($storeName));
return '://custom.clerk.io/' . $storeName . '.js';
}
}
2 changes: 1 addition & 1 deletion code/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Clerk_Clerk>
<version>4.8.2</version>
<version>4.8.4</version>
</Clerk_Clerk>
</modules>
<global>
Expand Down
6 changes: 5 additions & 1 deletion design/frontend/base/default/template/clerk/tracking.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ $toLocaleStringOptions = array(
$public_key = Mage::getStoreConfig('clerk/general/publicapikey');
$form_key = Mage::getSingleton('core/session')->getFormKey();
$collect_emails = Mage::getStoreConfigFlag('clerk/general/collect_emails');

$storeName = Mage::app()->getStore()->getName();
$storeSlug = preg_replace('/[^a-z]/', '', strtolower($storeName));
$clerkJsUrl = '://custom.clerk.io/' . $storeSlug . '.js';
?>
<script type="text/javascript">
(function(w,d){
var e=d.createElement('script');e.type='text/javascript';e.async=true;
e.src=(d.location.protocol=='https:'?'https':'http')+'://cdn.clerk.io/clerk.js';
e.src=(d.location.protocol=='https:'?'https':'http')+'<?php echo $clerkJsUrl; ?>';
var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(e,s);
w.__clerk_q=w.__clerk_q||[];w.Clerk=w.Clerk||function(){w.__clerk_q.push(arguments)};
})(window,document);
Expand Down
4 changes: 2 additions & 2 deletions design/frontend/template/tracking.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ if (Mage::helper('clerk')->getSetting('clerk/general/collect_baskets', Mage::app
}
}


$clerkJSUrl = $this->getClerkJSUrl();
?>
<script>
(function(w,d){
var e=d.createElement('script');e.type='text/javascript';e.async=true;
e.src=(d.location.protocol=='https:'?'https':'http')+'://cdn.clerk.io/clerk.js';
e.src=(d.location.protocol=='https:'?'https':'http')+'<?php echo $clerkJSUrl; ?>';
var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(e,s);
w.__clerk_q=w.__clerk_q||[];w.Clerk=w.Clerk||function(){w.__clerk_q.push(arguments)};
})(window,document);
Expand Down

0 comments on commit d86efdc

Please sign in to comment.