PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) - Version 7.1.11

Version Description

Download this release

Release Info

Developer PixelYourSite
Plugin Icon 128x128 PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads)
Version 7.1.11
Comparing to
See all releases

Code changes from version 7.1.10 to 7.1.11

facebook-pixel-master.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: PixelYourSite
5
  * Plugin URI: http://www.pixelyoursite.com/
6
  * Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
7
- * Version: 7.1.10
8
  * Author: PixelYourSite
9
  * Author URI: http://www.pixelyoursite.com
10
  * License: GPLv3
4
  * Plugin Name: PixelYourSite
5
  * Plugin URI: http://www.pixelyoursite.com/
6
  * Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
7
+ * Version: 7.1.11
8
  * Author: PixelYourSite
9
  * Author URI: http://www.pixelyoursite.com
10
  * License: GPLv3
includes/class-events-manager.php CHANGED
@@ -155,15 +155,16 @@ class EventsManager {
155
 
156
  if ( isWooCommerceActive() && PYS()->getOption( 'woo_enabled' ) ) {
157
  $this->setupWooCommerceEvents();
158
- if(count(EventsManager::$facebookServerEvents)>0 && Facebook()->enabled()) {
159
- Facebook()->trackEventByServerApi(EventsManager::$facebookServerEvents);
160
- }
161
  }
162
 
163
  if ( isEddActive() && PYS()->getOption( 'edd_enabled' ) ) {
164
  $this->setupEddEvents();
165
  }
166
 
 
 
 
167
  }
168
 
169
  /**
@@ -214,6 +215,13 @@ class EventsManager {
214
  'ids' => $ids,
215
  );
216
 
 
 
 
 
 
 
 
217
  }
218
 
219
  }
155
 
156
  if ( isWooCommerceActive() && PYS()->getOption( 'woo_enabled' ) ) {
157
  $this->setupWooCommerceEvents();
158
+
 
 
159
  }
160
 
161
  if ( isEddActive() && PYS()->getOption( 'edd_enabled' ) ) {
162
  $this->setupEddEvents();
163
  }
164
 
165
+ if(count(EventsManager::$facebookServerEvents)>0 && Facebook()->enabled()) {
166
+ Facebook()->trackEventByServerApi(EventsManager::$facebookServerEvents);
167
+ }
168
  }
169
 
170
  /**
215
  'ids' => $ids,
216
  );
217
 
218
+ // fire fb server api event
219
+ if(Facebook()->enabled() && $pixel->getSlug() == "facebook" && $eventType == 'edd_purchase') {
220
+ if($eventData != null) {
221
+ $this->addEventToFacebookServerApi(Facebook(),'edd_purchase',$eventData);
222
+ }
223
+ }
224
+
225
  }
226
 
227
  }
includes/functions-common.php CHANGED
@@ -234,134 +234,136 @@ function getAvailableProductCog($product_id) {
234
 
235
  }
236
 
237
- function getAvailableProductCogOrder($order_id) {
238
- $order = wc_get_order( $order_id );
239
- $orderData = $order->get_data();
240
- $order_shipping_total = $orderData['shipping_total'];
241
- $order_total = $order->get_total();
242
- $cost = 0;
243
- $notice = '';
244
- $custom_total = 0;
245
- $cat_isset = 0;
246
- foreach ( $order->get_items() as $item_id => $item ) {
247
- $parent_id = false;
248
- if (isset( $item['variation_id'] ) && 0 != $item['variation_id']) {
249
- $parent_id = $item['product_id'];
250
- }
251
- $product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
252
- $cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
253
- $product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
254
- if ($parent_id && $product_cost == '') {
255
- $product_cost = get_post_meta( $parent_id, '_pixel_cost_of_goods_cost_val', true );
256
- }
257
- $price = get_post_meta($product_id, '_regular_price', true);
258
- $qlt = $item['quantity'];
259
- if ($product_cost) {
260
- $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
261
- $custom_total = $custom_total + ($price * $qlt);
262
- } else {
263
- $product_cost = get_product_cost_by_cat( $product_id );
264
- $cost_type = get_product_type_by_cat( $product_id );
265
- if ($product_cost) {
266
- $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
267
- $custom_total = $custom_total + ($price * $qlt);
268
- $notice = "Category Cost of Goods was used for some products.";
269
- $cat_isset = 1;
270
- } else {
271
- $product_cost = get_option( '_pixel_cost_of_goods_cost_val');
272
- $cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
273
- if ($product_cost) {
274
- $cost = ($cost_type == 'percent') ? (float) $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
275
- $custom_total = $custom_total + ($price * $qlt);
276
- if ($cat_isset == 1) {
277
- $notice = "Global and Category Cost of Goods was used for some products.";
278
- } else {
279
- $notice = "Global Cost of Goods was used for some products.";
280
- }
281
- } else {
282
- $notice = "Some products don't have Cost of Goods.";
283
- }
284
- }
285
- }
286
- }
287
- if (($order_total - $cost - $order_shipping_total) > 0) {
288
- $profit = $order_total - $cost - $order_shipping_total;
289
- } else {
290
- $profit = '';
291
- }
292
- if ('' !== $notice) {
293
- if (($custom_total - $cost) > 0) {
294
- $profit = $custom_total - $cost;
295
- } else {
296
- $profit = '';
297
- }
298
- }
299
 
300
- return $profit;
301
 
302
  }
303
 
304
- function getAvailableProductCogCart($amount) {
305
- $cart_total = $amount;
306
- $cost = 0;
307
- $notice = '';
308
- $custom_total = 0;
309
- $cat_isset = 0;
310
- foreach ( WC()->cart->cart_contents as $cart_item_key => $item ) {
311
- $parent_id = false;
312
- if (isset( $item['variation_id'] ) && 0 != $item['variation_id']) {
313
- $parent_id = $item['product_id'];
314
- }
315
- $product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
316
- $cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
317
- $product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
318
- if ($parent_id && $product_cost == '') {
319
- $product_cost = get_post_meta( $parent_id, '_pixel_cost_of_goods_cost_val', true );
320
- }
321
- $price = get_post_meta($product_id, '_regular_price', true);
322
- $qlt = $item['quantity'];
323
- if ($product_cost) {
324
- $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
325
- $custom_total = $custom_total + ($price * $qlt);
326
- } else {
327
- $product_cost = get_product_cost_by_cat( $product_id );
328
- $cost_type = get_product_type_by_cat( $product_id );
329
- if ($product_cost) {
330
- $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
331
- $custom_total = $custom_total + ($price * $qlt);
332
- $notice = "Category Cost of Goods was used for some products.";
333
- $cat_isset = 1;
334
- } else {
335
- $product_cost = get_option( '_pixel_cost_of_goods_cost_val');
336
- $cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
337
- if ($product_cost) {
338
- $cost = ($cost_type == 'percent') ? $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
339
- $custom_total = $custom_total + ($price * $qlt);
340
- if ($cat_isset == 1) {
341
- $notice = "Global and Category Cost of Goods was used for some products.";
342
- } else {
343
- $notice = "Global Cost of Goods was used for some products.";
344
- }
345
- } else {
346
- $notice = "Some products don't have Cost of Goods.";
347
- }
348
- }
349
- }
350
- }
351
- if (($cart_total - $cost) > 0) {
352
- $profit = $cart_total - $cost;
353
- } else {
354
- $profit = '';
355
- }
356
- if ('' !== $notice) {
357
- if (($custom_total - $cost) > 0) {
358
- $profit = $custom_total - $cost;
359
- } else {
360
- $profit = '';
361
- }
362
- }
 
 
 
 
363
 
364
- return $profit;
365
 
366
  }
367
 
234
 
235
  }
236
 
237
+ function getAvailableProductCogOrder($order) {
238
+
239
+ $cost = 0;
240
+ $notice = '';
241
+ $custom_total = 0;
242
+ $cat_isset = 0;
243
+ $isWithoutTax = get_option( '_pixel_cog_tax_calculating') == 'no';
244
+
245
+ $shipping = $order->get_shipping_total("edit");
246
+ $order_total = $order->get_total('edit') - $shipping;
247
+
248
+ if($isWithoutTax) {
249
+ $order_total -= $order->get_total_tax('edit');
250
+ } else {
251
+ $order_total -= $order->get_shipping_tax("edit");
252
+ }
253
+
254
+ foreach ( $order->get_items() as $item_id => $item ) {
255
+ $product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
256
+ $cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
257
+ $product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
258
+
259
+ $product = wc_get_product($product_id);
260
+ $args = array( 'qty' => 1, 'price' => $product->get_price());
261
+ $qlt = $item['quantity'];
262
+
263
+ if($isWithoutTax) {
264
+ $price = wc_get_price_excluding_tax($product, $args);
265
+ } else {
266
+ $price = wc_get_price_including_tax($product,$args);
267
+ }
268
+
269
+ if ($product_cost) {
270
+ $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
271
+ $custom_total = $custom_total + ($price * $qlt);
272
+ } else {
273
+ $product_cost = get_product_cost_by_cat( $product_id );
274
+ $cost_type = get_product_type_by_cat( $product_id );
275
+ if ($product_cost) {
276
+ $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
277
+ $custom_total = $custom_total + ($price * $qlt);
278
+ $notice = "Category Cost of Goods was used for some products.";
279
+ $cat_isset = 1;
280
+ } else {
281
+ $product_cost = get_option( '_pixel_cost_of_goods_cost_val');
282
+ $cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
283
+ if ($product_cost) {
284
+ $cost = ($cost_type == 'percent') ? (float) $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
285
+ $custom_total = $custom_total + ($price * $qlt);
286
+ if ($cat_isset == 1) {
287
+ $notice = "Global and Category Cost of Goods was used for some products.";
288
+ } else {
289
+ $notice = "Global Cost of Goods was used for some products.";
290
+ }
291
+ } else {
292
+ $notice = "Some products don't have Cost of Goods.";
293
+ }
294
+ }
295
+ }
296
+ }
 
 
297
 
298
+ return $order_total - $cost;
299
 
300
  }
301
 
302
+ function getAvailableProductCogCart() {
303
+ $cart_total = 0.0;
304
+ $cost = 0;
305
+ $notice = '';
306
+ $custom_total = 0;
307
+ $cat_isset = 0;
308
+ $isWithoutTax = get_option( '_pixel_cog_tax_calculating') == 'no';
309
+
310
+ $shipping = WC()->cart->get_shipping_total();
311
+ $cart_total = WC()->cart->get_total('edit') - $shipping;
312
+
313
+ if($isWithoutTax) {
314
+ $cart_total -= WC()->cart->get_total_tax();
315
+ } else {
316
+ $cart_total -= WC()->cart->get_shipping_tax();
317
+ }
318
+
319
+ foreach ( WC()->cart->cart_contents as $cart_item_key => $item ) {
320
+ $product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
321
+ $cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
322
+
323
+ $product = wc_get_product($product_id);
324
+
325
+ $args = array( 'qty' => 1, 'price' => $product->get_price());
326
+ if($isWithoutTax) {
327
+ $price = wc_get_price_excluding_tax($product, $args);
328
+ } else {
329
+ $price = wc_get_price_including_tax($product,$args);
330
+ }
331
+ $qlt = $item['quantity'];
332
+
333
+
334
+ $product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
335
+
336
+
337
+ if ($product_cost) {
338
+ $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
339
+ $custom_total = $custom_total + ($price * $qlt);
340
+ } else {
341
+ $product_cost = get_product_cost_by_cat( $product_id );
342
+ $cost_type = get_product_type_by_cat( $product_id );
343
+ if ($product_cost) {
344
+ $cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
345
+ $custom_total = $custom_total + ($price * $qlt);
346
+ $notice = "Category Cost of Goods was used for some products.";
347
+ $cat_isset = 1;
348
+ } else {
349
+ $product_cost = get_option( '_pixel_cost_of_goods_cost_val');
350
+ $cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
351
+ if ($product_cost) {
352
+ $cost = ($cost_type == 'percent') ? $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
353
+ $custom_total = $custom_total + ($price * $qlt);
354
+ if ($cat_isset == 1) {
355
+ $notice = "Global and Category Cost of Goods was used for some products.";
356
+ } else {
357
+ $notice = "Global Cost of Goods was used for some products.";
358
+ }
359
+ } else {
360
+ $notice = "Some products don't have Cost of Goods.";
361
+ }
362
+ }
363
+ }
364
+ }
365
 
366
+ return $cart_total - $cost;
367
 
368
  }
369
 
includes/functions-woo.php CHANGED
@@ -80,94 +80,133 @@ function getWooCartSubtotal() {
80
 
81
  }
82
 
83
- function getWooEventValue( $valueOption, $amount, $global, $product_id = null, $percent = 100 ) {
84
-
85
- switch ( $valueOption ) {
86
- case 'global':
87
- $value = (float) $global;
88
- break;
89
-
90
- case 'cog':
91
- $cog = getAvailableProductCog($product_id);
92
- if ($cog['val']){
93
- if ($cog['type'] == 'fix') {
94
- $value = round((float) $amount - (float) $cog['val'], 2);
95
- } else {
96
- $value = round((float) $amount - ( (float) $amount * (float) $cog['val'] / 100 ), 2);
97
- }
98
- } else {
99
- $value = (float) $amount;
100
- }
101
- if ( !isPixelCogActive() ) $value = (float) $amount;
102
- break;
103
-
104
- case 'percent':
105
- $percents = (float) $percent;
106
- $percents = str_replace( '%', null, $percents );
107
- $percents = (float) $percents / 100;
108
- $value = (float) $amount * $percents;
109
- break;
110
-
111
- default: // "price" option
112
- $value = (float) $amount;
113
- }
114
-
115
- return $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- function getWooEventValueOrder( $valueOption, $amount, $global, $order_id, $content_ids, $percent = 100 ) {
120
-
121
- switch ( $valueOption ) {
122
- case 'global':
123
- $value = (float) $global;
124
- break;
125
-
126
- case 'cog':
127
- $cog_value = getAvailableProductCogOrder($order_id);
128
- ($cog_value !== '') ? $value = (float) round($cog_value, 2) : $value = (float) $amount;
129
- if ( !isPixelCogActive() ) $value = (float) $amount;
130
- break;
131
-
132
- case 'percent':
133
- $percents = (float) $percent;
134
- $percents = str_replace( '%', null, $percents );
135
- $percents = (float) $percents / 100;
136
- $value = (float) $amount * $percents;
137
- break;
138
 
139
- default: // "price" option
140
- $value = (float) $amount;
141
- }
142
 
143
- return $value;
 
 
 
144
 
145
- }
 
 
146
 
147
- function getWooEventValueCart( $valueOption, $amount, $global, $percent = 100 ) {
 
148
 
149
- switch ( $valueOption ) {
150
- case 'global':
151
- $value = (float) $global;
152
- break;
153
 
154
- case 'cog':
155
- $cog_value = getAvailableProductCogCart($amount);
156
- ($cog_value !== '') ? $value = (float) round($cog_value, 2) : $value = (float) $amount;
157
- if ( !isPixelCogActive() ) $value = (float) $amount;
158
- break;
159
 
160
- case 'percent':
161
- $percents = (float) $percent;
162
- $percents = str_replace( '%', null, $percents );
163
- $percents = (float) $percents / 100;
164
- $value = (float) $amount * $percents;
165
- break;
166
 
167
- default: // "price" option
168
- $value = (float) $amount;
169
- }
 
 
 
170
 
171
- return $value;
 
 
172
 
 
173
  }
80
 
81
  }
82
 
83
+ function getWooEventValue( $valueOption, $global, $percent, $product_id,$qty ) {
84
+
85
+ $product = wc_get_product($product_id);
86
+
87
+ if(!$product) return 0;
88
+
89
+ if($valueOption == 'cog' && isPixelCogActive()) {
90
+
91
+ $args = array( 'qty' => $qty, 'price' => $product->get_price());
92
+ if(get_option( '_pixel_cog_tax_calculating') == 'no') {
93
+ $amount = wc_get_price_excluding_tax($product, $args);
94
+ } else {
95
+ $amount = wc_get_price_including_tax($product,$args);
96
+ }
97
+
98
+ $cog = getAvailableProductCog($product_id);
99
+
100
+ if ($cog['val']) {
101
+ if ($cog['type'] == 'fix') {
102
+ $value = round((float)$amount - (float)$cog['val'], 2);
103
+ } else {
104
+ $value = round((float)$amount - ((float)$amount * (float)$cog['val'] / 100), 2);
105
+ }
106
+ } else {
107
+ $value = (float)$amount;
108
+ }
109
+ return $value;
110
+ }
111
+
112
+ if ( PYS()->getOption( 'woo_event_value' ) == 'custom' ) {
113
+ $amount = getWooProductPrice( $product_id, $qty );
114
+ } else {
115
+ $amount = getWooProductPriceToDisplay( $product_id, $qty );
116
+ }
117
+
118
+ switch ( $valueOption ) {
119
+ case 'global': $value = $global; break;
120
+ case 'percent':
121
+ $percents = (float) $percent;
122
+ $percents = str_replace( '%', null, $percents );
123
+ $percents = (float) $percents / 100;
124
+ $value = (float) $amount * $percents;
125
+ break;
126
+ default:$value = (float)$amount;
127
+ }
128
+
129
+ return $value;
130
 
131
  }
132
+ /**
133
+ * @param $valueOption
134
+ * @param \WC_Order $order
135
+ * @param $global
136
+ * @param $order_id
137
+ * @param $content_ids
138
+ * @param int $percent
139
+ * @return float|int
140
+ */
141
+ function getWooEventValueOrder( $valueOption, $order, $global, $percent = 100 ) {
142
+
143
+ if ( PYS()->getOption( 'woo_event_value' ) == 'custom' ) {
144
+ $amount = getWooOrderTotal( $order );
145
+ } else {
146
+ $amount = $order->get_total();
147
+ }
148
+ switch ( $valueOption ) {
149
+ case 'global':
150
+ $value = (float) $global;
151
+ break;
152
+
153
+ case 'cog':
154
+ $cog_value = getAvailableProductCogOrder($order);
155
+ ($cog_value !== '') ? $value = (float) round($cog_value, 2) : $value = (float) $amount;
156
+ if ( !isPixelCogActive() ) $value = (float) $amount;
157
+ break;
158
+
159
+ case 'percent':
160
+ $percents = (float) $percent;
161
+ $percents = str_replace( '%', null, $percents );
162
+ $percents = (float) $percents / 100;
163
+ $value = (float) $amount * $percents;
164
+ break;
165
+
166
+ default: // "price" option
167
+ $value = (float) $amount;
168
+ }
169
+
170
+ return $value;
171
 
172
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
+ function getWooEventValueCart( $valueOption, $global, $percent = 100 ) {
 
 
175
 
176
+ if($valueOption == 'cog' && isPixelCogActive()) {
177
+ $cog_value = getAvailableProductCogCart();
178
+ if($cog_value !== '')
179
+ return (float) round($cog_value, 2) ;
180
 
181
+ if ( get_option( '_pixel_cog_tax_calculating') == 'no' ) {
182
+ return WC()->cart->cart_contents_total;
183
+ }
184
 
185
+ return WC()->cart->cart_contents_total + WC()->cart->tax_total;
186
+ }
187
 
 
 
 
 
188
 
189
+ if ( PYS()->getOption( 'woo_event_value' ) == 'custom' ) {
190
+ $amount = getWooCartTotal();
191
+ } else {
192
+ $amount = $params['value'] = WC()->cart->subtotal;
193
+ }
194
 
195
+ switch ( $valueOption ) {
196
+ case 'global':
197
+ $value = (float) $global;
198
+ break;
 
 
199
 
200
+ case 'percent':
201
+ $percents = (float) $percent;
202
+ $percents = str_replace( '%', null, $percents );
203
+ $percents = (float) $percents / 100;
204
+ $value = (float) $amount * $percents;
205
+ break;
206
 
207
+ default: // "price" option
208
+ $value = (float) $amount;
209
+ }
210
 
211
+ return $value;
212
  }
includes/views/html-main-general.php CHANGED
@@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
32
  target="_blank">pro version</a>.</p>
33
  </div>
34
  </div>
35
- <?php if(isWooCommerceActive()) : ?>
36
  <div class="row align-items-center mb-3">
37
  <div class="col-3">
38
 
@@ -45,7 +45,7 @@ if ( ! defined( 'ABSPATH' ) ) {
45
  ); ?>
46
  <?php Facebook()->render_text_area_array_item("server_access_api_token","Api token") ?>
47
  <small class="form-text">
48
- This is an experimental feature and for now works only for the WooCommerce Purchase event.
49
  </small>
50
  </div>
51
  </div>
@@ -71,7 +71,7 @@ if ( ! defined( 'ABSPATH' ) ) {
71
  <?php endif; ?>
72
  <hr>
73
 
74
- <?php endif; ?>
75
 
76
  <?php if ( GA()->enabled() ) : ?>
77
 
32
  target="_blank">pro version</a>.</p>
33
  </div>
34
  </div>
35
+
36
  <div class="row align-items-center mb-3">
37
  <div class="col-3">
38
 
45
  ); ?>
46
  <?php Facebook()->render_text_area_array_item("server_access_api_token","Api token") ?>
47
  <small class="form-text">
48
+ This is an experimental feature and works only for the WooCommerce Purchase and CompleteRegistration events, and Easy Digital Downloads Purchase event.
49
  </small>
50
  </div>
51
  </div>
71
  <?php endif; ?>
72
  <hr>
73
 
74
+
75
 
76
  <?php if ( GA()->enabled() ) : ?>
77
 
modules/facebook/PYSServerEventHelper.php CHANGED
@@ -107,7 +107,7 @@ class ServerEventHelper {
107
  * Add purchase WooCommerce Advanced Matching params
108
  */
109
 
110
- if ( is_order_received_page() && isset( $_REQUEST['key'] ) ) {
111
 
112
  $order_key = sanitize_key($_REQUEST['key']);
113
  $order_id = wc_get_order_id_by_order_key( $order_key );
107
  * Add purchase WooCommerce Advanced Matching params
108
  */
109
 
110
+ if ( PixelYourSite\isWooCommerceActive() && is_order_received_page() && isset( $_REQUEST['key'] ) ) {
111
 
112
  $order_key = sanitize_key($_REQUEST['key']);
113
  $order_id = wc_get_order_id_by_order_key( $order_key );
modules/facebook/facebook.php CHANGED
@@ -393,14 +393,12 @@ class Facebook extends Settings implements Pixel {
393
 
394
  // currency, value
395
  if ( PYS()->getOption( 'woo_view_content_value_enabled' ) ) {
396
-
397
- $amount = getWooProductPriceToDisplay( $post->ID );
398
-
399
  $value_option = PYS()->getOption( 'woo_view_content_value_option' );
400
  $global_value = PYS()->getOption( 'woo_view_content_value_global', 0 );
401
 
402
 
403
- $params['value'] = getWooEventValue( $value_option, $amount, $global_value, $post->ID );
404
  $params['currency'] = get_woocommerce_currency();
405
 
406
  }
@@ -617,11 +615,11 @@ class Facebook extends Settings implements Pixel {
617
 
618
  $params['num_items'] = $num_items;
619
 
620
- $amount = $order->get_total();
621
  $value_option = PYS()->getOption( 'woo_purchase_value_option' );
622
  $global_value = PYS()->getOption( 'woo_purchase_value_global', 0 );
623
 
624
- $params['value'] = getWooEventValueOrder( $value_option, $amount, $global_value, $order_id, $content_ids );
625
  $params['currency'] = get_woocommerce_currency();
626
  //$params['transaction_id'] = $order_id;
627
  $params['eventID'] = $order_id;
@@ -883,6 +881,7 @@ class Facebook extends Settings implements Pixel {
883
 
884
  $params['currency'] = edd_get_currency();
885
  $params['value'] = edd_get_payment_amount( $payment_id );
 
886
 
887
  }
888
 
393
 
394
  // currency, value
395
  if ( PYS()->getOption( 'woo_view_content_value_enabled' ) ) {
396
+
 
 
397
  $value_option = PYS()->getOption( 'woo_view_content_value_option' );
398
  $global_value = PYS()->getOption( 'woo_view_content_value_global', 0 );
399
 
400
 
401
+ $params['value'] = getWooEventValue( $value_option, $global_value,100, $post->ID ,1);
402
  $params['currency'] = get_woocommerce_currency();
403
 
404
  }
615
 
616
  $params['num_items'] = $num_items;
617
 
618
+
619
  $value_option = PYS()->getOption( 'woo_purchase_value_option' );
620
  $global_value = PYS()->getOption( 'woo_purchase_value_global', 0 );
621
 
622
+ $params['value'] = getWooEventValueOrder( $value_option, $order, $global_value );
623
  $params['currency'] = get_woocommerce_currency();
624
  //$params['transaction_id'] = $order_id;
625
  $params['eventID'] = $order_id;
881
 
882
  $params['currency'] = edd_get_currency();
883
  $params['value'] = edd_get_payment_amount( $payment_id );
884
+ $params['eventID'] = $payment_id;
885
 
886
  }
887
 
modules/facebook/function-helpers.php CHANGED
@@ -291,12 +291,11 @@ function getWooSingleAddToCartParams( $product_id, $qty = 1 ) {
291
 
292
  // currency, value
293
  if ( PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_enabled' ) ) {
294
-
295
- $amount = PixelYourSite\getWooProductPriceToDisplay( $product_id, $qty );
296
  $value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
297
  $global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
298
 
299
- $params['value'] = PixelYourSite\getWooEventValue( $value_option, $amount, $global_value, $product_id );
300
  $params['currency'] = get_woocommerce_currency();
301
 
302
  }
@@ -392,12 +391,11 @@ function getWooCartParams( $context = 'cart' ) {
392
  }
393
 
394
  if ( PixelYourSite\PYS()->getOption( $value_enabled_option ) ) {
395
-
396
- $amount = $params['value'] = WC()->cart->subtotal;
397
  $value_option = PixelYourSite\PYS()->getOption( $value_option_option );
398
  $global_value = PixelYourSite\PYS()->getOption( $value_global_option, 0 );
399
 
400
- $params['value'] = PixelYourSite\getWooEventValueCart( $value_option, $amount, $global_value );
401
  $params['currency'] = get_woocommerce_currency();
402
 
403
  }
@@ -561,13 +559,13 @@ function getCompleteRegistrationOrderParams() {
561
  $order_id = (int) wc_get_order_id_by_order_key( $order_key );
562
  $order = new \WC_Order( $order_id );
563
 
564
- $amount = $order->get_total();
565
  $value_option = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_custom_value' );
566
  $global_value = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_global_value', 0 );
567
  $percents_value = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_percent_value', 100 );
568
 
569
  $params['eventID'] = $order_id;
570
- $params['value'] = PixelYourSite\getWooEventValueOrder( $value_option, $amount, $global_value, $order_id, "", $percents_value );
571
  $params['currency'] = get_woocommerce_currency();
572
  return $params;
573
  }
291
 
292
  // currency, value
293
  if ( PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_enabled' ) ) {
294
+
 
295
  $value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
296
  $global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
297
 
298
+ $params['value'] = PixelYourSite\getWooEventValue( $value_option, $global_value,100, $product_id,$qty );
299
  $params['currency'] = get_woocommerce_currency();
300
 
301
  }
391
  }
392
 
393
  if ( PixelYourSite\PYS()->getOption( $value_enabled_option ) ) {
394
+
 
395
  $value_option = PixelYourSite\PYS()->getOption( $value_option_option );
396
  $global_value = PixelYourSite\PYS()->getOption( $value_global_option, 0 );
397
 
398
+ $params['value'] = PixelYourSite\getWooEventValueCart( $value_option, $global_value );
399
  $params['currency'] = get_woocommerce_currency();
400
 
401
  }
559
  $order_id = (int) wc_get_order_id_by_order_key( $order_key );
560
  $order = new \WC_Order( $order_id );
561
 
562
+
563
  $value_option = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_custom_value' );
564
  $global_value = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_global_value', 0 );
565
  $percents_value = PixelYourSite\Facebook()->getOption( 'woo_complete_registration_percent_value', 100 );
566
 
567
  $params['eventID'] = $order_id;
568
+ $params['value'] = PixelYourSite\getWooEventValueOrder( $value_option, $order, $global_value, $percents_value );
569
  $params['currency'] = get_woocommerce_currency();
570
  return $params;
571
  }
pixelyoursite.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
- define( 'PYS_FREE_VERSION', '7.1.10' );
8
  define( 'PYS_FREE_PINTEREST_MIN_VERSION', '2.0.6' );
9
  define( 'PYS_FREE_BING_MIN_VERSION', '1.0.0' );
10
  define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
+ define( 'PYS_FREE_VERSION', '7.1.11' );
8
  define( 'PYS_FREE_PINTEREST_MIN_VERSION', '2.0.6' );
9
  define( 'PYS_FREE_BING_MIN_VERSION', '1.0.0' );
10
  define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: PixelYourSite, themister
3
  Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Easy Digital Downloads Pixel, Easy Digital Downloads Google Analytics, Head & Footer scripts, Enhanced Ecommerce, Pinterest tag
4
  Requires at least: 3.0.1
5
  Requires PHP: 5.4
6
- Tested up to: 5.4
7
- Stable tag: 7.1.10
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -391,6 +391,15 @@ NO, absolutely not! We don't track any type of data about your website. We simpl
391
  == Changelog ==
392
 
393
 
 
 
 
 
 
 
 
 
 
394
  = PixelYourSite 7.1.10 =
395
 
396
  * Small improvements related to "Facebook for WooCommerce" ID logic.
3
  Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Easy Digital Downloads Pixel, Easy Digital Downloads Google Analytics, Head & Footer scripts, Enhanced Ecommerce, Pinterest tag
4
  Requires at least: 3.0.1
5
  Requires PHP: 5.4
6
+ Tested up to: 5.5
7
+ Stable tag: 7.1.11
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
391
  == Changelog ==
392
 
393
 
394
+ = PixelYourSite 7.1.11 =
395
+
396
+ * FIX: Facebook Pixel server-side events token field was missing for Easy Digital Downloads.
397
+
398
+ * FIX: Possible error when [Cost of Goods](https://www.pixelyoursite.com/plugins/woocommerce-cost-of-goods) value was used for WooCommerce Facebook Pixel events.
399
+
400
+ * Wordpress 5.5 compatibility.
401
+
402
+
403
  = PixelYourSite 7.1.10 =
404
 
405
  * Small improvements related to "Facebook for WooCommerce" ID logic.