PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Http/Routes/WebRoutes.php +41 -3 1.3.21 → 1.6.5 View file →
@@ -29,11 +29,19 @@
29 29 {
30 30 public static function register()
31 31 {
32 32
33 + // Late on init, deliberately. These routes do not merely register — they
34 + // TAKE OVER the request, render a full page and die(). At the default
35 + // priority this callback is queued at plugin-include time, so it runs
36 + // before anything that registers on init from `fluentcart_loaded` (every
37 + // add-on, including FluentCart Pro). A route that renders and dies before
38 + // those listeners exist silently drops whatever they would have rendered
39 + // — which is why the saved-payment-method picker and the save-my-card
40 + // consent box appeared on the checkout page but never in modal checkout.
33 41 add_action('init', function () {
34 42 self::registerRoutes();
35 - });
43 + }, 99);
36 44 }
37 45
38 46 public static function renderModalCheckout() {
39 47 add_action('wp_footer', function () {
@@ -143,9 +151,35 @@
143 151 $coupons = App::request()->get('coupons', '');
144 152 if ($coupons) {
145 153 $coupons = explode(',', $coupons);
146 154 $coupons = array_map('sanitize_text_field', $coupons);
147 - $cart->applyCoupon($coupons);
155 + $couponResult = $cart->applyCoupon($coupons);
156 +
157 +
158 + $couponErrors = [];
159 + if (is_wp_error($couponResult)) {
160 + $couponErrors[] = esc_html($couponResult->get_error_message());
161 + } elseif (is_array($couponResult)) {
162 + $perCouponResults = Arr::get($couponResult, 'coupon_results', []);
163 + foreach ($coupons as $code) {
164 + foreach ($perCouponResults as $resultCode => $result) {
165 + if (strcasecmp((string) $resultCode, (string) $code) === 0) {
166 + $errorMessage = Arr::get($result, 'error', '');
167 + if ($errorMessage !== '') {
168 + $couponErrors[] = esc_html($errorMessage);
169 + }
170 + break;
171 + }
172 + }
173 + }
174 + }
175 +
176 + if ($couponErrors) {
177 + $checkoutData = is_array($cart->checkout_data) ? $cart->checkout_data : [];
178 + $checkoutData['__checkout_error_notices'] = $couponErrors;
179 + $cart->checkout_data = $checkoutData;
180 + $cart->save();
181 + }
148 182 }
149 183
150 184 $target_path = (new StoreSettings())->getCheckoutPage();
151 185
@@ -215,9 +249,9 @@
215 249 case 'fluent_cart_payment_authenticate':
216 250 (new PayPalPartnerRenderer($request->mode))->render(
217 251 $request->all()
218 252 );
219 - break;
253 + return true;
220 254 case 'download-by-id':
221 255 case 'download-file':
222 256 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in view template
223 257 echo (new FileDownloader())->index(App::request());
@@ -333,8 +367,12 @@
333 367 }
334 368
335 369 private static function handlePrintRoute($method): bool
336 370 {
371 + if (!is_user_logged_in() || !current_user_can('manage_options')) {
372 + return false;
373 + }
374 +
337 375 $order = App::request()->get('order');
338 376 if (!empty($order)) {
339 377 PrintService::$method($order);
340 378 return true;