Additional step to the checkout

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!
Icewind
Posts: 4
Joined: 04 Dec 2018, 20:22

Additional step to the checkout

Post by Icewind » 04 Dec 2018, 20:50

Hello,
My employer wants me to add a new step to the checkout, meaning I have to add additional data to the checkout process ("Delivery time").
Image
I've been bashing my head around, and using your documentation, somehow I createad what you can see above. However, after doing so I have broken the checkout :D .
Time si running out and I am still not clear how this works, so can you please guide me? Can you list all the steps I have to take for this to work?(even if it sounds dumb...I might have missed something)

Thank you :D

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

Re: Additional step to the checkout

Post by aimeos » 05 Dec 2018, 21:06

1.) Create a new subpart for the checkout process (https://aimeos.org/docs/Developers/Html ... w_subparts)
2.) Configure a new step using https://aimeos.org/docs/Configuration/C ... d/subparts
3.) In the process step of your new subpart, save the selected date/time values as attributes in the order service item of the basket (https://aimeos.org/api/latest/class-Aim ... Iface.html)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Icewind
Posts: 4
Joined: 04 Dec 2018, 20:22

Re: Additional step to the checkout

Post by Icewind » 07 Dec 2018, 12:53

Many thanks for the answer!

d=(OwO)=b

I have come to understand that i missed the 3rd step, however I am still not clear how the flow works.

I think this is the part where i have to save the attributes

Code: Select all

	public function process()
	{
		$view = $this->getView();

		try
		{
			$context = $this->getContext();
			$basketCtrl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' );

			// only start if there's something to do
			if( ( $serviceId = $view->param( 'c_timeoption', null ) ) !== null )
			{
				$serviceCtrl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'service' );

				$attributes = $view->param( 'c_delivery/' . $serviceId, [] );

				$errors = $serviceCtrl->checkAttributes( $serviceId, $attributes );
			
				$view->deliveryError = $errors;

				if( count( $errors ) > 0 )
				{
					$view->standardErrorList = $view->get( 'standardErrorList', [] ) + $errors;
					throw new \Aimeos\Client\Html\Exception( sprintf( 'Please recheck your time choice' ) );
				}
				else
				{
                              
      /* Is this the part where the attributes are saved?*/

					$basketCtrl->setService( 'delivery', $serviceId, $attributes );

      /* Is this the part where the attributes are saved?*/
				}
			}

			parent::process();


			// Test if delivery service is available
			$services = $basketCtrl->get()->getServices();
			if( !isset( $view->standardStepActive ) && !array_key_exists( 'summary', $services ) )
			{
				$view->standardStepActive = 'summary';
				return false;
			}
		}
		catch( \Exception $e )
		{
			$view->standardStepActive = 'summary';
			throw $e;
		}
	}
Now the checkout goes to the last step ("summary"), but i am not sure how to save the attributes :oops:

1. Do i have to give them a specific name or any name is fine? (this is the part i don't understand - see the comments in the code above)

2. After this I will have to display the option selected in summary whitch means I need to edit the subpart template for summary, right?

Thanks again! :D

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

Re: Additional step to the checkout

Post by aimeos » 07 Dec 2018, 13:16

Icewind wrote: 1. Do i have to give them a specific name or any name is fine? (this is the part i don't understand - see the comments in the code above)
No the name must be unique only but you need to add a decorator to your service options that checks if the data is correct like this ones:
- https://github.com/aimeos/aimeos-core/b ... r/Time.php
- https://github.com/aimeos/aimeos-core/b ... r/Date.php

If you use the same names as they expect, you can even reuse them without writing your own one.
Icewind wrote: 2. After this I will have to display the option selected in summary whitch means I need to edit the subpart template for summary, right?
If you store them as service attributes, they may be shown automatically in the summary depending on their type. Just have a look into the template what are the conditions.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Icewind
Posts: 4
Joined: 04 Dec 2018, 20:22

Re: Additional step to the checkout

Post by Icewind » 07 Dec 2018, 13:53

Thank you! I did not expect you to answer so fast. This is great...it looks like exactly what i need but I am very stressed and I think my brain refuses to cooperate with me...

Can you please show me a bit of code how can I use this inside the process part? :D


While browsing the documentation, another question popped in my head...Do I have to add a new type of service provider(in admin I mean), beside delivery and payment and play around with those?

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

Re: Additional step to the checkout

Post by aimeos » 10 Dec 2018, 20:01

Icewind wrote:Thank you! I did not expect you to answer so fast. This is great...it looks like exactly what i need but I am very stressed and I think my brain refuses to cooperate with me...

Can you please show me a bit of code how can I use this inside the process part? :D
Puh, maybe it's better to ask the Aimeos company for help to get this done as we are given support in our spare time ...
Icewind wrote:While browsing the documentation, another question popped in my head...Do I have to add a new type of service provider(in admin I mean), beside delivery and payment and play around with those?
No, you don't. Just use a delivery service provider.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Icewind
Posts: 4
Joined: 04 Dec 2018, 20:22

Re: Additional step to the checkout

Post by Icewind » 13 Dec 2018, 20:11

aimeos wrote: Puh, maybe it's better to ask the Aimeos company for help to get this done as we are given support in our spare time ...
Yes, I was kind of aware of that. Your answers are greatly appreciated.

After some rest and some testing I think I finally understand. Thank you for your support :D

Post Reply