<script>
$('.product-action-cart, .product__add-to-cart').on('click', function() {
var product_id = $(this).data('product-id');
fbq('track', 'AddToCart', {
content_ids: [product_id.toString()],
content_type: 'product',
// product_catalog_id: '1',
});
});
</script>
<script>
if (window.location.href.includes('/shop/payment')) {
var product_ids = [];
$(".product-name.col-md-9").each(function (index, elem) {
var id = $(elem).data("product-id");
if (!!id) {
product_ids.push(id.toString());
}
});
var price_total = $('span[data-oe-expression="order_total_price"] .oe_currency_value').text();
price_total = price_total.replace(/\./gi, "")
fbq('track', 'InitiateCheckout', {
content_ids: product_ids,
content_type: 'product',
value: price_total,
currency: 'VND'
});
};
</script>
<script>
if (window.location.href.includes('/shop/payment')) {
$('.cart__total-checkout-btn').one('click', function (e) {
e.preventDefault();
var product_ids = [];
$(".product-name.col-md-9").each(function (index, elem) {
var id = $(elem).data("product-id");
if (!!id) {
product_ids.push(id.toString());
}
});
var price_total = $('.cart__total-price span[data-oe-expression="order_total_price"] .oe_currency_value').text();
price_total = parseFloat(price_total.replace(",", ""));
fbq('track', 'Purchase', {
content_ids: product_ids,
content_type: 'product',
value: price_total || 0.0,
currency: 'VND'
});
$(this).click();
});
};
</script>
<script>
var product_ids = [];
$(".product-name").each(function(index, elem) {
var id = $(elem).data("product-id");
product_ids.push(id.toString());
});
product_ids = $.unique(product_ids);
fbq('track', 'ViewContent', {
content_type : "product",
content_ids : product_ids,
});
</script>