How X-Cart Determines a Customer's Address Zone
page last edited on 24 April 2019
When X-Cart needs to determine a tax or shipping rate that needs to be applied to a customer’s cart, it checks the customer’s address to see which zone this address belongs to. For that, X-Cart goes consecutively through the customer’s address fields - the country, the state and the zip/postal code - and matches them against the respective fields of each zone. If it finds that the customer’s country is listed among the countries included into a zone, it goes on to check the customer’s state. If the zone’s state list is empty (i.e., the zone includes all the states in the country), the customer’s address is identified as belonging to the zone. If the zone’s state list is not empty, and the customer’s state is not on that list, the customer’s address is identified as not belonging to this zone (so, X-Cart will need to find another zone the address can be matched with). If the zone’s state list is not empty, and the customer’s state is listed among the states included into the zone, the matching process continues on to the zip/postal code field. Similarly to the previous step, the zone’s field for zip/postal codes may be empty. In this case the customer’s address will be identified as belonging to the zone. If the zone’s field contains some zip/postal codes or zip/postal code masks X-Cart will also match the customer’s zip/postal code against the contents of this field and may find the customer’s address to match or not to match the zone.
If the customer’s address is found to match more than one zone, X-Cart will have to range all the zones matching the customer’s address by “weight”: zones with the largest number of parameters (country, state, zip/postal code) that match the customer’s address are deemed to have the greatest “weight”. So, when X-Cart needs to find a tax or shipping rate for an order, and the customer’s address matches more than one zone, X-Cart will first look for rates defined for the zone that has the greatest “weight”. If no rates for this zone can be found, X-Cart will go on to look for rates for the next zone, and so on. The last zone is always the built-in “All Addresses” (Default) Zone; this zone has zero “weight” and is used only if no other zone can be applied.
Help make this document better
This guide, as well as the rest of our docs, are open-source and available on GitHub.