Decorator process method not working correctly

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!
krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Decorator process method not working correctly

Post by krzysiekp » 19 Nov 2021, 16:14

I have a code. Code below line:

Code: Select all

$this->getClient()->process();
not working correctly. For example remove product from cart not working.

Code: Select all

class BasketDecorator extends \Aimeos\Client\Html\Common\Decorator\Base implements \Aimeos\Client\Html\Common\Decorator\Iface
{

    public function process()
    {
        try {
            $context = $this->getContext();
            if (Request::input('b_action') === 'add') {
                \Aimeos\Controller\Frontend::create($context, 'basket')->clear();
            }
        } catch (\Exception $ex) {
        }
        $this->getClient()->process();
        
        $cardType = Session::get('card_type');

        if (empty($cardType)) {
            header('Location: /shop');
            die;
        }

        $count = \Aimeos\Controller\Frontend::create($context, 'basket')->get()->getProducts()->count();
        if ($count > 0) {
            header('Location: /shop/checkout/onepage');
            die;
        } else {
            header('Location: /shop');
            die;
        }
    }
}

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

Re: Decorator process method not working correctly

Post by aimeos » 20 Nov 2021, 10:06

Did you configure your decorator so it will be used? Check if the code is executed at all.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Re: Decorator process method not working correctly

Post by krzysiekp » 20 Nov 2021, 12:31

Aimeos

I want to execute all base operations of basket and then my code in decorator but not working correctly

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

Re: Decorator process method not working correctly

Post by aimeos » 21 Nov 2021, 14:30

You didn't answer any of our questions ...
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Re: Decorator process method not working correctly

Post by krzysiekp » 22 Nov 2021, 07:37

Yes, I configured it. I check this code. The code is executing.

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

Re: Decorator process method not working correctly

Post by aimeos » 22 Nov 2021, 09:21

If you want to execute the basket process() method first, you need to call "$this->getClient()->process();" as first statement in the process() method of your decorator.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Re: Decorator process method not working correctly

Post by krzysiekp » 22 Nov 2021, 09:23

That's exactly what I do but not working correctly.

Post Reply