Version Description
Facebook pixel change for AddToCart event
Download this release
Release Info
Developer | jorisverwater |
Plugin | Product Feed PRO for WooCommerce |
Version | 8.0.5 |
Comparing to | |
See all releases |
Code changes from version 8.0.4 to 8.0.5
- js/woosea_add_cart.js +0 -100
- readme.txt +7 -1
- woocommerce-sea.php +27 -25
js/woosea_add_cart.js
CHANGED
@@ -1,100 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
|
3 |
-
//localStorage.removeItem("attributes");
|
4 |
-
$( "select" ).change(function() {
|
5 |
-
|
6 |
-
//localStorage.removeItem("attributes");
|
7 |
-
var productId = $('input[name=product_id]').val();
|
8 |
-
var selectedName = $(this).attr("name");
|
9 |
-
var selectedValue = $(this).find('option:selected').text();
|
10 |
-
var storedAttributes = JSON.parse(localStorage.getItem("attributes"));
|
11 |
-
|
12 |
-
// Already saved a selection in local storage
|
13 |
-
if(storedAttributes){
|
14 |
-
// Only add new selections to the local storage
|
15 |
-
var len_value = selectedValue.length;
|
16 |
-
if(len_value > 0){
|
17 |
-
storedAttributes[selectedName] = selectedValue;
|
18 |
-
localStorage.setItem("attributes", JSON.stringify(storedAttributes));
|
19 |
-
}
|
20 |
-
} else {
|
21 |
-
var json_attributes = new Object();
|
22 |
-
json_attributes.productId = productId;
|
23 |
-
json_attributes[selectedName] = selectedValue;
|
24 |
-
localStorage.setItem("attributes", JSON.stringify(json_attributes));
|
25 |
-
}
|
26 |
-
|
27 |
-
var storedAttributes = JSON.parse(localStorage.getItem("attributes"));
|
28 |
-
|
29 |
-
// Now AJAX call to save in options
|
30 |
-
var inputdata = {
|
31 |
-
'action': 'woosea_storedattributes_details',
|
32 |
-
'data_to_pass': productId,
|
33 |
-
'storedAttributes': storedAttributes,
|
34 |
-
'nonce': frontEndAjax.nonce
|
35 |
-
}
|
36 |
-
|
37 |
-
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
38 |
-
}, 'json' );
|
39 |
-
|
40 |
-
console.log(storedAttributes);
|
41 |
-
});
|
42 |
-
|
43 |
-
// For shop pages
|
44 |
-
$(".add_to_cart_button").click(function(){
|
45 |
-
var productId = $(this).attr('data-product_id');
|
46 |
-
|
47 |
-
console.log("Facebook Pixel by AdTribes.io - 1");
|
48 |
-
console.log(productId);
|
49 |
-
|
50 |
-
// Ajax frontend
|
51 |
-
var inputdata = {
|
52 |
-
'action': 'woosea_addtocart_details',
|
53 |
-
'data_to_pass': productId,
|
54 |
-
'nonce': frontEndAjax.nonce
|
55 |
-
}
|
56 |
-
|
57 |
-
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
58 |
-
fbq("track", "AddToCart", {
|
59 |
-
content_ids: "['" + response.product_id + "']",
|
60 |
-
content_name: response.product_name,
|
61 |
-
content_category: response.product_cats,
|
62 |
-
content_type: "product",
|
63 |
-
value: response.product_price,
|
64 |
-
currency: response.product_currency,
|
65 |
-
});
|
66 |
-
}, 'json' );
|
67 |
-
});
|
68 |
-
|
69 |
-
// For product pages
|
70 |
-
$(".single_add_to_cart_button").click(function(){
|
71 |
-
var productId = $('input[name=product_id]').val();
|
72 |
-
|
73 |
-
console.log("Facebook Pixel by AdTribes.io - 2");
|
74 |
-
|
75 |
-
if(!productId){
|
76 |
-
productId = $(this).attr('value');
|
77 |
-
}
|
78 |
-
|
79 |
-
console.log(productId);
|
80 |
-
|
81 |
-
// Ajax frontend
|
82 |
-
var inputdata = {
|
83 |
-
'action': 'woosea_addtocart_details',
|
84 |
-
'data_to_pass': productId,
|
85 |
-
'nonce': frontEndAjax.nonce
|
86 |
-
}
|
87 |
-
|
88 |
-
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
89 |
-
|
90 |
-
fbq("track", "AddToCart", {
|
91 |
-
content_ids: "['" + response.product_id + "']",
|
92 |
-
content_name: response.product_name,
|
93 |
-
content_category: response.product_cats,
|
94 |
-
content_type: "product",
|
95 |
-
value: response.product_price,
|
96 |
-
currency: response.product_currency,
|
97 |
-
});
|
98 |
-
}, 'json' );
|
99 |
-
});
|
100 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
|
|
5 |
Tags: Product Feed, Google Shopping, Google Shopping Feed, WooCommerce Product Feed, WooCommerce Product Feed PRO, Bing Shopping, Bing product feed, Bing remarking, Google Merchant Feed, Google DRM Feed, Google Dynamic Remarketing Feed, Facebook feed, Google feed, Bing feed, Facebook Product Feed, Facebook Dynamic remarketing, Data Feed, WooCommerce Feed, XML product feed, CSV product feed, TSV, TXT product feed, comparison shopping engines, comparison shopping websites, vergelijk.nl, vergelijk.be, vertaa.fi, beslist.nl, kieskeurig.nl, bol.com, raketten, pricerunner, pricegrabber, Buy, leGuide, Kelkoo, Twenga, Yandex, Etsy, Dealtime, Shopzilla, Billiger, Google Product Review feed
|
6 |
Requires at least: 4.5
|
7 |
Tested up to: 5.4
|
8 |
-
Stable tag: 8.0.
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -313,6 +313,9 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
|
|
313 |
|
314 |
=== Changelog ===
|
315 |
|
|
|
|
|
|
|
316 |
= 8.0.4 (2020-04-23) =
|
317 |
* Facebook pixel code change for variable products
|
318 |
|
@@ -2562,6 +2565,9 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
|
|
2562 |
|
2563 |
== Upgrade Notice ==
|
2564 |
|
|
|
|
|
|
|
2565 |
= 8.0.4 =
|
2566 |
Facebook pixel code change for variable products
|
2567 |
|
5 |
Tags: Product Feed, Google Shopping, Google Shopping Feed, WooCommerce Product Feed, WooCommerce Product Feed PRO, Bing Shopping, Bing product feed, Bing remarking, Google Merchant Feed, Google DRM Feed, Google Dynamic Remarketing Feed, Facebook feed, Google feed, Bing feed, Facebook Product Feed, Facebook Dynamic remarketing, Data Feed, WooCommerce Feed, XML product feed, CSV product feed, TSV, TXT product feed, comparison shopping engines, comparison shopping websites, vergelijk.nl, vergelijk.be, vertaa.fi, beslist.nl, kieskeurig.nl, bol.com, raketten, pricerunner, pricegrabber, Buy, leGuide, Kelkoo, Twenga, Yandex, Etsy, Dealtime, Shopzilla, Billiger, Google Product Review feed
|
6 |
Requires at least: 4.5
|
7 |
Tested up to: 5.4
|
8 |
+
Stable tag: 8.0.5
|
9 |
|
10 |
== Description ==
|
11 |
|
313 |
|
314 |
=== Changelog ===
|
315 |
|
316 |
+
= 8.0.5 (2020-04-24) =
|
317 |
+
* Facebook pixel change for AddToCart event
|
318 |
+
|
319 |
= 8.0.4 (2020-04-23) =
|
320 |
* Facebook pixel code change for variable products
|
321 |
|
2565 |
|
2566 |
== Upgrade Notice ==
|
2567 |
|
2568 |
+
= 8.0.5 =
|
2569 |
+
Facebook pixel change for AddToCart event
|
2570 |
+
|
2571 |
= 8.0.4 =
|
2572 |
Facebook pixel code change for variable products
|
2573 |
|
woocommerce-sea.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Product Feed PRO for WooCommerce
|
4 |
-
* Version: 8.0.
|
5 |
* Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
|
6 |
* Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
|
7 |
* Author: AdTribes.io
|
@@ -48,7 +48,7 @@ if (!defined('ABSPATH')) {
|
|
48 |
* Plugin versionnumber, please do not override.
|
49 |
* Define some constants
|
50 |
*/
|
51 |
-
define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '8.0.
|
52 |
define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
|
53 |
define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
|
54 |
|
@@ -405,7 +405,7 @@ function woosea_add_facebook_pixel( $product = null ){
|
|
405 |
$fb_price = $fb_lowprice;
|
406 |
}
|
407 |
}
|
408 |
-
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product\", content_ids:[$fb_prodid], value:\"$fb_price\", currency:\"$currency\"});";
|
409 |
} else {
|
410 |
// This is a parent variable product
|
411 |
// Since these are not allowed in the feed, at the variations product ID's
|
@@ -432,15 +432,14 @@ function woosea_add_facebook_pixel( $product = null ){
|
|
432 |
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product_group\", content_ids:[$content], value:\"$fb_price\", currency:\"$currency\"});";
|
433 |
}
|
434 |
} else {
|
|
|
435 |
$fb_price = wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
|
436 |
-
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product\", content_ids:[$fb_prodid], value:\"$fb_price\", currency:\"$currency\"});";
|
437 |
}
|
438 |
}
|
439 |
}
|
440 |
} elseif ($fb_pagetype == "cart"){
|
441 |
-
|
442 |
// This is on the order thank you page
|
443 |
-
// if(!empty($_GET)){
|
444 |
if( isset( $_GET['key'] ) && is_wc_endpoint_url( 'order-received' ) ) {
|
445 |
$order_string = sanitize_text_field($_GET['key']);
|
446 |
if(!empty($order_string)){
|
@@ -475,26 +474,29 @@ function woosea_add_facebook_pixel( $product = null ){
|
|
475 |
$checkoutpage = wc_get_checkout_url();
|
476 |
$current_url = get_permalink(get_the_ID());
|
477 |
|
478 |
-
if(
|
479 |
-
|
480 |
-
$
|
481 |
-
|
482 |
-
$
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
|
|
|
|
488 |
|
489 |
-
|
490 |
-
|
491 |
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
498 |
}
|
499 |
}
|
500 |
}
|
@@ -553,7 +555,7 @@ function woosea_add_facebook_pixel( $product = null ){
|
|
553 |
}
|
554 |
}
|
555 |
$fb_prodid = rtrim($fb_prodid, ",");
|
556 |
-
$viewContent = "fbq(\"trackCustom\",\"Search\",{search_string:\"$search_string\", content_type:\"product\", content_ids:\"[$fb_prodid]\"});";
|
557 |
} else {
|
558 |
// This is another page than a product page
|
559 |
$viewContent = "";
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Product Feed PRO for WooCommerce
|
4 |
+
* Version: 8.0.5
|
5 |
* Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
|
6 |
* Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
|
7 |
* Author: AdTribes.io
|
48 |
* Plugin versionnumber, please do not override.
|
49 |
* Define some constants
|
50 |
*/
|
51 |
+
define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '8.0.5' );
|
52 |
define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
|
53 |
define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
|
54 |
|
405 |
$fb_price = $fb_lowprice;
|
406 |
}
|
407 |
}
|
408 |
+
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product\", content_ids:[\"$fb_prodid\"], value:\"$fb_price\", currency:\"$currency\"});";
|
409 |
} else {
|
410 |
// This is a parent variable product
|
411 |
// Since these are not allowed in the feed, at the variations product ID's
|
432 |
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product_group\", content_ids:[$content], value:\"$fb_price\", currency:\"$currency\"});";
|
433 |
}
|
434 |
} else {
|
435 |
+
// This is a simple product page
|
436 |
$fb_price = wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
|
437 |
+
$viewContent = "fbq(\"track\",\"ViewContent\",{content_category:\"$cats\", content_name:\"$product_name\", content_type:\"product\", content_ids:[\"$fb_prodid\"], value:\"$fb_price\", currency:\"$currency\"});";
|
438 |
}
|
439 |
}
|
440 |
}
|
441 |
} elseif ($fb_pagetype == "cart"){
|
|
|
442 |
// This is on the order thank you page
|
|
|
443 |
if( isset( $_GET['key'] ) && is_wc_endpoint_url( 'order-received' ) ) {
|
444 |
$order_string = sanitize_text_field($_GET['key']);
|
445 |
if(!empty($order_string)){
|
474 |
$checkoutpage = wc_get_checkout_url();
|
475 |
$current_url = get_permalink(get_the_ID());
|
476 |
|
477 |
+
if(!empty($cart_items)){
|
478 |
+
if( !is_wp_error( $cart_items )) {
|
479 |
+
foreach( $cart_items as $cart_id => $cart_item) {
|
480 |
+
$prod_id = $cart_item['product_id'];
|
481 |
+
if($cart_item['variation_id'] > 0){
|
482 |
+
$prod_id = $cart_item['variation_id'];
|
483 |
+
}
|
484 |
+
$contents .= '\''.$prod_id.'\',';
|
485 |
+
//$contents .= "$prod_id,";
|
486 |
+
$line_total = $cart_item['line_total'];
|
487 |
+
$line_tax = $cart_item['line_tax'];
|
488 |
+
$cart_real = number_format(($line_total+$line_tax),2)+$cart_real;
|
489 |
|
490 |
+
}
|
491 |
+
$contents = rtrim($contents, ",");
|
492 |
|
493 |
+
// User is on the billing pages
|
494 |
+
if($checkoutpage == $current_url){
|
495 |
+
$viewContent = "fbq(\"track\",\"InitiateCheckout\",{currency:\"$currency\", value:\"$cart_real\", content_type:\"product\", content_ids:[$contents]});";
|
496 |
+
} else {
|
497 |
+
// User is on the basket page
|
498 |
+
$viewContent = "fbq(\"track\",\"AddToCart\",{currency:\"$currency\", value:\"$cart_real\", content_type:\"product\", content_ids:[$contents]});";
|
499 |
+
}
|
500 |
}
|
501 |
}
|
502 |
}
|
555 |
}
|
556 |
}
|
557 |
$fb_prodid = rtrim($fb_prodid, ",");
|
558 |
+
$viewContent = "fbq(\"trackCustom\",\"Search\",{search_string:\"$search_string\", content_type:\"product\", content_ids:\"[\"$fb_prodid\"]\"});";
|
559 |
} else {
|
560 |
// This is another page than a product page
|
561 |
$viewContent = "";
|