Jump to content

Adding new checkout step


SamDouglas

Recommended Posts

Hello,

 

I am trying to add a new checkout step to my PrestaShop v1.7 where the user just has to enter a date. We are trying to implement a platform where users can rent party equipment so we need the event date.

 

Has somebody an idea what files I have to change? I found the Checkout[..]Step.php files in /classes/checkout but I'm sure there are more files which have to be changed.

 

Greetings

Sam Douglas

Link to comment
Share on other sites

did you check controllers/front/OrderController.php
 

I have not tested it, but maybe this will help :

$this->checkoutProcess
            ->addStep(new CheckoutPaymentStep(
                $this->context,
                $translator,
                new PaymentOptionsFinder(),
                new ConditionsToApproveFinder(
                    $this->context,
                    $translator
                )
            ))
        ;
Link to comment
Share on other sites

  • 2 years later...

Hi, I want to relive this. I am developing a new step. I used the code above, but that's just the beginning. I was guided by the management processes and personal information.

- CheckoutAddressStep

- CheckoutPersonalInformationStep.

☻ My step is:

CheckoutComprobanteStep:

 controllers/front/OrderController.php

 

$this->checkoutProcess
    ->addStep(new CheckoutComprobanteStep(
        $this->context,
        $translator,
        $this->makeComprobanteForm()
    ));

classes/checkout/CheckoutComprobanteStep.php

class CheckoutComprobanteStep extends AbstractCheckoutStep
{

    protected $template = 'checkout/_partials/steps/comprobante.tpl';
    private $comproForm;

    public function __construct(
        Context $context,
        TranslatorInterface $translator,
        ComprobanteForm $comproForm
    ) {
        parent::__construct($context, $translator);
        $this->comproForm = $comproForm;
    }


    public function handleRequest(array $requestParameters = array())
    {
        $this->step_is_reachable = true;

        if (isset($requestParameters['submitComprobante'])) {

            $this->comproForm->fillWith($requestParameters);

            if ($this->comproForm->submit()) {
                $this->step_is_complete = true;
            } else {
                $this->step_is_complete = false;
                $this->setCurrent(true);
                $this->getCheckoutProcess()->setHasErrors(true)->setNextStepReachable();
            }
        }

        $this->setTitle(
            $this->getTranslator()->trans(
                'Tipo Comprobante',
                array(),
                'Shop.Theme.Checkout'
            )
        );

    }

 

 

You have to create many more classes. As far as it goes, I insert my form of my voucher process into a table in the database. I still need to link the Voucher with the orders, with the cart or with the client, I still do not know. Answer to share code if someone already did it.

mi correo es:  [email protected]

proccess.png

Edited by TonyInuma (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...