Page 1 of 1

Error on Admin Orders page if Country is NULL in Customer Data

Posted: Sun Sep 15, 2024 2:13 am
by jcarndt
I have been seeing the following errors in my Admin error_log:

[14-Sep-2024 21:45:47 America/New_York] PHP Notice: Trying to access array offset on value of type null in /home4/birdonaw/public_html/oscomce/includes/modules/customer_data/cd_traditional_address.php on line 141
[14-Sep-2024 21:45:47 America/New_York] PHP Notice: Trying to access array offset on value of type null in /home4/birdonaw/public_html/oscomce/includes/modules/customer_data/cd_traditional_address.php on line 141
[14-Sep-2024 21:45:47 America/New_York] PHP Notice: Trying to access array offset on value of type null in /home4/birdonaw/public_html/oscomce/includes/modules/customer_data/cd_traditional_address.php on line 141

These errors occur when you display the Order in the admin, and the Country is NULL.
Capture.JPG
I was hoping Country would not need to be a required field, since I have a small store with only 1 country. I was thinking a better user experience if Country was not required.

I did a little more investigation, and I found if xxx_address_format_id in the Orders table is 0 or NULL, then this error is thrown.

Does anyone know if Country can be optional, or does it have to be a required field? If it can be optional, I would appreciate any thoughts on how to correct this issue.

Re: Error on Admin Orders page if Country is NULL in Customer Data

Posted: Sun Sep 15, 2024 4:08 am
by heatherbell
jcarndt wrote: Sun Sep 15, 2024 2:13 amsmall store with only 1 country. I was thinking a better user experience if Country was not required.
app.php/addons/supporters_code/s03e08_c ... e_selector
Think this PRO VIP Addon enables 1 Country to be preselected and disables unwanted Countries.
Country is generally required for tax purposes, Payment and Shipping integrations.

Re: Error on Admin Orders page if Country is NULL in Customer Data

Posted: Sun Sep 15, 2024 8:56 am
by burt
You could also simply delete out all the countries you do not need, which would mean leaving just the country/countries you do want to present to customer. EG keep USA/Canada if N.American based. Aus/NZ if Aus based etc.

Re: Error on Admin Orders page if Country is NULL in Customer Data

Posted: Sun Sep 15, 2024 1:27 pm
by jcarndt
@burt and @heatherbell Thanks for your thoughts!! They are very helpful.

One other thought, since it appears Country for the store to format the address properly and other store functions, it would be helpful to remove the module option that makes Country optional. It seems like it should be made mandatory to me.

Thanks again!!

Re: Error on Admin Orders page if Country is NULL in Customer Data

Posted: Mon Sep 16, 2024 7:13 am
by heatherbell
jcarndt wrote: Sun Sep 15, 2024 1:27 pmremove the module option that makes Country optional.
The option to disable or remove might be required by some development.
Users are informed in the User Guide here: https://phoenixcart.org/phoenixcartwiki ... ta_Modules