stefandunn Posted February 17, 2014 Share Posted February 17, 2014 What's the best way of adding the basket on a page outside of the shop, my idea being that we have a website which has a CMS system like Wordpress which then redirects to the Prestashop when they click on "Shop". The client would like the basket to appear across all pages, so we will need to add it to header of our CMS which exists outside of Prestashop. I know that there is RESTful API, but I don't think this will work with the basket widget. Any idea how this can be done? Regards Link to comment Share on other sites More sharing options...
prestashopninja Posted February 17, 2014 Share Posted February 17, 2014 You may see the example below. I think it's enough to show the idea. If you put this one on the main PS installation directory, it will work out of the box, without any CSS formatting, so you can also format it later to fit your CMS's design. You may also clone blockcart module if you want to make a totally different cart template. <?php include_once(dirname(__FILE__).'/config/config.inc.php'); include_once(dirname(__FILE__).'/init.php'); include_once(dirname(__FILE__).'/modules/blockcart/blockcart.php'); $blockcart = new blockcart(); $context = Context::getContext(); echo $blockcart->hookRightColumn(array('cookie' => $context->cookie , 'cart' => $context->cart)); Link to comment Share on other sites More sharing options...
stefandunn Posted February 17, 2014 Author Share Posted February 17, 2014 You may see the example below. I think it's enough to show the idea. If you put this one on the main PS installation directory, it will work out of the box, without any CSS formatting, so you can also format it later to fit your CMS's design. You may also clone blockcart module if you want to make a totally different cart template. <?php include_once(dirname(__FILE__).'/config/config.inc.php'); include_once(dirname(__FILE__).'/init.php'); include_once(dirname(__FILE__).'/modules/blockcart/blockcart.php'); $blockcart = new blockcart(); $context = Context::getContext(); echo $blockcart->hookRightColumn(array('cookie' => $context->cookie , 'cart' => $context->cart)); Do I save this as index.php then in the PS root directory? Link to comment Share on other sites More sharing options...
prestashopninja Posted February 17, 2014 Share Posted February 17, 2014 You may save it for example as "displayCart.php" in the PS root directory. Assume you have your PS installation at /var/www/yoursite.com/ps and yoursite.com/ps on the browser leads to your ps website. The easiest way would be to call this file within an iframe targeting yoursite.com/ps/displayCart.php, so you may access it from within your CMS pages or anywhere else. Link to comment Share on other sites More sharing options...
stefandunn Posted February 18, 2014 Author Share Posted February 18, 2014 You may save it for example as "displayCart.php" in the PS root directory. Assume you have your PS installation at /var/www/yoursite.com/ps and yoursite.com/ps on the browser leads to your ps website. The easiest way would be to call this file within an iframe targeting yoursite.com/ps/displayCart.php, so you may access it from within your CMS pages or anywhere else. Many thanks, I'll give it ago. Would this work if I ajax loaded it instead of using an iframe? Or even using PHP include? Link to comment Share on other sites More sharing options...
prestashopninja Posted February 18, 2014 Share Posted February 18, 2014 Virtually everything is possible. However if you want to use include from outside PS main directory, I guess you'd need to alter the PS code as it would probably redirect you to the PS main page. Ajax: Why not? Now that you know how to init. a Prestashop stack, you could also make a separate module out of blockcart, which would display only the total price for example. Those are simple examples and the sky is the limit. I'm sure you'll find much more elegant ways to use this approach. Keep on trying and keep us posted when you'll come up with something brilliant. Link to comment Share on other sites More sharing options...
Recommended Posts