Workflow with Myshopify and Google
AK

Ankit Kothari

Created Mar 23, 2022

Workflow with Myshopify and Google

113
    a

Myshopify

1 Step
1

Click on Add a new template

Click on Add a new template
    d

Google

1 Step
2

Click on product from dropdown under Create a new template for

Click on product from dropdown under Create a new template for
    a

Myshopify

6 Steps
3

Select liquid

Select liquid
4

Type "filter-primeb" and create file.

Type "filter-primeb" and create file.
5

Add the badge integration code

<!--filter_primeb-->

{% layout none %}

 {% render 'primeb', product: product, primebGroup:'1', primePageType:'collection', primebOuterStyle:'position:absolute;top:10px;right:10px;z-index:3;', primebInnerClass: 'prime-d-block prime-mb-1', hideAssets: '1'  %}

Add the badge integration code
6

Click on Snippets

Click on  Snippets
7

Click on Add a new snippet

Click on Add a new snippet
8

Type "primefilter.liquid" and click create snippet

Type "primefilter.liquid" and click create snippet
    d

Google

2 Steps
9

Paste the below code in the text area and Hit Save button

<script>

 

  document.addEventListener("DOMContentLoaded", function(event) {  

      _usfSetPrimebs();  

      setTimeout(function() {

      _usfSetPrimebs();

        window.addEventListener('globoFilterRenderCompleted', function (e) {

              _usfSetPrimebs();  

      });

      }, 2000);  

    }); 

 


function updatePrimeBadge() {

  $(".prime-temp").each(function() {

$("#prime-custom-" + $(this).attr("data-productid")).html($(this).html());

  });

}


                          

function _usfSetPrimebs() {

   var primebs = document.querySelectorAll('[data-primeb]');

 

   for (el of primebs) {

 

    _getPrimebHtml(el)

   }

setTimeout(function() {

    country = 'primebadgecountry';

     primebCountdownTimer();

      }, 1000); 

}


window._usfPrimebs = {};

function _getPrimebHtml(el) {

 

   var handle = el.getAttribute('data-primeb');

   if (!handle)

    return;

var group = el.getAttribute('data-primebgroup');

  

   if (!group)

   {

     group = "1";

   }


   if (_usfPrimebs[handle+group]) {

    el.innerHTML = _usfPrimebs[handle+group];

    el.removeAttribute('data-primeb');

    return;

   }

 

   var comp = this;

   var xhr = new XMLHttpRequest();

   

   var locale = '/'+'{{request.locale.iso_code}}';

  if({{localization.language.primary}}){

    locale = '';

}


   var url = locale+`/products/${handle}?view=filter-primeb`;


if(group == "2")

  {

    url = locale+`/products/${handle}?view=filter-primeb2`;

  }

else if(group == "3")

  {

    url = locale+`/products/${handle}?view=filter-primeb3`;

  }



   xhr.open("GET", url, true);

   xhr.setRequestHeader("Cache-Control", "max-age=3600");

   xhr.onreadystatechange = function() {

    if (this.readyState === XMLHttpRequest.DONE) {

        if (this.status === 200) {

if(this.responseText.includes('doctype'))

            {

              ;

            }

          else

          {


            _usfPrimebs[handle+group] = this.responseText;

            el.innerHTML = this.responseText;

            el.removeAttribute('data-primeb');

}

        } else {

            console.log(this.status, this.statusText);

        }

    }

   };

   xhr.send();

}


</script>


Paste the below code in the text area and Hit Save button
10

next step: Copy paste the below code in theme.liquid

Add this code at the end before  </body> and hit the save button.

{% include 'primefilter' %}

next step: Copy paste the below code in theme.liquid
    d

Google

1 Step
11

Next step: Click on globo.filter.product.liquid under Snippets folder

Next step: Click on globo.filter.product.liquid under Snippets folder
    a

Myshopify

3 Steps
12

Add below code and hit save button

Paste "<div data-primeb="{{product.handle}}" data-primebgroup="1"></div>" into text area before <a class="spf-product...">

Add below code and hit save button
13

Click on main-search.liquid under Sections folder

Click on main-search.liquid under Sections folder
14

Add the below code

Paste

{% render 'prime-css' %}

{% include 'primefilter' %}

{% render 'primeb-js' %} into text area before {% schema %}

Add the below code
Well done!
Create how-to guides like this in a snap. Get Tango now.