Zasilkovna deprecated script

Zasilkovna deprecated script

lady_blue
Shopify Partner
2 0 0

Hello guys.

 

As a user of Shopify Basic, I'm currently facing an issue with my Checkout-Configurations. Specifically:

 

configuration.png

Did some of you experience that issue, and can you help me fix it?

I am using the Zasilkovna app, and the additional script I implemented when I installed the app at checkout shows as Deprecated. Here is the script: 

 

{%- comment -%}<!-- ZASILKOVNA START -->{%- endcomment -%}
<div id="zasilkovna-additional-checkout-script" data-version="2.0" ></div> {%- comment -%} Marker for us to identify code is added{%- endcomment -%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20160511/json2.min.js"></script>
{% assign tag_selected = "zasilkovna_selected" %}
{% assign tag_fulfilled = "zasilkovna_fulfilled %}
{% assign tag_cancelled = "zasilkovna_cancelled %}
{% assign zasil_attr_name = "PickupPointName" %}
{% assign error_message = "Prosím, vyberte si znovu výdejní místo Vaší zásilky." %}
{% assign zasilkovna-method = false %}
{% assign id-prefix = "sngd" %}

{% assign shipping_method = checkout.shipping_method %}
{%- capture shipping_method_name -%}
"{{ shipping_method.title|downcase }}"
{%- endcapture -%}
{% if shipping_method_name contains "zásilkovna"%}
{% assign zasilkovna-method = true %}
{% endif %}

{% if checkout.order %}
{% for tag in checkout.order.tags%}
{% if tag == tag_fulfilled or tag == tag_cancelled %}
{% assign zasilkovna-method = false %}
{% endif %}
{% endfor %}
{% endif %}

{% for attr in checkout.attributes%}
{% assign attr_name =attr|first %}
{% if attr_name == zasil_attr_name %}
{% assign zasil_name = attr|last %}
{% assign pickup_point=zasil_name %}
{% endif %}
{% endfor %}

{% if checkout.order and checkout.order.attributes %}
{% for attr in checkout.order.attributes%}
{% assign attr_name =attr|first %}
{% if attr_name == zasil_attr_name %}
{% assign zasil_name = attr|last %}
{% assign pickup_point=zasil_name %}
{% endif %}
{% endfor %}

{%endif%}

{%if zasilkovna-method %}
{% assign order-hmac = checkout.order_id | hmac_sha256:"jN6ngkqK3Gt6mCrIZZR7Q7vqUv86mOA2" %}
{% assign oparams = "?order=" | append: checkout.order_id | append: "&hmac=" | append: order-hmac %}


<div id="{{id-prefix}}-modal-wrap">
<div id="{{id-prefix}}-modal-content">
<div id="{{id-prefix}}-loader">
</div>
</div>
</div>

<style>
@keyframes {{id-prefix}}-spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

#{{id-prefix}}-modal-wrap {
position: fixed;
z-index: 4;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}

#{{id-prefix}}-modal-content {
position: absolute;
left: 50%;
top: 20%;
}

#{{id-prefix}}-loader {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 120px;
height: 120px;
position: absolute;
left: -76px;
animation: {{id-prefix}}-spin 2s linear infinite;
}
</style>

{%- unless zasil_name -%}
<script src="https://widget.packeta.com/v6/www/js/library.js"></script>
{%- endunless -%}
<script type="text/javascript">

function packetaCallback(extendedPoint) {
if(extendedPoint == null) {
hideSpinner();
return;
}
showSpinner();
var ep = JSON.stringify(extendedPoint, undefined, 2);

var zasil_id = encodeURIComponent(extendedPoint.id);
var zasil_name = encodeURIComponent(extendedPoint.name);
var xhttp = new XMLHttpRequest();
xhttp.open('GET', 'https://us-central1-dkh-sga-zasilkovna-shopify.cloudfunctions.net/dropoff{{oparams}}' + '&zid=' + zasil_id + '&zname=' + zasil_name + '&shop={{shop.permanent_domain|url_encode}}', true);
xhttp.addEventListener('readystatechange', function () {
if (xhttp.readyState === 4) {
if(Math.floor(xhttp.status / 100) != 2) {
if(!alert("{{error_message}}")) location.reload();
} else {
location.reload();
}
}
});
xhttp.send();
}

var hideSpinner = function(){
var x = document.getElementById("{{id-prefix}}-modal-wrap");
x.style.display = "none";
}
var showSpinner = function(){
var x = document.getElementById("{{id-prefix}}-modal-wrap");
x.style.display = "block";
}

window.openZasil = function() {

Packeta.Widget.pick('9c9081cc08e0ac69', packetaCallback);

return false;
}
</script>
<script type="text/javascript">
{%- if zasil_name -%}
Shopify.Checkout.OrderStatus.addContentBox(
'<h2>Zásilka je na cestě!</h2>',
'<p>Vaši zásilku posíláme na pobočku zásilkovny {{pickup_point}}.</p>');
hideSpinner();
{%- else -%}
Shopify.Checkout.OrderStatus.addContentBox(
'<h2>Vyžaduje se zásilka!</h2>',
'<p><a class="" href="#" onclick="window.openZasil()">Vyberte si pobočku Zásilkovnu, kam pošleme Vaši zásilku.</a></p>');
openZasil();
{%- endif -%}
</script>

{%endif%}

{%- comment -%}<!-- ZASILKOVNA END -->{%- endcomment -%}

 

Is it possible just to rewrite the script, or what can be a solution for my issue?

Thank you for any help

Replies 3 (3)

Taknify
Shopify Partner
274 19 29

Contact the app to see if they have an updated code using Shopify Extensions or Web Pixels to be replaced for this current code. 
Shopify sent out that their checkout is being deprecated long ago and now the additional scripts wouldn't work and is being replaced with something called Web Pixels. 
There is not much we can do other than finding alternative do what your code is doing which is: Allowing customers to choose a pickup point for their order. Handles the selection process and communicates the user selection back to their app, and updates the order status page with information.

Need to tweak your store for Black Friday? Simply, send me a message.
lady_blue
Shopify Partner
2 0 0

Thank you

Sam_Mahmud
Shopify Partner
295 9 18

Hello Lady_blue,

As the additional script is not going to work anymore you have to track the purchase via customer event custom pixel. create a custom pixel and paste the datalyer to track the purchase and see the event in the datalayer. 

 

 

 

Your COFFEE TIP! Can Create something incredible!
Require Assistance with website design or enhanced conversion tracking Via Google Tag Manager GTM ?
sam.analyst4@gmail.com! or WhatsApp!
Solved? accept it as solution with like