Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
PrestaShop Module Development
PrestaShop Module Development

PrestaShop Module Development: Develop and customize powerful modules for PrestaShop 1.5 and 1.6

eBook
zł39.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

PrestaShop Module Development

Chapter 1. Creating a New Module

To learn how to code a PrestaShop module, it is always easier to work on a practical case. So, throughout the next chapters, we will develop a module that will permit customers to grade and comment on products.

In this first chapter, we will see how to:

  • Create the Bootstrap of an installable module
  • Add a configuration form to the module using Smarty templates
  • Register the module configuration in a database

First steps

First of all, we have to choose a public and technical name for the module. The technical name must be in lowercase, contain only letters and numbers, and begin with a letter. Let's call the module publicly My Module of product comments and technically mymodcomments.

You can choose whatever names you want as long as you stick to them for the rest of the book. However, since the technical name will be the directory name of your module, you won't be able to have two modules with the same technical name in a PrestaShop. Moreover, your technical name has to be unique if you want to sell it on marketplaces. One trick is to prefix it with your company name (in my case, my company name is Froggy Commerce, so I prefixed all my modules with froggy).

On the other hand, the public name has no restriction, so you can write whatever you want for the merchant.

Now, we will begin to create our first module.

Open the modules directory in the root of the PrestaShop directory, then create a new directory and name it with the technical name we chose: mymodcomments. Once done, in this new directory, create a new blank PHP file and name it with the technical name as well (in our case, mymodcomments.php). This is the main file of the module. The following screenshot depicts the file and folder structure:

First steps

Now open the mymodcomments.php file, and write the class of your module. You must name it with your technical name. To make it easier to read, you can use CamelCase. The class must extend PrestaShop's Module class. This class contains all the needed methods to make a module work; without it, your module won't work. In our case, the class of the module will be:

<?php
class MyModComments extends Module
{
}

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Additionally, the code for this book is part of a Git repository, which is available on GitHub at https://github.com/FabienSerny/mymodcomments, https://github.com/FabienSerny/mymodcarrier, and https://github.com/FabienSerny/mymodpayment.

In order to have a working module, we just have to add the __construct method. In this method, you must write the following three mandatory lines:

  • Set the technical name: Without this, the module won't be installable. This variable is used by PrestaShop to build the install, uninstall, and configure links of the module:
    $this->name = 'mymodcomments';
  • Set the public name: This line is used to display the module name for the merchant in the modules list of the back office:
    $this->displayName = 'My Module of product comments';
  • Calling the parent __construct method: This line is mandatory since important initializations are made in this function:
    parent::__construct();

You can add some of the following optional lines to give information about the module:

  • Set the module category: This makes the module search easier. If you don't set it or set a wrong value, then the module will automatically be associated with the Other Modules category. You should set one of the values shown in the following table:

    administration

    advertising_marketing

    analytics_stats

    billing_invoicing

    Checkout

    content_management

    export

    emailing

    front_office_features

    i18n

    localization

    merchandizing

    migration_tools

    payments_gateways

    payment_security

    pricing_promotion

    quick_bulk_update

    search_filter

    seo

    shipping_logistics

    slideshows

    smart_shopping

    market_place

    social_networks

    others

    mobile

      

    These possible values are associated with the module's categories search filter in the back office of your PrestaShop:

    $this->tab = 'front_office_features';
  • Set the module version: This variable will not only be used to display the module version in the module's list of the back office but also to check if updates are available (we'll cover this in more detail later):
    $this->version = '0.1';
  • Set the author name: This line is used to display the author name for the merchant in the module's list of the back office. It can also be used to search for modules:
    $this->author = 'Fabien Serny';
  • Set the module description: This helps the merchant learn what the module is used for:
    $this->description = 'With this module, your customers will be able to grade and comments your products';

Here's what your code should look like now:

<?php
class MyModComments extends Module
{
  public function __construct()
  {
    $this->name = 'mymodcomments';
    $this->tab = 'front_office_features';
    $this->version = '0.1';
    $this->author = 'Fabien Serny';
    $this->displayName = 'My Module of product comments';
    $this->description = 'With this module, your customers will be able to grade and comments your products.';
    parent::__construct();
  }
}

At this point, you should be able to see your module in the back office of the modules section, as shown in the following screenshot:

First steps

Note

The question mark icon

This is the default logo for all modules. If you want a custom picture, you just have to add a logo.png picture of 32 x 32 pixels and a logo.gif picture of 16 x 16 pixels (for PrestaShop 1.4 compliancy) at the root of your module directory.

The module is now a working module; you can install it by clicking on the Install button. Here is what you should see:

First steps

For the moment, your module does nothing and doesn't have any configuration options. The only actions available are:

  • Uninstall: This option uninstalls the module and deletes the specific configurations, if there are some.
  • Disable: This is an alternative to the uninstall action but permits you to keep module configurations. The module is still installed and will simply be ignored by PrestaShop.
  • Reset: This option uninstalls and reinstalls the module.
  • Delete: This option will uninstall the module and then delete all the module files.

All these core functions are handled by the Module class and can be overridden by the module (we will see this later).

Adding the module configuration

We will now add configuration options to our module. To do so, we just have to add the getContent function to our module. The return value of this function will be the content displayed on your screen.

In our case, we will write the following code:

public function getContent()
{
  return 'My name is Raphael, I am a tourist';
}

Note

The sentence returned is only an example (and a private joke from one of the PrestaShop core developers).

When the getContent function is placed in a module's class, PrestaShop automatically displays a Configure link in the back office. When the Configure link is clicked, this function is called and the return value is displayed.

So, if you refresh the modules list in the back office and your module is installed, you should now see a Configure button:

Adding the module configuration

If you click on the configuration link, you will see the translations block (automatically generated by PrestaShop software), and the sentence that we wrote in the function:

Adding the module configuration

You must avoid writing HTML in PHP code (very bad practice). That's why we will use the Smarty template (the template engine used in PrestaShop). If you are not familiar with this library, or with template engines in general, I invite you to read the official documentation (the link is in the introduction of this book). However, do not panic; using Smarty templates is quite easy!

We will start by creating the templates directory in the root of the module's directory: /views/templates/hook/. All of the templates used in the module's class must be placed in this directory.

One of the best practices is to name the templates with the name of the method in which they are used. So, we will create a template named getContent.tpl. Let's write our previous text in this template:

My name is Raphael, I am still a tourist

Then, in the getContent method, we just have to change the return line to the following:

return $this->display(__FILE__, 'getContent.tpl');

In this case, the display method will automatically use the getContent.tpl template in the /views/templates/hook/ directory. If you refresh the page, you'll see that your display has changed (we added one word). Now, your view is separated from your code. The following screenshot displays the file architecture you should have now:

Adding the module configuration

Making a simple configuration form

We will now make a small configuration form with two options: one to enable grades and the other one to enable comments on a product.

Let's fill in the getContent.tpl file we created previously with a small form.

Since PrestaShop 1.6, the back office now uses the CSS Framework Bootstrap. You can either write basic HTML (and make the display compliant with an older version of PrestaShop), or write Bootstrap templates.

If you choose to use Bootstrap (as I'll do later), you have to set the Bootstrap flag in your module constructor first.

In the __construct method of your module's mymodcomments.php main class, add the following line before parent::__construct:

$this->bootstrap = true;

If you do not set this flag to true (and if you are using PrestaShop 1.6), PrestaShop will include a retrocompatibility CSS file to make the template that you used in PrestaShop 1.5 compliant with the PrestaShop 1.6 display. Here is the Bootstrap HTML code that we will use to display the configuration:

<fieldset>
  <h2>My Module configuration</h2>
  <div class="panel">
    <div class="panel-heading">
      <legend><img src="../img/admin/cog.gif" alt="" width="16" />Configuration</legend>
    </div>
    <form action="" method="post">
      <div class="form-group clearfix">
        <label class="col-lg-3">Enable grades:</label>
        <div class="col-lg-9">
          <img src="../img/admin/enabled.gif" alt="" />
          <input type="radio" id="enable_grades_1" name="enable_grades" value="1" />
          <label class="t" for="enable_grades_1">Yes</label>
          <img src="../img/admin/disabled.gif" alt="" />
          <input type="radio" id="enable_grades_0" name="enable_grades" value="0" />
          <label class="t" for="enable_grades_0">No</label>
        </div>
      </div>

      <div class="form-group clearfix">
        <label class="col-lg-3">Enable comments:</label>
        <div class="col-lg-9">
          <img src="../img/admin/enabled.gif" alt="" />
          <input type="radio" id="enable_comments_1" name="enable_comments" value="1" />
          <label class="t" for="enable_comments_1">Yes</label>
          <img src="../img/admin/disabled.gif" alt="" />
          <input type="radio" id="enable_comments_0" name="enable_comments" value="0" />
          <label class="t" for="enable_comments_0">No</label>
        </div>
      </div>
      <div class="panel-footer">
        <input class="btn btn-default pull-right" type="submit" name="mymod_pc_form" value="Save" />
      </div>
    </form>
  </div>
</fieldset>

The HTML tags used here are the tags generally used in the native module, but you have no real limitations except your imagination.

Note

I will not go further in my explanation of this code since HTML basics are beyond the scope of this book.

If you refresh your browser, you will see the form appear, but for the moment, submitting the form will do nothing. So, we need to take care of saving the configuration options chosen by the merchant when he submits the form.

In order to not overload the getContent method, let's create a new method dedicated to handling the submission of the module configuration form. The name processConfiguration seems a good name to me for such a function. Since getContent is the only method called by PrestaShop when we enter in a module's configuration, we still have to call the newly created processConfiguration method in the getContent method:

public function processConfiguration()
{
}
public function getContent()
{
  $this->processConfiguration();
  return $this->display(__FILE__, 'getContent.tpl');
}

In the processConfiguration method, we will check whether the form has been sent with the Tools::isSubmit method:

if (Tools::isSubmit('mymod_pc_form'))
{
}

As you might have noticed, we set the mymod_pc_form name attribute on the Submit button. PrestaShop's Tools::isSubmit method checks whether a key matches the attribute name in the POST and GET values. If it exists, we will know that the form has been sent for sure.

We will now save the data of the form sent. We will use the following two methods for this action:

  • Tools::getValue: This function will retrieve the POST value of the key passed in the parameter. If the POST value does not exist, it will automatically check for the GET value. We can set a second parameter (optional), which will correspond to the default value if neither POST nor GET value is found.
  • Configuration::updateValue: This function is used to save simple value in the configuration table of PrestaShop. You just have to set the key as the first parameter and the value as the second. The updateValue function makes a new entry in the configuration table if the provided configuration is not found, and will update the configuration value if it is already in the configuration table. This method can have other parameters, but we will cover them later since we do not need them for the moment.

So in practice, we will have this:

if (Tools::isSubmit('mymod_pc_form'))
{
$enable_grades = Tools::getValue('enable_grades');
$enable_comments = Tools::getValue('enable_comments');
Configuration::updateValue('MYMOD_GRADES', $enable_grades);
Configuration::updateValue('MYMOD_COMMENTS', $enable_comments);
}

Note

It is a PrestaShop best practice to set the key in uppercase. Since any module can add configuration value, it's also a best practice to add a prefix to avoid conflict between modules. That's why I added MYMOD_.

Now, I invite you to refresh the configuration page in your browser, change the value of one or both options, and then submit the form.

Apparently, nothing has changed. However, if you go into your phpMyAdmin (or any administration tool), and see the content of PrestaShop's configuration table (if you kept the default database prefix, its name should be ps_configuration), you will see that the last two entries of the table are your values. You can play with the form and submit it again; the value will be updated.

We still have to display a confirmation message to let the merchant know that their configuration has been saved. For this, we just have to assign a confirmation variable to Smarty in the isSubmit condition just after the Configuration::updateValue calls.

The Smarty object is available in the $this->context->smarty variable in your module class. We will use the assign method of Smarty:

$this->context->smarty->assign('confirmation', 'ok');

This function takes two parameters: the name of the variable in which the value will be stored, and the value.

Note

If you want more information about this, you can check the official Smarty documentation at http://www.smarty.net/docsv2/en/api.assign.tpl.

In the Smarty template, you will now have a variable named $confirmation, which contains the value ok.

Note

We will see later exactly what the Context object contains. It is not important at this point.

If the $confirmation variable has been assigned to Smarty, then we display a confirmation message in getContent.tpl:

{if isset($confirmation)}
  <div class="alert alert-success">Settings updated</div>
{/if}

You can add these lines wherever you want in the template. However, you should add it just before the fieldset since this is a PrestaShop standard.

Now, you can submit the form again. If you did it right, the confirmation message should appear, as shown in the following screenshot:

Making a simple configuration form

We've almost finished the first version of the configuration form. However, you might have noticed that if you close the configuration form and reopen it, the options you set to Yes won't be preselected correctly. This will give the impression to the merchant that their configuration has not been saved properly.

To fix this problem, we just have to retrieve the configuration values and assign them to Smarty. We will use another function from the Configuration class: Configuration::get.

This function takes the key of the configuration wanted as a parameter, and returns the associated value:

$enable_grades = Configuration::get('MYMOD_GRADES');
$enable_comments = Configuration::get('MYMOD_COMMENTS');

Then, to assign these variables to Smarty, we will use the same method we saw previously to set the confirmation message flag:

$this->context->smarty->assign('enable_grades', $enable_grades);
$this->context->smarty->assign('enable_comments', $enable_comments);

To keep a short getContent method, my advice is to create a new method that we will call assignConfiguration, and write the code in it. So, at the end, we will have something like this:

public function assignConfiguration()
{
  $enable_grades = Configuration::get('MYMOD_GRADES');
  $enable_comments = Configuration::get('MYMOD_COMMENTS');
  $this->context->smarty->assign('enable_grades', $enable_grades);
  $this->context->smarty->assign('enable_comments', $enable_comments);
}

public function getContent()
{
  $this->processConfiguration();
  $this->assignConfiguration();
  return $this->display(__FILE__, 'getContent.tpl');
}

We just have to add some Smarty code in getContent.tpl to make it work. I will take the Enable grades option as an example, but it will be the same for Enable comments. If the Yes option is enabled, we will precheck the radio button whose value is 1. If the option value is not set or is set to 0, we will precheck the other radio button. The following is the Smarty code:

<img src="../img/admin/enabled.gif" alt="" />
<input type="radio" id="enable_grades_1" name="enable_grades" value="1" {if $enable_grades eq '1'}checked{/if} />
<label class="t" for="enable_grades_1">Yes</label>
<img src="../img/admin/disabled.gif" alt="" />
<input type="radio" id="enable_grades_0" name="enable_grades" value="0" {if empty($enable_grades) || $enable_grades eq '0'}checked{/if} />
<label class="t" for="enable_grades_0">No</label>

If we close the configuration form and reopen it, you will now see that the configuration values are prechecked correctly.

Congratulations, you finished the first step of your module!

If you don't know Smarty well yet, take time to read the official documentation to learn about functions of the Smarty object and template syntax. This will save you time for future developments.

Summary

In this chapter, we saw how to create the Bootstrap of an installable module with just one file. We also learned how to use Smarty templates in a module by building a small configuration form, and how to register merchant choices in the configuration table of the PrestaShop database.

In the next chapter, we will talk about the concept of hooks: what they're for and how to use them. We will also build the first interaction between the module and the front office.

Left arrow icon Right arrow icon

Description

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

What you will learn

  • Code your own module from scratch
  • Explore best practices for database table creation
  • Use hooks or implement overrides
  • Discover the many native methods available in PrestaShop
  • Make new administration tools
  • Create fully functional payment modules
  • Develop carrier modules
  • Secure and optimize your modules
  • Build functionalities compliant with the multistore feature
Estimated delivery fee Deliver to Poland

Premium delivery 7 - 10 business days

zł110.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 28, 2014
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783280254
Languages :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Poland

Premium delivery 7 - 10 business days

zł110.95
(Includes tracking information)

Product Details

Publication date : Nov 28, 2014
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783280254
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 617.97
PrestaShop 1.5 Beginner's Guide
zł197.99
Bootstrap Site Blueprints
zł197.99
PrestaShop Module Development
zł221.99
Total 617.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Creating a New Module Chevron down icon Chevron up icon
2. Hooks Chevron down icon Chevron up icon
3. Using Context and its Methods Chevron down icon Chevron up icon
4. Building Module Updates Chevron down icon Chevron up icon
5. Front Controllers, Object Models, and Overrides Chevron down icon Chevron up icon
6. Admin Controllers and Hooks Chevron down icon Chevron up icon
7. The Carrier Module Chevron down icon Chevron up icon
8. The Payment Module Chevron down icon Chevron up icon
9. Multistore Chevron down icon Chevron up icon
10. Security and Performance Chevron down icon Chevron up icon
A. Native Hooks Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(15 Ratings)
5 star 66.7%
4 star 20%
3 star 6.7%
2 star 6.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Vicente Pérez Linares Nov 08, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Quizá algo más superficial de lo esperado, pero sin duda con él se aprende a desarrollar módulos
Amazon Verified review Amazon
Andre Gugliotti Dec 28, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've been working with Magento for several years and now I decided to take a look over PrestaShop. After having tips here and there, via internet tutorials, I bought this book. I really recommend it as I could learn a lot. Fabien Serny explains everything in a easy way, doesn't waste our time and cover almost every topic you need to know on PrestaShop modules development.PS: just to make it clear, if you are looking for installation and themes development, this is not the right book for you.
Amazon Verified review Amazon
Alessandro Feb 10, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Prestashop documentation is an area that needs improvement and this book is a much needed help.It follows a very practical approach and guides to the development of some useful custom modules with source code commentary and some insights to the general Prestashop architecture, the book is well written and concise.It helped me to get a better confidence with the platform and gave a boost to the development of a custom module I'm working to.Here are the chapters:Table of ContentsPreface1. Creating a New Module2. Hooks3. Using Context and its Methods4. Building Module Updates5. Front Controllers, Object Models, and Overrides6. Admin Controllers and Hooks7. The Carrier Module8. The Payment Module9. Multistore10. Security and PerformanceAppendix: Native HooksIndex
Amazon Verified review Amazon
Matteo Nardi Mar 27, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Veramente un ottimo libro per lo sviluppo di moduli prestashop personali. Completo e con esempi ben presentati e spiegati. Consigliato.
Amazon Verified review Amazon
Fabio Mar 12, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Il libro affronta praticamente lo sviluppodi un modulo completo curandone tutti gliaspetti riga per riga e spiegandone il motivo.La lettura è molto piacevole e scorrevole.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela