Can't use existing delivery address

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!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Can't use existing delivery address

Post by MikaelNazarenko » 27 Nov 2019, 13:30

Hello!

Versions info:

Code: Select all

aimeos/ai-admin-jqadm                 2019.10.x-dev ac5080a Aimeos ai-admin-jqadm extension
aimeos/ai-admin-jsonadm               2019.10.2             Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html                 2019.10.8             Aimeos ai-client-html extension
aimeos/ai-client-jsonapi              2019.10.1             Aimeos JSON API extension
aimeos/ai-controller-frontend         2019.10.3             Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs             2019.10.3             Aimeos ai-controller-jobs extension
aimeos/ai-gettext                     2019.10.1             Aimeos Gettext extension
aimeos/ai-laravel                     2019.10.2             Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-payments                    2019.10.1             Payment extension for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer                 2019.10.1             SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core                    2019.10.x-dev e2194bf Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel                 2019.10.1             Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects

When I am on checkout proccess I select existing delivery address (another from billing). Then I click next to delivery point. Then I click back to address tab. And here new delivery address is selected.. Also before I selected existing address I have modified some fields of it. And fields were not saved...

I have disabled my extension and all my customization..

I am very worry about this surprise, because it is on live site.. I am not sure 100% that it is a bug, but seems it happened after updates aimeos and I disabled all my customizations...

Please, help to fix it

Screenshots:

https://prnt.sc/q2tjqo

https://prnt.sc/q2tk4t

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 27 Nov 2019, 14:32

The same bug even here http://laravel.demo.aimeos.org/

When I modify existing delivery address on checkout - changes not saved. And on last step is old data from existing address. Also if I get back to addresses - new address is selected, but I was selecting exiting address...

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 27 Nov 2019, 15:27

File

Code: Select all

vendor/aimeos/aimeos-core/lib/mshoplib/src/MShop/Common/Item/Address/Base.php

Code: Select all

	/*
	 * Sets the item values from the given array and removes that entries from the list
	 *
	 * @param array &$list Associative list of item keys and their values
	 * @param boolean True to set private properties too, false for public only
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Address item for chaining method calls
	 */
	public function fromArray( array &$list, $private = false )
	{
	    $item = parent::fromArray( $list, $private );

		foreach( $list as $key => $value )
		{
			if( strncmp( 'customer.address.', $key, 17 ) !== 0 ) {
				$key = str_replace( ['order.base.address.', 'customer.'], $this->prefix, $key );
			} else {
				$key = str_replace( 'customer.address.', $this->prefix, $key );
			}

            if(!empty($list['order.base.address.countryid']) && $list['order.base.address.countryid'] == 'LV') {
                dd($key);
            }


The output of dd is:

"customer.address.address.salutation"

I think problem here

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 27 Nov 2019, 15:49

https://github.com/aimeos/aimeos-core/b ... e.php#L600

I think it where the problem is. I guess developer have done mistake, because str_replace tries to find first element from array of its first argument and replace it and then second element and so on. Maybe I am wrong, but I have changed that line with:

Code: Select all

 $replaced = 0;
                $key = str_replace( ['order.base.address.'], $this->prefix, $key, $replaced );
                if(!$replaced) {
                    $key = str_replace( ['customer.'], $this->prefix, $key );
                }
And it works.

Please fix it well! thank you !

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 28 Nov 2019, 07:47

A lot of bugs with delivery address in checkout process!!!! ((((

After I selected existing address - the address is not preselected!

And each time when I select existing address in checkout process - it duplicates and add the same address to user!

I don't understand what happened (

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 28 Nov 2019, 09:16

For me problems were because of addressid was missed;

I extended Order\Base Address,

fromArray method:

Code: Select all

case 'customer.address.id':
                    $item->setAddressId($value);
                    break;
toArray:

Code: Select all

        $list = parent::toArray( true );
        if( $private === true ) {
            $list['order.base.address.addressid'] = $this->getAddressId();
        }
        return $list;

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

Re: Can't use existing delivery address

Post by aimeos » 28 Nov 2019, 09:59

This should have been fixed since last week but we didn't tag the fixes yet (now: aimeos/ai-client-html 2019.10.9). Can you please update your installation and see if everything works for you now?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 28 Nov 2019, 10:56

Please, sorry for my stressed posts ) I was stressed and I had small time to fix it ) Thank you a lot for support! I hope maybe I am also helpful sometimes.

This is my current composer:

Code: Select all

        "aimeos/ai-admin-jqadm": "2019.10.x-dev",
        "aimeos/ai-payments": "^2019.07",
        "aimeos/aimeos-core": "2019.10.x-dev",
        "aimeos/aimeos-laravel": "2019.10.x",

Please tell what I should set to composer to get right versions? I will check it

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

Re: Can't use existing delivery address

Post by aimeos » 28 Nov 2019, 11:01

Just run "composer update". Then, you should get "aimeos/ai-client-html: 2019.10.9".
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Can't use existing delivery address

Post by MikaelNazarenko » 28 Nov 2019, 11:04

Should I leave dev for core and ai-admin-jqadm ? Or have you added fixes to normal verison ? For me important fixes for isModified() method )

Post Reply