diff --git a/classes/rules/FilterTrapRule.php b/classes/rules/FilterTrapRule.php index 2cc4346..f9b18c2 100644 --- a/classes/rules/FilterTrapRule.php +++ b/classes/rules/FilterTrapRule.php @@ -12,9 +12,25 @@ class FilterTrapRule implements RuleInterface if (!Tools::getIsset('q') && !Tools::getIsset('order')) { return true; } - + // 1. IGNORE AJAX REQUESTS + // Redirecting an AJAX request returns HTML (the verification page) + // to a JS listener expecting JSON, which breaks the UI. + // We assume bots will hit the main URL first before firing AJAX. + if (Tools::getIsset('from-xhr') ||Tools::getIsset('ajax') || Tools::getIsset('is_ajax')) { + return true; + } $context = Context::getContext(); + // 3. CHECK FOR EXISTING SESSION (Likely Human) + // If they have a Customer ID or a Guest ID, they have interacted + // with the shop enough to establish a standard PrestaShop cookie. + if (isset($context->customer) && $context->customer->id) { + return true; + } + if (isset($context->cookie->id_guest) && $context->cookie->id_guest) { + // Optional: You could also check for items in cart to be even more sure + return true; + } // 2. Allow whitelisted Bots (Google/Bing) // We trust them not to spam. If they do, use robots.txt.