name29 Posted April 13, 2015 Share Posted April 13, 2015 Hi! How i can insert before checkout some custom PHP code in order to verify that the product inside the shopping card are really saleble? Thank you Link to comment Share on other sites More sharing options...
PascalVG Posted April 13, 2015 Share Posted April 13, 2015 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 More sharing options...
name29 Posted April 13, 2015 Author Share Posted April 13, 2015 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 More sharing options...
PascalVG Posted April 14, 2015 Share Posted April 14, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now