=== Add to Cart Ajax for Hello Elementor === Contributors: fahadmahmood, mklacroix, marcusig, invoicepress Tags: hello elementor, woocommerce, ajax, add to cart, product page Requires at least: 4.4 Tested up to: 7.1 Stable tag: 1.1.4 Requires PHP: 7.0 License: GPL2 License URI: http://www.gnu.org/licenses/gpl-2.0.html Add to Cart Ajax for WordPress Theme Hello Elementor / Mini Cart. == Description == * Author: [Fahad Mahmood](https://www.androidbubbles.com/contact) * Project URI: An addon for WooCommerce compatible theme "Hello Elementor", a plain-vanilla & lightweight theme for Elementor page builder. = Hello Elementor / Mini Cart = [youtube http://www.youtube.com/watch?v=epzy7j_MgFs] = Product Configurator for WooCommerce / Mini Cart = [youtube http://www.youtube.com/watch?v=koaIuUoOnrI] == Installation == 1. Upload the plugin files to the `/wp-content/plugins/` directory, or install the plugin through the WordPress plugins screen directly. 2. Activate the plugin through the 'Plugins' screen in WordPress 3. Make sure WooCommerce and the Hello Elementor theme (with the Elementor mini cart / menu cart widget) are active. 4. Open any single product page and click "Add to cart". The product is added with AJAX and the mini cart refreshes. == Frequently Asked Questions == = Can I turn AJAX add to cart off for one product? = Yes. Add a custom field `disable_ajax_add_to_cart` with the value `1` to the product. The optional pro add-on gives you a checkbox for this in the product editor. = Is there a hook for developers? = Yes. `mcafw_after_add_to_cart` runs after an add to cart request (arguments: product ID, variation ID, quantity). `mcafw_ds_added_to_cart` runs only when the item was really added (it also receives the cart item key). On the front-end the `mcafw_added_to_cart` jQuery event is triggered on `document.body` with the server response. = What is the "pro" folder? = If a `pro` folder exists inside the plugin, the premium features load automatically (plug and play). If the folder does not exist, the free version works exactly the same, without any errors. == Screenshots == 1. Compatibility List == Changelog == = 1.1.4 = * Tested up to WordPress 7.1. * Security: the add to cart request now parses and sanitizes the submitted form field by field, validates every value type, and checks that WooCommerce is available before use. * Security: script version no longer uses the current time, so browsers can cache the script. * Fix: PHP 8 compatibility for Product Configurator data (array_key_exists() on objects) and several undefined index/offset notices. * Fix: a failed AJAX request no longer leaves the page blocked and the button locked. * Fix: variable products with "any" attribute options are added with the selected attributes. * Fix: no fatal error on non-WooCommerce pages when WooCommerce is deactivated. * Enhancement: WooCommerce HPOS compatibility declared. * Enhancement: the AJAX response now includes `added` and `notices`; new `mcafw_ds_added_to_cart` action, `mcafw_ds_response`, `mcafw_ds_localize_data` and `mcafw_ds_cart_item_data` filters, and a `mcafw_added_to_cart` front-end event. * Enhancement: optional plug and play "pro" folder (settings page, toast notices, redirect after add to cart, per-product switch, statistics, add-on field support). * All existing features are unchanged. = 1.1.2 = * Enhancement: Added `mcafw_after_add_to_cart` action hook for developers to attach custom functionality after an item is added to the cart. 25/10/2025 * Improvement: Refactored AJAX handler for cleaner structure, better sanitization, and improved error handling. * Improvement: Optimized cart fragment refresh logic for faster updates on Elementor mini-cart widgets. * Tweak: Cleaned up script enqueue conditions and added nonce validation for improved security. * Dev: General code cleanup and stability improvements. = 1.1.0 = * Fix: Simple product add to cart was not working for WooCommerce default templates. 11/11/2023 [Thanks to Kashif Nadeem / RichCandies] = 1.0.9 = * Fix: jQuery blockUI related issue. 02/01/2023 [Thanks to Narinder Kumar / Dfavo] = 1.0.8 = * Updated for Mini Cart Close Button stops working. 08/07/2023 [Thanks to Humna Naeem] = 1.0.7 = * Updated for WordPress version. 24/05/2023 = 1.0.6 = * WC refresh fragments implemented instead of creating fragments manually. 05/08/2022 [Thanks Filipe Russane] = 1.0.5 = * Add to cart is not displaying in mini cart, your script is not working. 05/02/2022 = 1.0.4 = * Add to cart buttons will not work for out of stock items. 13/01/2022 = 1.0.3 = * Mini cart open icon and close icon related click event revised. 03/10/2021 = 1.0.2 = * Product Configurator for WooCommerce - compatibility added. 28/09/2021 = 1.0.1 = * Improvements regarding totals in mini cart. 27/09/2021 = 1.0.0 = * Initial commit. 27/09/2021 [Thanks to tomdimond/discoversalkan] == Upgrade Notice == = 1.1.4 = Tested with WordPress 7.1. Security hardening, PHP 8 compatibility fixes and new developer hooks. No features were removed. = 1.1.2 = This update enhances compatibility and introduces a new action hook (`mcafw_after_add_to_cart`) for better developer extensibility. Also includes security, performance, and UI update improvements. = 1.1.0 = Fix: Simple product add to cart was not working for WooCommerce default templates. = 1.0.9 = jQuery blockUI related issue. = 1.0.8 = Updated for Mini Cart Close Button stops working. = 1.0.7 = Updated for WordPress version. = 1.0.6 = WC refresh fragments implemented instead of creating fragments manually. = 1.0.5 = Add to cart is not displaying in mini cart, your script is not working. = 1.0.4 = Add to cart buttons will not work for out of stock items. = 1.0.3 = Mini cart open icon and close icon related click event revised. = 1.0.2 = Product Configurator for WooCommerce - compatibility added. = 1.0.1 = Improvements regarding totals in mini cart. = 1.0.0 = Initial commit. 27/09/2021 [Thanks to tomdimond/discoversalkan] == License == This WordPress plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. This WordPress plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this WordPress plugin. If not, see http://www.gnu.org/licenses/gpl-2.0.html.