1

I'm using Prestashop 1.6. I think I need to update the JQuery version to use Fancybox 3.

I looked at FTP /public_html/js/jquery, jquery-1.11.0.min.js file is available. So JQuery is not up to date. I changed the name of this file to old_jquery-1.11.0.min.js. I have installed the jquery-3.4.1.min.js file. But it doesn't work.

Is there a configuration file in which I can enter the current file path? Or is the update done in another way?

Agah Toruk
  • 383
  • 5
  • 10

1 Answers1

3

PrestaShop is using the addJquery() method from the Controller class which allows you to decides which path/version of Jquery you'd like to include for a specific page. This also allows you to run two versions of jQuery at the same time (by using the noConflict flag as described here)

The addJquery() method uses a static method to get jQuery's path: Media::getJqueryPath() which is itself using the _PS_JQUERY_VERSION_ constant.

Therefore, there are two places where you would need to make changes:

Admin Panel

  • File: classes/controller/AdminController.php on line 3831 in PrestaShop 1.6.1.24

    <script src='"._PS_JS_DIR_."jquery/jquery-1.11.0.min.js'></script>

Defines

  • File: /config/defines.inc.php on line 217 in PrestaShop 1.6.1.24

    define('_PS_JQUERY_VERSION_', '1.11.0');

However, I would recommend against it due to possible side effects with some jQuery plugins used by PrestaShop (both on the back-end and front-end).

A alternate solution would be to:

  • Keep these files as is
  • Override the setMedia() method in classes/controller/FrontController.php
  • Specify the jQuery 3.4.1 version in $this->addJquery() (line 952 in PrestaShop 1.6.1.24) - only if you detect that the current controller is ProductControllerCore

I hope this helps!

Bruno Leveque
  • 2,647
  • 2
  • 23
  • 33