Black Friday 2026 50% off every plan Our biggest deal of the year on #1 Joomla products.
Ends in 15d 08h 06m 59s
Claim 50% off
Staff replied EasyStore Joomla 6 v3.1.1

SettingsModel::getRegionByCountry()` Returns No Shipping Methods When Region States Are Configured

Asked by Philip S. Hempel 1 week ago Last activity 1 week ago

SettingsModel::getRegionByCountry()` Returns No Shipping Methods When Region States Are Configured

  • Product: JoomShaper EasyStore (com_easystore)
  • Product Version: 3.1.1
  • Joomla Version: 6.2.0 (PHP 8.4)
  • File: components/com_easystore/src/Model/SettingsModel.php (getRegionByCountry(), lines 79-99)

What the Bug Is

When a store administrator configures a shipping region for a country and selects specific states ($value->states is non-empty), SettingsModel::getRegion($shipping, $country, $state) calls getRegionByCountry($shipping, $country) when $state is empty on initial checkout page load. getRegionByCountry() requires empty($value->states) on line 86, so it returns null (data: []) whenever states are configured for that country, preventing shipping methods from loading until states is emptied in the database.

How to Reproduce It

  1. In EasyStore Settings -> Shipping, configure a shipping region for United States (840) with one or more states selected and an enabled shipping method.
  2. Add a product to the cart and open /component/easystore/checkout (or call GET /index.php?option=com_easystore&task=checkout.getShipping&country=840).
  3. The endpoint returns {"status":"success","data":[]} because $state is not passed on initial load and getRegionByCountry() rejects any region where !empty($value->states).

Fix (Unified Patch Against Clean com_easystore 3.1.1)

--- a/components/com_easystore/src/Model/SettingsModel.php
+++ b/components/com_easystore/src/Model/SettingsModel.php
@@ -80,12 +80,20 @@
     {
         $region = null;

+        $fallbackRegion = null;
+
         foreach ($shipping as $item) {
             if (!empty($item->regions)) {
                 foreach ($item->regions as $value) {
-                    if ($value->country == $country && empty($value->states)) {
-                        $region = $item;
-                        break;
+                    if ($value->country == $country) {
+                        if (empty($value->states)) {
+                            $region = $item;
+                            break;
+                        }
+
+                        if ($fallbackRegion === null) {
+                            $fallbackRegion = $item;
+                        }
                     }
                 }
             }
@@ -95,7 +103,7 @@
             }
         }

-        return $region;
+        return $region ?? $fallbackRegion;
     }

     private function isRegionMatched($region, $country, $state)

1 reply

Mehtaz Afsana Borsha Staff

Hi,

Thank you for the detailed bug report and for providing the reproduction steps and proposed patch.

We appreciate the time you've taken to investigate this issue in EasyStore 3.1.1.

Based on your findings, the current getRegionByCountry() logic appears to exclude shipping regions with state-specific configurations when no state is provided during the initial checkout request.

Your proposed fallback is worth reviewing. However, we also need to ensure that it does not return shipping methods for states where those methods should not be available, particularly when multiple shipping regions exist for the same country.

We'll share your findings and suggested patch with our development team for further investigation.

Thank you again for your contribution and for helping us improve EasyStore.

Best regards,

Log in to reply.