Abandoned Basket Notification
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- Wall0fDeath
- Posts: 28
- Joined: 30 Aug 2022, 13:56
Abandoned Basket Notification
Php : 8.2
Os: Debian GNU/Linux 11 (Bullseye)
Aimeos 22.10.12
Laravel 9.37.0
Hi!
I wish you a happy new year! )
I need abandoned cart notifications for my work. I think the last relevant topic about this was in 2022 february (Do aimeos supports abandoned cart functionality?) , but this link(https://github.com/aimeos/aimeos-core/b ... e/Base.php) does not work for me wether I am logged in or not.
Was the abandoned cart notification function implemented in any of the already released aimeos versions?
If not, is there any chance to be released in this year? (If yes, when will it be approximately?)
If I start to make it, may I ask for some suggestions about how should to can be easily merged to some future releases of Aimeos?
Os: Debian GNU/Linux 11 (Bullseye)
Aimeos 22.10.12
Laravel 9.37.0
Hi!
I wish you a happy new year! )
I need abandoned cart notifications for my work. I think the last relevant topic about this was in 2022 february (Do aimeos supports abandoned cart functionality?) , but this link(https://github.com/aimeos/aimeos-core/b ... e/Base.php) does not work for me wether I am logged in or not.
Was the abandoned cart notification function implemented in any of the already released aimeos versions?
If not, is there any chance to be released in this year? (If yes, when will it be approximately?)
If I start to make it, may I ask for some suggestions about how should to can be easily merged to some future releases of Aimeos?
Last edited by Wall0fDeath on 31 Mar 2023, 12:59, edited 1 time in total.
Re: Abandoned Basket Notification
In Aimeos 2022.10+, the baskets are already saved to the mshop_order_basket table:
https://github.com/aimeos/aimeos-core/b ... r/Base.php
Thus, you would only need to add a job controller sending an e-mail to the customers which is similar to this one:
https://github.com/aimeos/ai-controller ... andard.php
If you are able to provide a PR we can work on, we will be happy to merge it into the core so it can be part of the next release
https://github.com/aimeos/aimeos-core/b ... r/Base.php
Thus, you would only need to add a job controller sending an e-mail to the customers which is similar to this one:
https://github.com/aimeos/ai-controller ... andard.php
If you are able to provide a PR we can work on, we will be happy to merge it into the core so it can be part of the next release
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- Wall0fDeath
- Posts: 28
- Joined: 30 Aug 2022, 13:56
Re: Abandoned Basket Notification
Php : 8.2
Os: Debian GNU/Linux 11 (Bullseye)
Aimeos 22.10.12
Laravel 9.37.0
Hi! Thank you for your previous answer! I am about to finish the extension.
I almost finished the functionality for the notification, but I have a problem with the install and the .
// I had to load the old seassion basket/order into the new one if you log in with empty basket
I needed to add a session variable after login into the redirect middleware, so now if you login with an empty basket, it will search the user's last saved basket for the site and loads it into the new order session( the basket id etc is untouched).
For this i had to modify the "MShop/Order/Manager/Base/Base.php" file's 'getSession' function and i implemented a ~'copyOldSession' named function.
I changed "Controller/Frontend/Basket/Standard.php" ->get() function in a new controller "Controller/Frontend/Basket/Abandonedbasket.php" to reload basket, if we are after login and the basket before login was empty.
I added a new condition and a value reset into "Client/Html/Basket/Mini/Standard.php" body, header in a new file "Client/Html/Basket/Mini/Abandonedbasket.php".
I made a job controller to send out mails and log them in a database table in configurable intervals and restart counting, if the basket updates.
+i18n to hungarian language and base .pot on english.
+Manager / Item for abandoned basket
These seems to work, but i think I can make it better.
My questions would be the following:
- Decorators are still black holes to me after a tons of reading. Can I modify the "MShop/Order/Manager/Base/Base.php->getSession()" function with a decorator, to make it 'better or nicer' without making changing the Standard? If i can, what dir should i put the new decorator class, with what name, what class to extend, and if I put there a function with the same name will that overwrite the original function?
- To give that session variable after the login, i had to modify "app/Http/Middleware/RedirectIfAuthenticated.php".
Is there any existing way to add this too with a "composer require ....", so basically automatically at extension install?
- The manager's class name looks rly long (Abandonedbasketnotification). I would like to change it to Abandonedbasket/Notification, but it seems this way I have to make a Standard.php into the Abandonedbasket dir and tell it, to read the Notification/Standard.php, or i don't know, but i couldn't find it.
If i should make it, the class should it extend, and what should i tell it read. I've tried to find and example in the core, but i couldn't find any. ( Maybe I was careless )
May I ask for your opinion about these?
Thanks in advance!
Os: Debian GNU/Linux 11 (Bullseye)
Aimeos 22.10.12
Laravel 9.37.0
Hi! Thank you for your previous answer! I am about to finish the extension.
I almost finished the functionality for the notification, but I have a problem with the install and the .
// I had to load the old seassion basket/order into the new one if you log in with empty basket
I needed to add a session variable after login into the redirect middleware, so now if you login with an empty basket, it will search the user's last saved basket for the site and loads it into the new order session( the basket id etc is untouched).
For this i had to modify the "MShop/Order/Manager/Base/Base.php" file's 'getSession' function and i implemented a ~'copyOldSession' named function.
I changed "Controller/Frontend/Basket/Standard.php" ->get() function in a new controller "Controller/Frontend/Basket/Abandonedbasket.php" to reload basket, if we are after login and the basket before login was empty.
I added a new condition and a value reset into "Client/Html/Basket/Mini/Standard.php" body, header in a new file "Client/Html/Basket/Mini/Abandonedbasket.php".
I made a job controller to send out mails and log them in a database table in configurable intervals and restart counting, if the basket updates.
+i18n to hungarian language and base .pot on english.
+Manager / Item for abandoned basket
These seems to work, but i think I can make it better.
My questions would be the following:
- Decorators are still black holes to me after a tons of reading. Can I modify the "MShop/Order/Manager/Base/Base.php->getSession()" function with a decorator, to make it 'better or nicer' without making changing the Standard? If i can, what dir should i put the new decorator class, with what name, what class to extend, and if I put there a function with the same name will that overwrite the original function?
- To give that session variable after the login, i had to modify "app/Http/Middleware/RedirectIfAuthenticated.php".
Is there any existing way to add this too with a "composer require ....", so basically automatically at extension install?
- The manager's class name looks rly long (Abandonedbasketnotification). I would like to change it to Abandonedbasket/Notification, but it seems this way I have to make a Standard.php into the Abandonedbasket dir and tell it, to read the Notification/Standard.php, or i don't know, but i couldn't find it.
If i should make it, the class should it extend, and what should i tell it read. I've tried to find and example in the core, but i couldn't find any. ( Maybe I was careless )
May I ask for your opinion about these?
Thanks in advance!
Re: Abandoned Basket Notification
Decorators are like layers of an onion you wrap around a class object with the same interface. Then, you can intercept method calls in your decorator e.g.:Wall0fDeath wrote: ↑30 Mar 2023, 15:29 - Decorators are still black holes to me after a tons of reading. Can I modify the "MShop/Order/Manager/Base/Base.php->getSession()" function with a decorator, to make it 'better or nicer' without making changing the Standard? If i can, what dir should i put the new decorator class, with what name, what class to extend, and if I put there a function with the same name will that overwrite the original function?
Code: Select all
class \Aimeos\MShop\Order\Manager\Base\Decorator\Abandoned
extends \Aimeos\MShop\Common\Manager\Decorator\Iface
{
public function getSession() : \Aimeos\MShop\Order\Item\Base\Iface
{
// do something before
$basket = $this->getManager()->getSession();
// do something afterwards
return $basket;
}
}
Code: Select all
class \Aimeos\MShop\Order\Manager\Base\Decorator\Abandoned
extends \Aimeos\MShop\Common\Manager\Decorator\Iface
{
public function getSession() : \Aimeos\MShop\Order\Item\Base\Iface
{
if( ( $basket = $this->getAbandoned() ) === null ) {
$basket = $this->getManager()->getSession();
}
return $basket;
}
protected function getAbandoned() : \Aimeos\MShop\Order\Item\Base\Iface
{
// get basket from table
return $basket;
}
}
Code: Select all
'mshop' => [
'order' => [
'manager' => [
'base' => [
'decorators' => [
'local' => [
'Abandoned' => 'Abandoned',
],
],
],
],
],
],
If you create a Laravel package with a package service provider that also includes your Aimeos code, you can automatically register a new middleware that adds the token to the session:Wall0fDeath wrote: ↑30 Mar 2023, 15:29 - To give that session variable after the login, i had to modify "app/Http/Middleware/RedirectIfAuthenticated.php".
Is there any existing way to add this too with a "composer require ....", so basically automatically at extension install?
- https://panjeh.medium.com/laravel-regis ... 3bd43d76cb
Why not name the decorator just "Abandoned"?Wall0fDeath wrote: ↑30 Mar 2023, 15:29 - The manager's class name looks rly long (Abandonedbasketnotification). I would like to change it to Abandonedbasket/Notification, but it seems this way I have to make a Standard.php into the Abandonedbasket dir and tell it, to read the Notification/Standard.php, or i don't know, but i couldn't find it.
If i should make it, the class should it extend, and what should i tell it read. I've tried to find and example in the core, but i couldn't find any. ( Maybe I was careless )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- Wall0fDeath
- Posts: 28
- Joined: 30 Aug 2022, 13:56
Re: Abandoned Basket Notification
Thank you!
This part works fine now. )
I managed to make it with a little change:
namespace Aimeos\MShop\Order\Manager\Base\Decorator;
class Abandoned
extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
...
}
This part works fine now. )
I managed to make it with a little change:
namespace Aimeos\MShop\Order\Manager\Base\Decorator;
class Abandoned
extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
...
}