Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
About the Author
About the Reviewers

Validating a cart into an order

We will now create a module's front controller named validation (you should have created the form, whose action calls the validation controller, in the previous section of this chapter).

This controller won't display anything; it will only transform a cart into an order. First, create a file named validation.php in the controllers/front/ directory of your module, then create the corresponding class in it:

class MyModPaymentValidationModuleFrontController extends ModuleFrontController

We will create a method called postProcess (in fact, we will override it since it already exists in all the controllers). This method is called at the beginning of the controller's execution, so we will be able to perform all our operations before any display.

The first thing to do is to check whether the cart exists and is correctly filled in and whether the payment module is still enabled. If one of these conditions is incorrect, we will redirect the customer at the...