Config for checkout standard address states

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Config for checkout standard address states

Post by BrianMecler » 18 Jul 2023, 11:30

Hello,

Laravel Framework 10.13.1, php8.1-fpm, aimeos/aimeos-laravel 2023.04.2

I am attempting to provide an array of states so that the State form field get displayed during checkout. It seems like 'if( count( $this->get( 'states', [] ) ) > 0 )' always returns 0 for me.

This is what I attempted to put in my config/shop.php:

Code: Select all

	'client' => [
		'html' => [
			'basket' => [
				'cache' => [
					// 'enable' => false, // Disable basket content caching for development
				],
			],
			'checkout' => [
				'standard' => [
					'address' => [
						'states' => [
							'US' => [
								'CA' => 'California',
								'NY' => 'New York',
							],
						],
						'billing' => [
							'hidden' => [
								'order.address.vatid', // this does work
							],
						],
					],
				],
			],
I tried several other combinations of an array, including an example I found with 'common' in it:

Code: Select all

'client' => [
	'html' => [
		'checkout' =>
			'standard' =>
				'address' => [
					'common' => [
						'states' => [
							'US' => [
This is my first time using the config.. As a sanity check, I added the config above to hide the order.address.vatid and confirm that change worked as expected.. Im guessing that I have the array in the wrong location, or not properly structured?

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 18 Jul 2023, 13:16

More information..

I am only not able to see the state field when signed out of the system.. When I sign in, and choose to edit the Billing address, or add a new delivery address, I see the state field and it has my values populated from the array.

What seems odd, is that while the states populate while logged in, the config for hiding 'order.address.vatid' doesnt seem to take affect. As I can see the vatid field on both sets of form fields... I also added some configs for mandatory fields and optional fields, those only seem to take affect when logged out of the system.

It seems like I am getting some kind of mixed behavior of the config fields depending on if I am logged in as a user or not?

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 18 Jul 2023, 16:45

I have tried clearing the cache as well:

Code: Select all

php artisan aimeos:clear

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 18 Jul 2023, 23:06

In the event that im having some type of caching issue, I verified that I see 18 records in 'madmin_cache' mysql table.
After I run 'php artisan aimeos:clear' I confirm that it removes the records:

mysql> select * from madmin_cache \G
Empty set (0.00 sec)

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 18 Jul 2023, 23:11

Unsure if it makes a difference, but I currently have 4 pages copied over from the vendor directory into my theme directory:

/packages/blueperch/templates/client/html/checkout/standard/
address-billing-body.php
address-body.php
address-delivery-body.php
address-partial.php

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 19 Jul 2023, 22:43

To clarify my problem (it is not what I originally thought):

My updates to config/shop.php to add the 'State' field only affect the 'Profile' page and allow the 'State' field to display when editing the customers 'Billing Address' or 'Delivery Address'.

Going to the basket and advancing thru the checkout process, as a customer or guest, does not display the 'States' field at all.
So it appears the config/shop.php values I added are only for modifying the customers profile information.

This appears to be the same behavior with the 'countries' config parameter. I am able to specify only two countries and that parameter is only used for the customers profile billing and delivery address forms. The forms on the checkout process show all the default countries.

My changes to the 'billing' and 'delivery' config values work on the checkout process forms, but they do not affect the customer profile form fields for delivery and billing.

Assuming the config I provide below

1) Is anyone able to confirm that the states and countries config keys are only good for the customer profile delivery and billing forms, and not any of the checkout forms?

2) Is anyone able to confirm that the billing and delivery config keys are only good for the checkout forms and not the customer profile delivery and billing forms?

3) If 1 and 2 above are correct, are these elements supposed to be controlled through a separate array or different structure?

Code: Select all

	'client' => [
		'html' => [
			'basket' => [
				'cache' => [
					 'enable' => false, // Disable basket content caching for development
				],
			],
			'checkout' => [
				'standard' => [
					'address' => [
						'states' => [
							'US' => [
								'CA' => 'California',
								'NY' => 'New York',
							],
						],
						'countries' => [
							'US',
						],
						'billing' => [
							'hidden' => [
								'order.address.vatid',
							],
							'mandatory' => [
								'order.address.countryid',
							],
							'optional' => [
								'order.address.firstname',
								'order.address.state',  // this doesnt show anyway
							],	
						],
						'delivery' => [
							'hidden' => [
								'order.address.vatid',
							],
							'mandatory' => [
								'order.address.countryid',
							],
							'optional' => [
								'order.address.firstname',
								'order.address.state',  // this doesnt show anyway
							],	
						],	

Thank you for your time.

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: Config for checkout standard address states

Post by aimeos » 20 Jul 2023, 07:36

Sorry, the configuration keys for countries and states has changed in 2023.x to:
- common/countries
- common/states

See: https://aimeos.org/docs/latest/frontend ... and-states

The documentation wasn't up to date and the setting wasn't used in the account/profile component too. The documentation has been fixed now and if you update the aimeos/ai-client-html package to 2023.07.4, it will use the same configuration as in the checkout address step.

In both, the profile and checkout sections, no caching is used at all. Only catalog pages and the mini basket are cached by default.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 20 Jul 2023, 10:25

Thank you for your reply!

I did attempt to use the following in 'common' several times:

Code: Select all

			'common' => [
				'cache' => [
					 'force' => false // enforce caching for logged in users
				],
				'states' => [
					'US' => [
						'CA' => 'California',
						'NY' => 'New York',
					],
				],
				'countries' => [
					'US',
				],			
			],
Does that appear correctly structured?

I will look into the updates you mentioned.

Thank you!

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: Config for checkout standard address states

Post by aimeos » 20 Jul 2023, 10:28

Depends on where you've added the "common" key. It must be a top level configuration key in ./config/shop.php (Laravel), not within client/html or somewhere else.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

BrianMecler
Posts: 41
Joined: 03 Jun 2023, 17:30

Re: Config for checkout standard address states

Post by BrianMecler » 20 Jul 2023, 11:25

Thank you,

That was my problem.. I kept trying to add the states and countries under the 'common' key that I found under client/html. I added a 'common' key at the root level and the fields showed up as you said!

Prior to that change, I did update 'aimeos/aimeos-laravel' to 2023.07.1 and 'aimeos/ai-client-html' to 2023.07.4. I didnt have any luck with getting the fields to override with the states and countries keys in client/html/checkout/standard/address/states after the update. Likely another 'me' problem, but I'm thankful you have progressed me through this problem.

Post Reply