Jump to content

Check before checkout


name29

Recommended Posts

edit, or better, override controllers/front/OrderController.php   (Make backup)

 

And in function Init, you could add some code to check. They do already some basic check here, like:

 

 

 

...
$product = $this->context->cart->checkQuantities(true);
 
if ((int)$id_product = $this->context->cart->checkProductsAccess())
{
  $this->step = 0;
  $this->errors[] = sprintf(Tools::displayError('An item in your cart is no longer available (%1s). You cannot proceed with your order.'), Product::getProductName((int)$id_product));
}
 
// If some products have disappear
if (is_array($product))
{
  $this->step = 0;
  $this->errors[] = sprintf(Tools::displayError('An item (%1s) in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.'), $product['name']);
}
 
// Check minimal amount
  $currency = Currency::getCurrency((int)$this->context->cart->id_currency);
...
 
etc.
 
You could then add your own check function here.
 
My 2 cents,
pascal.
Link to comment
Share on other sites

Hi Pascal!

 

Thank you for your reply!

 

I need to add some fields during check-out (before payment ) and verify that the service that are insidie the shopping cart are selable.

 

Where i can put the code for add another "step" (login/address/payment) in the check-out process?

Link to comment
Share on other sites

Hi name29,

 

in the same file:

/controllers/front/OrderController.php

 

you will see a function:

 

public function initContent()
 

with a switch command, where depending on

     switch ((int)$this->step)
 
it will go to login/address/carrier/billing etc.
 
In theory, you could add a step here, but at least in this file, and maybe outside it, it references many times to step X, step Y
 
like this code:
   if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
 
 
so be very, very careful if you insert a step, that you have to renumber the steps everywhere.
 
my 2 cents,
pascal
Link to comment
Share on other sites

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...