Fixed country only for delivery

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
YnievesPuntoNet
Posts: 8
Joined: 17 Oct 2022, 14:41

Fixed country only for delivery

Post by YnievesPuntoNet » 04 Nov 2022, 19:02

I try limit the country options (and state) for delivery. But dont work.

Code: Select all

            'checkout' => [
                'standard' => [
                    'address' => [
                        'billing' => [
                        ...
                        ],
                        'delivery' => [
                        ...
                        ],
                        'countries' => ['XX'],
                        'states' => [
                            'XX' => [
                                'AA' => 'Aaaaaa',
                                ...
                                'ZZ' => 'Zzzzzzz',
                            ],
                        ],
                    ],
                ],
            ],
but work for billing and delivery. If I put this code inside delivery or billing section, not make any changes in the form

Thanks all

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

Re: Fixed country only for delivery

Post by aimeos » 06 Nov 2022, 19:38

Seems to be a mistake in the docs because the country and state list is retrieved from "common/countries" and "common/states" config keys for a while now:
https://github.com/aimeos/ai-client-htm ... #L262-L315
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

YnievesPuntoNet
Posts: 8
Joined: 17 Oct 2022, 14:41

Re: Fixed country only for delivery

Post by YnievesPuntoNet » 08 Nov 2022, 19:30

Is possible restrict only the country and the state only for Delivery, not for Billing?

Thanks

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

Re: Fixed country only for delivery

Post by aimeos » 10 Nov 2022, 06:37

Not by default. You have to create a decorator for the checkout/standard/address/delivery subpart which overwrites the addressCountries view variable in its data() method:
https://aimeos.org/docs/latest/frontend ... omponents/

Something like:

Code: Select all

public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
	$view = parent::data( $view, $tags, $expire );
	$view->addressCountries = [...];
	return $view;
}
Decorator configuration would be:

Code: Select all

client/html/checkout/standard/address/delivery/decorators/global = ['Mydecorator']
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply