From ffc97228b7b9bc7c9254717bf0274a64f4d8c5eb Mon Sep 17 00:00:00 2001 From: Malin Date: Thu, 5 Mar 2026 08:20:37 +0100 Subject: [PATCH] fix: stopPropagation on floating button click to prevent Shoptimizer document handler closing cart --- assets/js/floating-cart.js | 4 ++++ cgkit-floating-cart.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/floating-cart.js b/assets/js/floating-cart.js index 45fd43d..95d17c6 100644 --- a/assets/js/floating-cart.js +++ b/assets/js/floating-cart.js @@ -45,6 +45,10 @@ // --- Floating button click → open minicart ----------------------- this.$btn.on( 'click', function ( e ) { e.preventDefault(); + // Stop the click bubbling to document-level handlers. + // Shoptimizer closes the cart on any click outside .shoptimizer-cart, + // so without this the cart would open then instantly close again. + e.stopPropagation(); self.openMinicart(); } ); diff --git a/cgkit-floating-cart.php b/cgkit-floating-cart.php index a797c55..b85bcea 100644 --- a/cgkit-floating-cart.php +++ b/cgkit-floating-cart.php @@ -3,7 +3,7 @@ * Plugin Name: CommerceKit Floating Cart * Plugin URI: https://www.commercegurus.com * Description: Adds a floating cart icon (bottom-right) and auto-opens the CommerceKit minicart after add to cart. Requires CommerceGurus CommerceKit and WooCommerce. - * Version: 1.0.2 + * Version: 1.0.3 * Author: CommerceGurus * Author URI: https://www.commercegurus.com * License: GPLv3 @@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -define( 'CGKIT_FC_VERSION', '1.0.2' ); +define( 'CGKIT_FC_VERSION', '1.0.3' ); define( 'CGKIT_FC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'CGKIT_FC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );