Page 1 of 1

How do I extend and override Order checkout page

Posted: 24 Apr 2017, 18:06
by bill
Hello,

I am new to Aimeos and I am trying to figure out things here with the checkout process and how does it really work.

I am trying to find what is the best way to override the checkout process basically after they reach to checkout/summary page and click on "Buy Now" button, how does this gets submitted and proceed? Which controller if I want to add my own code? how would I extend this

If you could guide me if will be great

Thanks

Re: How do I extend and override Order checkout page

Posted: 25 Apr 2017, 09:01
by aimeos
Have you read https://aimeos.org/docs/Developers/Html ... ut_process
It depends where you want to add your own code: before or after the redirect to the payment gateway.

Re: How do I extend and override Order checkout page

Posted: 25 Apr 2017, 16:16
by bill
Hello

Yes I have read it , there are some broken links and its hard to understand.

I am trying to see once the user clicks on "Buy Now" before the payment gateway, how can I intercept that and put my own code , where I grab the cart and do my own logic?

I read about extending the context like this : $context = \App::make('\Aimeos\Shop\Base\Context')->get();

Can I use that to grab the content of the current cart , and do my own custom method?

Please guide me through which files I need to modify or extend to do this

Thanks

Re: How do I extend and override Order checkout page

Posted: 25 Apr 2017, 20:37
by aimeos
Where's the best place to add your extensions depends on what you are going to achieve. Please tell us more about what you want to implement.

Re: How do I extend and override Order checkout page

Posted: 01 May 2017, 14:58
by PeterEsser
We have the same question; we need to adjust some functionality which takes place in the following 2 files:

- /ext/ai-client-html/client/html/src/Client/Html/Checkout/Standard/Order/Standard.php;
public function process();
we need to execute some code based on the order data and update automatically the order status to completed.

- /ext/ai-laravel/lib/custom/src/MShop/Customer/Manager/Laravel.php;
public function saveItem();
We need the created user in Aimeos to get the userdata and process it for further usage in our application.

We created an extension using the extension creator and see that there is a manifest file which includes the src folder of the extension ('client/html/src'), but the autoload_classmap does not contain files which are added in these folders. To be consistant, we added the same folder/file structure in the extension folder, so /ext/ourextension/client/html/src/Client/Html/Checkout/Standard/Order/Standard.php is placed there and as OOP approach the following definition is used in the class

class Standard
extends \Aimeos\Client\Html\Checkout\Standard\Order\Standard

So everything should be in place, we debugged the bootstrap class in the aimeos-core and see that the manifest and folders are added as includes, but in the end the autoload file in the /vendor/composer/autoload_classmap.php is not updated with files from this ext. folder.

Any idea how to fix this so we can add our own logic to existing functions?

We did the dump-autoload command and the template files in our extension folder are getting loaded so the extension structure should be fine.

Hope to hear from you guys!
Peter

Re: How do I extend and override Order checkout page

Posted: 02 May 2017, 10:54
by aimeos
PeterEsser wrote: - /ext/ai-client-html/client/html/src/Client/Html/Checkout/Standard/Order/Standard.php;
public function process();
we need to execute some code based on the order data and update automatically the order status to completed.
Instead of overwriting the existing implementation, you can
- add your own subpart: https://aimeos.org/docs/Developers/Html ... w_subparts
- add a decorator that dynamically extends the class: https://aimeos.org/docs/Developers/Html ... components
PeterEsser wrote: - /ext/ai-laravel/lib/custom/src/MShop/Customer/Manager/Laravel.php;
public function saveItem();
We need the created user in Aimeos to get the userdata and process it for further usage in our application.
Maybe a job controller is the best place for this: https://aimeos.org/docs/Developers/Cont ... controller
PeterEsser wrote: We created an extension using the extension creator and see that there is a manifest file which includes the src folder of the extension ('client/html/src'), but the autoload_classmap does not contain files which are added in these folders. To be consistant, we added the same folder/file structure in the extension folder, so /ext/ourextension/client/html/src/Client/Html/Checkout/Standard/Order/Standard.php is placed there and as OOP approach the following definition is used in the class

class Standard
extends \Aimeos\Client\Html\Checkout\Standard\Order\Standard
It doesn't work to name the class extending from itself. You need to rename it (e.g. "Ourproject") and configure the new class name of your class overwriting the standard implementation: https://aimeos.org/docs/Configuration/C ... order/name

Re: How do I extend and override Order checkout page

Posted: 30 Apr 2019, 10:36
by Dhara1510
Hello, @aimeos,

I am using your suggested method by using this documentation.

https://aimeos.org/docs/Developers/Cont ... processors

I want to do some code after subscription creation so i need to override subscription

Code: Select all

 end()
method. I followed your method. but I cannot proceed further.

You have mentioned

Code: Select all

controller/common/subscription/process/processors = ['Cgroup']
use this configuration option. Can you please help me where to configure my own created class.

And this configured class automatically will use my overridden function? Also when I do composer update will it be there and not removed?

Re: How do I extend and override Order checkout page

Posted: 01 May 2019, 09:13
by aimeos
First, you need to create your own custom Aimeos extension for your own code (use the extension builder):
https://aimeos.org/docs/Developers/Create_an_extension

Then, the end() method is when a subscription is canceled or it reached its end date. If you want to add code after the subscription is created, use begin() instead.

The configuration should be in the ./config directory of your custom Aimeos extension in the controller.php file:

Code: Select all

return [
    'common' => [
        'subscription' => [
            'process' => [
                'processors' => ['Mylastclasspart']
            ]
        ]
    ]