<script type="text/javascript">
$(window).on('load', function () {
var i = setInterval(function () {
if (mgr_api != {}) {
clearInterval(i);
const order = {
order: {{ order.id }},
order_price: {{ order.total_price }},
products: [
{% for item in order.items %}
{
id: {{ item.product.id }},
price: {{ item.total_price.with_margin }},
amount: {{ item.quantity }}
},
{% endfor %}
]
};
mgr_api.track('purchase', order);
}
}, 100);
});
</script>
<script type="text/javascript">
const mg_track_product = {
id: '{{ product.id }}',
name: '{{ product.title }}',
price: {{ product.price }},
categories: [{% for collection in product.collections %}{{ collection.id }},{% endfor %}],
image: '{{ product.first_image.compact_url }}',
url: '{{ account.url }}{{ product.canonical_url }}'
};
$(window).on('load', function () {
var i = setInterval(function () {
if (mgr_api != {}) {
clearInterval(i);
mgr_api.track("view", mg_track_product);
$('.buybutton').on('click', function () {
mgr_api.track("add_cart", mg_track_product);
});
}
}, 100);
});
</script>
<script type="text/javascript">
const mg_track_product = {
id: {% for variant in product.variants limit:1 %}'{{ variant.id }}'{% endfor %},
name: '{{ product.title }}',
price: {{ product.price }},
categories: [{% for collection in product.collections %}{{ collection.id }},{% endfor %}],
image: '{{ product.first_image.compact_url }}',
url: '{{ account.url }}{{ product.canonical_url }}'
};
$(window).on('load', function () {
var i = setInterval(function () {
if (mgr_api != {}) {
clearInterval(i);
mgr_api.track("view", mg_track_product);
$('.add-cart-counter__btn').on('click', function () {
mgr_api.track("add_cart", mg_track_product);
});
}
}, 100);
});
</script>
<script type="text/javascript">
const mg_track_product = {
email: mg_email,
item: 'переменная_id_товара', // id товара, должен совпадать с offer id в фиде, обязательный параметр
properties: {fashion_size: "", barcode: "", fashion_color: ""} // свойства товара, необязательный параметр
};
$(function () {
if (mg_email) $("#product_stock input").val(mg_email)
})
$(window).on('click', '#product_stock button', function () {
if (mgr_api != {}) {
try {
mgr_api.subscribeTrigger("product_stock", mg_track_product);
$("#product_stock small").text('Вы подписались на появление товара')
} catch (error) {
console.error(error);
$("#product_stock small").text('Ошибка подписки')
}
}
});
</script>
<form id="product_stock">
<input type="text">
<button type="button">Подписаться на появление товара</button>
<small></small>
</form>
<script type="text/javascript">
$(window).on('load', function () {
var i = setInterval(function () {
if (mgr_api != {}) {
clearInterval(i);
$('.buybutton').on('click', function () {
let mg_track_product = {
id: $(this).closest("form").attr("data-product-id")
};
mgr_api.track("add_cart", mg_track_product);
});
}
}, 100);
});
</script>
<script type="text/javascript">
$(window).on('load', function () {
var i = setInterval(function () {
if (mgr_api != {}) {
clearInterval(i);
$('.minicartdel').on('click', function () {
mgr_api.track("remove_cart", $(this).data('item-id'));
});
}
}, 100);
});
</script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
var mg_email = '';
var mgr_api = {};
(function () {
$.getJSON('/client_account/contacts.json', function(resp) {
if(resp.status !== 'error'){
mg_email = resp.client.email;
console.debug('MG track client email:', resp.client.email);
}
});
var script = document.createElement('script');
var b = '';
if (typeof this.href != "undefined") {
b = this.href.toString().toLowerCase()
} else {
b = document.location.toString().toLowerCase()
}
;
script.src = "https://mailganer.com/jsapi/r/XXX?ref=" + document.referrer + "&url=" + b + "&nc=" + Math.random();
script.async = true;
script.onload = function () {
mgr_api = new MGApi();
mgr_api.auth(mg_email);
};
document.getElementsByTagName('head')[0].appendChild(script);
})();
</script>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="{{'now' | date: '%Y-%m-%d %H:%M'}}">
<shop>
<name>{{marketplace.shop_name}}</name>
<company>{{marketplace.company}}</company>
<url>{{marketplace.url}}</url>
<platform>InSales</platform>
<currencies>
{% for currency in currencies %}
<currency id="{{currency.id}}" rate="{{currency.rate}}" {% if currency.plus %}plus="{{currency.plus}}" {% endif %} />
{% endfor %}
</currencies>
<categories>
{% for collection in collections %}
<category id="{{collection.id}}" {% if collection.parent_id %}parentId="{{collection.parent_id}}"{% endif %} url="{{marketplace.url}}/collection/{{collection.handle}}">{{collection.title}}</category>
{% endfor %}
</categories>
{% if delivery_options != empty %}
<delivery-options>
{% for option in delivery_options %}
<option cost="{{option.cost}}" days="{{option.days}}" {% if option.order-before %}order-before="{{option.order-before}}" {% endif %} />
{% endfor %}
</delivery-options>
{% endif %}
<offers>
{{content_for_layout}}
</offers>
<promos>
{% for promo in promos %}
<promo id="{{promo.id}}" type="promo code">
{% if promo.start_date %}
<start-date>{{promo.start_date}}</start-date>
{% endif %}
{% if promo.end_date %}
<end-date>{{promo.end_date}}</end-date>
{% endif %}
{% if promo.description %}
<description>{{promo.description}}</description>
{% endif %}
{% if promo.url %}
<url>{{promo.url}}</url>
{% endif %}
<promo-code>{{promo.code}}</promo-code>
<discount {% if promo.percent? %}unit="percent"{% else %}unit="currency" currency="{{currency}}"{% endif %}>
{{promo.discount}}
</discount>
<purchase>
{% for offer_id in promo.matching_offers_ids %}
<product offer-id="{{offer_id}}" />
{% endfor %}
</purchase>
</promo>
{% endfor %}
</promos>
</shop>
</yml_catalog>
<offer type="vendor.model" available="{% if product.available %}true{% else %}false{% endif %}" id="{{product.id}}" >
<url>{{account.url}}/product_by_id/{{product.id}}</url>
<price>{{product.price}}</price>
<oldprice>{{product.old_price}}</oldprice>
<currencyId>{{product.currency_id}}</currencyId>
<categoryId>{{collection.id}}</categoryId>
{%for image in product.images limit: 1 %}
<picture>{{image.url}}</picture>
{% endfor %}
<vendor>{{product.properties.vendor}}</vendor>
<model>{{product.title}}</model>
<description>{{product.description}}</description>
</offer>
{% for variant in product.variants %}
[здесь тег <offer> и его содержимое]
{% endfor %}
<offer type='vendor.model' available='{% if variant.quantity != 0 %}true{% else %}false{% endif %}' {% if product.variants.size > 1 %}id='{{ variant.id }}' group_id='{{ product.id }}'{% else %}id='{{ variant.id }}'{% endif %}>
<url>{{ account.url }}/product/{{ product.handle }}{% if product.variants.size > 1 %}?variant_id={{ variant.id }}{% endif %}</url>