Book Image

PrestaShop Module Development

By : Serny
Book Image

PrestaShop Module Development

By: Serny

Overview of this book

If you are a developer who is new to PrestaShop and wants to get a good foundation in development on the PrestaShop framework, this book is for you. It's assumed that you will have some experience with PHP5, jQuery, and HTML/CSS (no need to be an expert on it).
Table of Contents (13 chapters)
12
Index

Checking the currency


In PrestaShop, the merchant can enable different currencies for each module payment. Go to the Payment menu under Modules in your back office; you will see a section named CURRENCY RESTRICTIONS (you also have other sections such as COUNTRY RESTRICTIONS):

The displayPayment hook won't display a payment method if the customer has chosen a currency that is not enabled for the payment method in question.

However, it's safer to add security in your payment module. In the initContent method of your module's Payment front controller, add the following lines just before assigning data to Smarty:

// Check if currency is accepted
if (!$this->checkCurrency())
Tools::redirect('index.php?controller=order');

Then, in this controller, create the checkCurrency method. We will first retrieve the currency associated with the cart (the one chosen by the customer) and get the currencies enabled for this payment module with the getCurrency method (native method of the PaymentModule abstract...