Plugin / PrestaShop Integration

François Pons

Frequently Asked Questions (FAQ)

No, the plugin will not work with any PrestaShop older than 1.4 because the internal structure of PrestaShop has been improved since 1.4 by using a FrontController class. This plugin add support by adding a specific controller for integration with WordPress. It could be possible to add support for PrestaShop 1.3 or older, but it need to be coded. So to get support for PrestaShop Integration, the better is that you upgrade your PrestaShop to at least 1.4 series. You will get furthermore newer functionnalities and bug fixes.
Yes, it should. But If It doesn’t work, you may need to update PrestaShop autoload behaviour as indicated below. PrestaShop 1.4 is an old version now, and has not been tested with this release. If your installation is working nicely, please do not update as the 0.9.1 release only add features for newer PrestaShop.
Yes, only since version 0.8 which is still compatible with PrestaShop 1.4.
Yes, at least using 0.9.1 (0.9 may be working on some case, but new themes structure may have been hard to integrate).
Yes, at least using 0.9.4 but you may need to patch PrestaShop classes/controller/Controller.php as follows in order to force ajax request to save cookie : --- classes/controller/Controller.php.orig 2018-11-06 20:24:21.000000000 +0000 +++ classes/controller/Controller.php 2019-03-05 07:42:15.960964683 +0000 @@ -687,6 +687,9 @@ Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => $value)); Hook::exec('actionAjaxDie'.$controller.$method.'Before', array('value' => $value)); + if (isset(Context::getContext()->cookie)) + Context::getContext()->cookie->write(); + die($value); } PrestaShop 1.7 can be easier to integrate natively as a lot of small files are included, furthermore inclusion of template files with variable are not yet supported, so you will have to take care of them being made from smarty directly. For example, including a _partials/stylesheet.tpl file will be done like that (do not forget templates leading directory) : A new function ps_body_class is an helper function to automatically adds body classes for PrestaShop (inspired from the body_class function of WordPress). Here is an example for adding the class layout-left-column but removing the class layout-full-width given by PrestaShop : > Another example for a typical footer.php PHP calls juste before the line (ps_get_template_vars() has been improved to simplify access to $javascript.bottom smarty expression here) : The above code is the direct translation of the PrestaShop 1.7 template code : {block name='javascript_bottom'} {include file="_partials/javascript.tpl" javascript=$javascript.bottom} {/block} {block name='hook_before_body_closing_tag'} {hook h='displayBeforeBodyClosingTag'} {/block}
Yes, it should work. Note that the version 0.9.8 has been fixed to use the right PrestaShop favicon to import, or the may shop favicon may be used. Furthermore, it may be needed to fix classes/shpop/Shop.php file to choose the right shop according to domain used. A new feature was added in version 0.9.8 to “import” PrestaShop frontpage for the WordPress frontpage but notice that no links are changed and duplicate content may appear if you do not take care. The plugin has been tested with a single PrestaShop shop and WordPress multisite and with both multishop and multisite.
If you are using PrestaShop 1.5 and you installed WordPress in root of your hosting and PrestaShop in a subdirectory, you will get this error. You need to patch PrestaShop file classes/shop/Shop.php as follows : --- classes/shop/Shop.php.orig 2013-01-07 09:18:32.000000000 +0100 +++ classes/shop/Shop.php 2013-01-07 09:25:26.000000000 +0100 @@ -368,6 +368,9 @@ if (!Validate::isLoadedObject($default_shop)) throw new PrestaShopException('Shop not found'); + if (defined('PRESTASHOP_INTEGRATION_VERSION')) { + $shop = $default_shop; + } else { $params = $_GET; unset($params['id_shop']); if (!Configuration::get('PS_REWRITING_SETTINGS')) @@ -388,6 +391,7 @@ } header('location: '.$url); exit; + } } } But you may notice other redirection which should be deactivated also, according to your PrestaShop version. The patch below is for a PrestaShop 1.6 version : --- classes/shop/Shop.php.orig 2015-03-05 09:03:41.340455129 +0100 +++ classes/shop/Shop.php 2016-02-11 20:57:05.779965183 +0100 @@ -345,6 +345,8 @@ } // If an URL was found but is not the main URL, redirect to main URL + /* BEGIN HACK : do not redirect */ + if (!defined('PRESTASHOP_INTEGRATION_VERSION')) if ($through && $id_shop && !$is_main_uri) { @@ -362,6 +364,7 @@ } } } + /* END HACK */ } $http_host = Tools::getHttpHost(); @@ -401,7 +404,11 @@ // Hmm there is something really bad in your Prestashop ! if (!Validate::isLoadedObject($default_shop)) throw new PrestaShopException('Shop not found'); - + if (defined('PRESTASHOP_INTEGRATION_VERSION')) { + // HACK for PrestaShop Integration + $params['id_shop'] = $id_shop = $default_shop->id; + $shop = $default_shop; + } else { $params = $_GET; unset($params['id_shop']); $url = $default_shop->domain; @@ -422,6 +429,7 @@ header('HTTP/1.0 '.$redirect_type.' Moved'); header('location: http://'.$url); exit; + } } elseif (defined('_PS_ADMIN_DIR_') && empty($shop->physical_uri)) { This bug is caused by PrestaShop trying to figure out which shop is used as it support now the multishop feature. The way it is done is causing the bug, the patch above is mandatory to avoid a redirection being made to the default shop.
You may be using a WordPress plugin that use PHP autoloader, but PrestaShop assume it is the only one using PHP autoloader : you need to modify the config/autoload.php file by changing the name of the function (for example : __autoload_prestashop) and to add at the end of the file the following line : spl_autoload_register('__autoload_prestashop'); Note that PS 1.6 has fixed this problem, you do not need to patch the code anymore.
You need to patch PrestaShop cookie management because this problems occurs where PrestaShop is installed in a child directory of WordPress. Please replace the $this->_path in setcookie invocation by simply '/'. This will make the cookie available to WordPress. you may use override functionnality in PrestaShop to simplify PrestaShop update in the future. Here is a code sample below if the shop is in a subdirectory and the wordpress in ‘/’ from class/Cookie.php : if (PHP_VERSION_ID <= 50200) { /* PHP version > 5.2.0 */ return setcookie($this->_name, $content, $time, '/' /* $this->_path */, $this->_domain, $this->_secure); } else { return setcookie($this->_name, $content, $time, '/' /* $this->_path */, $this->_domain, $this->_secure, true); } If you try to use two distinct domains for the blog and the shop, it will not work and it is not fixable. At least you need to use two subdomains of the same domain for the blog and the shop, and apply the cookie management to the common domain. This patch is not necessary when WordPress is installed in a child directory of PrestaShop installation, typically named blog.
You are probably using PrestaShop 1.6 and the theme has a special file called global.tpl wich collect all the JS variable you need to include it manually as follow in header.tpl (or footer.tpl if you have chosen to move JS code at the end) :
You have a specific public function for that, for example for the custom hook displayBanner you can put in your WordPress theme :
This plugin does not sync PrestaShop and WordPress set of JavaScript ! Jquery is used by both PrestaShop and WordPress, but PrestaShop generally uses old JS files, and WordPress newer version… So in order to avoid conflicts and so on, you may consider something like that (if your PrestaShop is using JQuery 1.11.0, please check, you may need to add other scripts as well) : function mytheme_init() { if ( !is_admin() ) { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', '', array(), '1.11.0' ); wp_enqueue_style( 'jquery' ); } } add_action( 'init', 'mytheme_init' );

Ratings

4.6
13 reviews

Rating breakdown

Details Information

Version

0.9.11

First Released

10 Dec, 2015

Total Downloads

24,319

Wordpress Version

3.3.0 or higher

Tested up to:

5.2.4

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.