CTX Feed – WooCommerce Product Feed Manager Plugin - Version 4.3.55

Version Description

(2021-03-28) = * Added: Addtocart in cart & product page added and removed ajax addtocart event.

Download this release

Release Info

Developer wahid0003
Plugin Icon 128x128 CTX Feed – WooCommerce Product Feed Manager Plugin
Version 4.3.55
Comparing to
See all releases

Code changes from version 4.3.54 to 4.3.55

Files changed (3) hide show
  1. README.txt +4 -1
  2. includes/helper.php +43 -53
  3. woo-feed.php +2 -2
README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: Product Feed, WooCommerce, Google Shopping, Google Merchant, Facebook Cata
5
  Requires at least: 3.6
6
  Tested Up To: 5.7
7
  Requires PHP: 5.6
8
- Stable tag: 4.3.54
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -498,6 +498,9 @@ Using pro version:
498
 
499
  == Changelog ==
500
 
 
 
 
501
  = 4.3.54 (2021-03-25) =
502
  * Added: Compatibility for Dynamic Pricing With Discount Rules by Acowebs.
503
  * Fixed: Pattern label updated.
5
  Requires at least: 3.6
6
  Tested Up To: 5.7
7
  Requires PHP: 5.6
8
+ Stable tag: 4.3.55
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
498
 
499
  == Changelog ==
500
 
501
+ = 4.3.55 (2021-03-28) =
502
+ * Added: Addtocart in cart & product page added and removed ajax addtocart event.
503
+
504
  = 4.3.54 (2021-03-25) =
505
  * Added: Compatibility for Dynamic Pricing With Discount Rules by Acowebs.
506
  * Fixed: Pattern label updated.
includes/helper.php CHANGED
@@ -3529,8 +3529,6 @@ if ( ! function_exists('woo_feed_pixel_script') ) {
3529
  add_action('wp_head', 'woo_feed_pixel_script');
3530
  }
3531
 
3532
-
3533
-
3534
  if ( ! function_exists('woo_feed_addtocart') ) {
3535
  /**
3536
  * Woo Feed Add to Cart
@@ -3540,20 +3538,51 @@ if ( ! function_exists('woo_feed_addtocart') ) {
3540
  $settings = woo_feed_get_options('all');
3541
  $disable_pixel = $settings['disable_pixel'];
3542
  $pixel_id = $settings['pixel_id'];
 
 
3543
 
3544
  // Add to Cart Tracking
3545
  if ( 'enable' == $disable_pixel && ! empty( $pixel_id ) ) {
3546
 
3547
  if ( isset($_POST['add-to-cart']) ) {
3548
  $product_id = ! empty($_POST['add-to-cart']) ? $_POST['add-to-cart'] : "";
3549
- $product = wc_get_product( (int)$product_id);
3550
- if ( $product instanceof WC_Product ) {
3551
- $product_name = $product->get_title();
3552
- $product_id = $product->get_id();
3553
- $product_price = $product->get_price();
3554
- $currency = get_option('woocommerce_currency');
3555
-
3556
- $view_type = "<script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3557
  fbq('track', 'AddToCart', {
3558
  content_name: '$product_name',
3559
  content_ids: $product_id,
@@ -3561,54 +3590,15 @@ if ( ! function_exists('woo_feed_addtocart') ) {
3561
  value: $product_price,
3562
  currency: '$currency',});
3563
  </script>";
 
3564
 
 
 
 
3565
  echo $view_type;
3566
  }
3567
  }
3568
 
3569
- ?>
3570
- <script>
3571
- let woo_feed_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';
3572
-
3573
- //product page add to cart
3574
- jQuery(document).on("click", ".add_to_cart_button", function(event) {
3575
- event.preventDefault();
3576
- let product_id = jQuery(this).data('product_id');
3577
- woo_feed_add_to_cart_pixel(product_id);
3578
- });
3579
-
3580
- //single page add to cart
3581
- jQuery(document).on("click", ".single_add_to_cart_button", function(event) {
3582
- let product_id = jQuery(this).attr('value');
3583
- woo_feed_add_to_cart_pixel(product_id);
3584
-
3585
- });
3586
-
3587
- //add product data to facebook pixel during add to cart
3588
- function woo_feed_ajax_add_to_cart_pixel(product_id) {
3589
- if( product_id ) {
3590
- let data = {
3591
- action: 'add_to_cart_pixel',
3592
- product_id: product_id
3593
- };
3594
-
3595
- jQuery.post(woo_feed_ajax_url, data, function(response) {
3596
- if( !jQuery.isEmptyObject(response) ) {
3597
- fbq('track', 'AddToCart', {
3598
- content_name: response.name,
3599
- content_ids: response.id,
3600
- content_type: 'product',
3601
- value: response.price,
3602
- currency: response.currency,
3603
- });
3604
- }
3605
-
3606
- }, 'json');
3607
- }
3608
- }
3609
-
3610
- </script>
3611
- <?php
3612
  }
3613
  }
3614
  add_action('wp_head', 'woo_feed_addtocart');
3529
  add_action('wp_head', 'woo_feed_pixel_script');
3530
  }
3531
 
 
 
3532
  if ( ! function_exists('woo_feed_addtocart') ) {
3533
  /**
3534
  * Woo Feed Add to Cart
3538
  $settings = woo_feed_get_options('all');
3539
  $disable_pixel = $settings['disable_pixel'];
3540
  $pixel_id = $settings['pixel_id'];
3541
+ $product = '';
3542
+ $view_type = '';
3543
 
3544
  // Add to Cart Tracking
3545
  if ( 'enable' == $disable_pixel && ! empty( $pixel_id ) ) {
3546
 
3547
  if ( isset($_POST['add-to-cart']) ) {
3548
  $product_id = ! empty($_POST['add-to-cart']) ? $_POST['add-to-cart'] : "";
3549
+ $product = wc_get_product( (int) $product_id);
3550
+ }
3551
+
3552
+ //when redirect to cart page after add to cart
3553
+ if( 'yes' === get_option('woocommerce_cart_redirect_after_add') ) {
3554
+ if( is_cart() ) {
3555
+ global $woocommerce;
3556
+
3557
+ //get cart items
3558
+ $items = $woocommerce->cart->get_cart();
3559
+
3560
+ $ids = array();
3561
+ if( $items && is_array($items) ) {
3562
+ foreach($items as $item => $values) {
3563
+ $_product = wc_get_product( $values['data']->get_id());
3564
+ $ids[] = $_product->get_id();
3565
+ }
3566
+
3567
+ if( !empty($ids) ) {
3568
+ //get last product id in cart
3569
+ $last_product_id = end($ids);
3570
+ $product = wc_get_product( (int) $last_product_id );
3571
+ // error_log("last inserted product id is: " . $last_product_id);
3572
+ }
3573
+ }
3574
+
3575
+ }
3576
+ }
3577
+
3578
+ //create addtocart script
3579
+ if ( !empty($product) && $product instanceof WC_Product ) {
3580
+ $product_name = $product->get_title();
3581
+ $product_id = $product->get_id();
3582
+ $product_price = $product->get_price();
3583
+ $currency = get_option('woocommerce_currency');
3584
+
3585
+ $view_type = "<script>
3586
  fbq('track', 'AddToCart', {
3587
  content_name: '$product_name',
3588
  content_ids: $product_id,
3590
  value: $product_price,
3591
  currency: '$currency',});
3592
  </script>";
3593
+ }
3594
 
3595
+ //show addtocart script
3596
+ if( is_cart() || is_product() ) {
3597
+ if( !empty($view_type) ) {
3598
  echo $view_type;
3599
  }
3600
  }
3601
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3602
  }
3603
  }
3604
  add_action('wp_head', 'woo_feed_addtocart');
woo-feed.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: CTX Feed
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
- * Version: 4.3.54
14
  * Author: WebAppick
15
  * Author URI: https://webappick.com/
16
  * License: GPL v2
@@ -39,7 +39,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
39
  * @var string
40
  * @since 3.1.6
41
  */
42
- define( 'WOO_FEED_FREE_VERSION', '4.3.54' );
43
  }
44
 
45
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
10
  * Plugin Name: CTX Feed
11
  * Plugin URI: https://webappick.com/
12
  * Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
13
+ * Version: 4.3.55
14
  * Author: WebAppick
15
  * Author URI: https://webappick.com/
16
  * License: GPL v2
39
  * @var string
40
  * @since 3.1.6
41
  */
42
+ define( 'WOO_FEED_FREE_VERSION', '4.3.55' );
43
  }
44
 
45
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {