Changeset 3344618
- Timestamp:
- 08/14/2025 11:33:44 AM (8 months ago)
- Location:
- exit-intent-popups-by-optimonk/trunk
- Files:
-
- 5 added
- 6 edited
-
README.md (added)
-
optimonk-admin.php (modified) (2 diffs)
-
optimonk-front.php (modified) (3 diffs)
-
optimonk-woo-data-injector.php (added)
-
optimonk.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
template/insert-code.js (modified) (2 diffs)
-
template/optimonk-wc-attributes.js (added)
-
template/optimonk-woo-data.js (added)
-
wc-attributes.php (modified) (4 diffs)
-
woo-version.php (added)
Legend:
- Unmodified
- Added
- Removed
-
exit-intent-popups-by-optimonk/trunk/optimonk-admin.php
r3144112 r3344618 22 22 self::$basePath = $pluginBasePath; 23 23 add_filter('plugin_action_links_' . plugin_basename(self::$basePath), array($this, 'addSettingsPageLink')); 24 add_filter('woocommerce_get_settings_general', array($this, 'registrateShopId')); 25 add_action('init', array($this, 'generateShopId')); 24 26 add_action('admin_enqueue_scripts', array($this, 'initScripts')); 25 27 add_action('admin_enqueue_scripts', array($this, 'initStyleSheet')); … … 30 32 add_action('admin_footer', array($this, 'settings_javascript')); 31 33 add_action('wp_ajax_setting_form', array($this, 'postHandler')); 34 } 35 36 public function generateShopId() { 37 if (get_option('omplugin_shop_id')) return; 38 39 $siteurl = get_option('siteurl'); 40 if (!$siteurl || strlen($siteurl) < 5) return; 41 42 $shopId = preg_replace('/^https?:\/\//', '', $siteurl) . '_' . time(); 43 44 update_option('omplugin_shop_id', $shopId); 45 } 46 47 public function registrateShopId($settings) { 48 // [GET] /wp-json/wc/v3/settings/general/omplugin_shop_id 49 50 $shopId = get_option('omplugin_shop_id'); 51 52 $settings[] = [ 53 'name' => __('UUID', 'OptiMonk'), 54 'id' => 'omplugin_shop_id', 55 'type' => 'text', 56 'default' => $shopId, 57 'desc_tip' => true, 58 'description' => 'Uniquely identify the website for the OptiMonk.', 59 'custom_attributes' => ['readonly' => 'readonly'] 60 ]; 61 62 return $settings; 32 63 } 33 64 -
exit-intent-popups-by-optimonk/trunk/optimonk-front.php
r2822087 r3344618 1 1 <?php 2 require_once(dirname(__FILE__) . "/optimonk-woo-data-injector.php"); 2 3 3 4 /** … … 31 32 $insertJavaScript = str_replace('{{siteUrl}}', $url, $insertJavaScript); 32 33 34 35 $current_url = home_url( add_query_arg( null, null ) ); 36 $dataInjector = new OptiMonkWooDataInjector(urldecode($current_url)); 37 $dataToInsert = $dataInjector->getData(); 38 39 $frontDomain = OPTIMONK_FRONT_DOMAIN; 40 33 41 echo <<<EOD 34 42 <script type="text/javascript"> 35 43 $insertJavaScript 44 $dataToInsert 36 45 </script> 37 <script type="text/javascript" src="https:// onsite.optimonk.com/script.js?account=$accountId" async></script>46 <script type="text/javascript" src="https://$frontDomain/script.js?account=$accountId" async></script> 38 47 EOD; 39 48 } … … 190 199 die(); 191 200 } 201 202 if ($pluginVar && $actionVar && 203 $wp->query_vars['plugin'] == 'optimonk' && 204 $wp->query_vars['action'] == 'addToCart') { 205 206 WcAttributes::addToCart(); 207 die(); 208 } 192 209 } 193 210 -
exit-intent-popups-by-optimonk/trunk/optimonk.php
r3144112 r3344618 5 5 Description: OptiMonk, the conversion optimization toolset crafted for marketers 6 6 Author: OptiMonk 7 Version: 2. 0.97 Version: 2.1.0 8 8 Text Domain: optimonk 9 9 Domain Path: /languages … … 11 11 License: GPLv2 12 12 */ 13 14 define('OM_PLUGIN_VERSION', '2.1.0'); 15 define('OPTIMONK_FRONT_DOMAIN', 'onsite.optimonk.com'); 13 16 14 17 if (!defined('ABSPATH')) { -
exit-intent-popups-by-optimonk/trunk/readme.txt
r3217583 r3344618 4 4 Requires at least: 2.8.0 5 5 Tested up to: 6.6.1 6 Stable tag: 2. 0.96 Stable tag: 2.1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 186 186 = Popup builder log = 187 187 188 ### 08/07/2025 189 190 - New: Support for Product Recommender algorithms like Most popular, Recently viewed in WooCommerce stores 191 - New: Support for Order tracking in WooCommerce stores 192 188 193 ### 11/12/2024 189 194 -
exit-intent-popups-by-optimonk/trunk/template/insert-code.js
r3123233 r3344618 18 18 19 19 function setCartData(cartData, adapter) { 20 adapter.Cart.clear();21 22 cartData.cart.forEach(cartItem => {23 adapter.Cart.add(cartItem.sku, {quantity: cartItem.quantity, price: cartItem.price, name: cartItem.name});24 });25 20 Object.keys(cartData.avs).forEach((key, value) => { 26 21 adapter.attr(`wp_${key}`, cartData.avs[key]); … … 84 79 setAssocData(pvData, adapter); 85 80 86 if (OptiMonk.campaigns.filter(campaign => campaign.hasVisitorCartRules()).length) {87 observeAjaxCartActions(adapter);88 fetchCart(adapter);89 }90 91 81 if (OptiMonk.campaigns.filter(campaign => campaign.hasVisitorAttributeRules()).length) { 92 82 makePostRequest("{{siteUrl}}/index.php?plugin=optimonk&action=productData", { body }) -
exit-intent-popups-by-optimonk/trunk/wc-attributes.php
r2814225 r3344618 1 1 <?php 2 require_once(dirname(__FILE__) . "/woo-version.php"); 3 2 4 class WcAttributes { 3 5 public static function getCartVariables() { 4 6 echo json_encode(self::getWooCommerceCartData()); 5 7 } 8 9 public static function addToCart() { 10 if ( ! class_exists( 'WooCommerce' ) ) { 11 wp_send_json_error( array( 'message' => 'WooCommerce is not active' ) ); 12 return; 13 } 14 15 $product_id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0; 16 $quantity = isset( $_POST['quantity'] ) ? absint( $_POST['quantity'] ) : 1; 17 $variation_id = isset( $_POST['variation_id'] ) ? absint( $_POST['variation_id'] ) : 0; 18 $variation = isset( $_POST['variation'] ) ? $_POST['variation'] : array(); 19 20 if ( ! $product_id ) { 21 wp_send_json_error( array( 'message' => 'Invalid product ID' ) ); 22 return; 23 } 24 25 $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation ); 26 27 if ( $cart_item_key ) { 28 WC()->cart->calculate_totals(); 29 30 wp_send_json_success( array( 31 'cart_item_key' => $cart_item_key, 32 'cart_count' => WC()->cart->get_cart_contents_count(), 33 'cart_total' => WC()->cart->get_cart_total(), 34 'message' => sprintf( '%s added to your cart.', get_the_title( $product_id ) ) 35 ) ); 36 } else { 37 wp_send_json_error( array( 'message' => 'Failed to add product to cart' ) ); 38 } 39 40 wp_die(); 41 } 42 6 43 7 44 public static function getVariables( $url ) { … … 25 62 ); 26 63 27 if ( self::isWooCommerce() === false ) {64 if ( WooVersion::isWooCommerce() === false ) { 28 65 return $return; 29 66 } … … 44 81 $item_tax = $line_subtotal_tax / $quantity; 45 82 $price = $item_price + $item_tax; 46 47 $ identifier = $product->get_sku() ? $product->get_sku() : $product->get_id();83 $productId = $product->get_id(); 84 $sku = $product->get_sku(); 48 85 49 86 $return['cart'][] = array( 50 'sku' => $identifier, 87 'id' => $productId, 88 'sku' => $sku, 51 89 'name' => $product_name, 52 90 'price' => $price, … … 112 150 113 151 protected static function isWooCommerceProductPage($post) { 114 return self::isWooCommerce() && get_post_type($post) === 'product'; 115 } 116 117 protected static function isWooCommerce() { 118 global $woocommerce; 119 120 if ( 121 isset( $woocommerce ) === false 122 || class_exists( '\WC_Product' ) === false 123 ) { 124 return false; 125 } 126 127 return true; 152 return WooVersion::isWooCommerce() && get_post_type($post) === 'product'; 128 153 } 129 154 130 155 protected static function wpbo_get_woo_version_number() { 131 // If get_plugins() isn't available, require it 132 if ( ! function_exists( 'get_plugins' ) ) 133 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 134 135 // Create the plugins folder and file variables 136 $plugin_folder = get_plugins( '/' . 'woocommerce' ); 137 $plugin_file = 'woocommerce.php'; 138 139 // If the plugin version number is set, return it 140 if ( isset( $plugin_folder[$plugin_file]['Version'] ) ) { 141 return $plugin_folder[$plugin_file]['Version']; 142 143 } else { 144 // Otherwise return null 145 return NULL; 146 } 156 WooVersion::wpbo_get_woo_version_number(); 147 157 } 148 158 }
Note: See TracChangeset
for help on using the changeset viewer.