Skip to content

Commit

Permalink
Merge pull request #78 from DripEmail/eci-1896-use-php-helper-to-dete…
Browse files Browse the repository at this point in the history
…ct-product-views

[ECI-1896] Use php helper to detect product views
  • Loading branch information
wstrinz authored Sep 12, 2023
2 parents 02956f4 + ef9a523 commit 6a3a531
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drip.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Plugin Name: Drip for WooCommerce
Plugin URI: https://github.com/DripEmail/drip-woocommerce
Description: A WordPress plugin to connect to Drip's WooCommerce integration
Version: 1.1.5
Version: 1.1.6
Author: Drip
Author URI: https://www.drip.com/
License: GPLv2
Expand Down
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: getdrip
Tags: ecommerce, emailmarketing, marketingautomation, emailmarketingautomation, woocommerce, drip
Requires at least: 4.6
Tested up to: 6.2.2
Stable tag: 1.1.5
Stable tag: 1.1.6
Requires PHP: 5.6
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -47,7 +47,7 @@ Install the official Drip for WooCommerce plugin. See why thousands of ecommerce

=== Do you offer a free trial? ===

Yes, we offer a free 14-day trial for new users. Sign up for a free trial today (no credit card needed): [https://www.getdrip.com/signup/basic](https://www.getdrip.com/signup/basic)
Yes, we offer a free 14-day trial for new users. Sign up for a free trial today (no credit card needed): [https://www.getdrip.com/signup/basic](https://www.getdrip.com/signup/basic)

=== How much does Drip cost? ===

Expand All @@ -73,6 +73,11 @@ The philosophy behind this plugin is to do as little as possible in it, and as m
= NEXT =

* Your change here!

= 1.1.6 =

* Use a more robust method for detecting product view events

= 1.1.5 =

* Fix bug when calling get_cart function before WP finishes loading
Expand Down
14 changes: 11 additions & 3 deletions src/class-drip-woocommerce-view-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ public static function init() {
/**
* Start processing view actions
*/
public function setup_view_actions() {
add_action( 'woocommerce_after_single_product', array( $this, 'drip_woocommerce_viewed_product' ), 10 );
public function setup_view_actions()
{
add_action('wp_enqueue_scripts', array($this, 'conditionally_enqueue_scripts'));
}

public function conditionally_enqueue_scripts()
{
if (is_product()) {
$this->drip_woocommerce_viewed_product();
}
}

/**
* Handler for woocommerce_after_single_product action
* Handler for product viewed action
*/
public function drip_woocommerce_viewed_product() {
wp_register_script( 'Drip product view tracking', plugin_dir_url( __FILE__ ) . 'product_view_tracking.js', array(), '1', true );
Expand Down

0 comments on commit 6a3a531

Please sign in to comment.