first commit
This commit is contained in:
20
modules/ps_facebook/views/js/app.js
Normal file
20
modules/ps_facebook/views/js/app.js
Normal file
File diff suppressed because one or more lines are too long
121
modules/ps_facebook/views/js/chunk-vendors.js
Normal file
121
modules/ps_facebook/views/js/chunk-vendors.js
Normal file
File diff suppressed because one or more lines are too long
48
modules/ps_facebook/views/js/front/conversion-api.js
Normal file
48
modules/ps_facebook/views/js/front/conversion-api.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
prestashop.on('updateProduct', function (params) {
|
||||
if (params.eventType === 'updatedProductCombination') {
|
||||
var productId = $('input[name="id_product"]').val();
|
||||
var $productAttributes = $(params.event.handleObj.selector);
|
||||
var attributes = [];
|
||||
$productAttributes.each(function (key, attribute) {
|
||||
if ($(attribute).is("input") && !$(attribute).is(':checked')) {
|
||||
return;
|
||||
}
|
||||
attributes.push($(attribute).val());
|
||||
})
|
||||
ajaxProductCombinationChange(productId, attributes);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function ajaxProductCombinationChange(productId, attributes) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: prestashopFacebookAjaxController,
|
||||
data: {
|
||||
action: 'CustomizeProduct',
|
||||
ajax: true,
|
||||
id_product: productId,
|
||||
attribute_ids: attributes,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
28
modules/ps_facebook/views/js/front/index.php
Normal file
28
modules/ps_facebook/views/js/front/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_facebook/views/js/index.php
Normal file
28
modules/ps_facebook/views/js/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
92
modules/ps_facebook/views/js/printpixel.js
Normal file
92
modules/ps_facebook/views/js/printpixel.js
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
function ajaxGetProduct(id, attribute) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: pixel_fc,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'GetProduct',
|
||||
ajax: true,
|
||||
id_product: id,
|
||||
id_attribute: attribute,
|
||||
},
|
||||
success: function(data) {
|
||||
var iso_code = prestashop.currency.iso_code,
|
||||
amount = data.price_amount;
|
||||
|
||||
fbq('track', 'AddToCart', {value: amount, currency: iso_code});
|
||||
},
|
||||
error: function(err) {}
|
||||
});
|
||||
}
|
||||
|
||||
// support 1.6 version
|
||||
if (typeof(prestashop) == 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Track Add to cart
|
||||
prestashop.on('updateCart', function(params) {
|
||||
if (
|
||||
typeof(params) !== 'undefined'
|
||||
&& typeof(prestashop.cart) !== 'undefined'
|
||||
) {
|
||||
var iso_code = prestashop.currency.iso_code,
|
||||
products = prestashop.cart.products,
|
||||
my_id = params.reason.idProduct,
|
||||
my_attribute = params.reason.idProductAttribute,
|
||||
my_link = params.reason.linkAction;
|
||||
|
||||
if (my_link != 'delete-from-cart') {
|
||||
|
||||
// Keep ajax call
|
||||
// ajaxGetProduct(my_id, my_attribute);
|
||||
|
||||
// Find product
|
||||
var search_product = $.grep(products, function(e){
|
||||
return e.id_product == my_id && e.id_product_attribute == my_attribute;
|
||||
});
|
||||
|
||||
if (products.length != 0) {
|
||||
var amount = search_product[0].price_wt;
|
||||
fbq('track', 'AddToCart', { value: amount, currency: iso_code, content_ids: my_id, content_type: "product" });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Track CustomizeProduct event for PS1.7
|
||||
prestashop.on('updatedProduct', function(params) {
|
||||
if (typeof(params) !== 'undefined') {
|
||||
fbq('track', 'CustomizeProduct');
|
||||
}
|
||||
})
|
||||
|
||||
//Track product added to a wishlist
|
||||
prestashop.on('wishlistEventBusInit', () => {
|
||||
window.WishlistEventBus.$on('addedToWishlist', (params) => {
|
||||
fbq('track', 'AddToWishlist', {id_produit: params.detail.idProduct, content_type: "product"});
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user