Jump to content

Display cart in non Prestashop parts of my site


Recommended Posts

The Prestashop is only part of my site, running in /shop and the rest of the site will be built with MODX.

In the MODX pages I want to display a cart summary, something like "You have 1 item in your cart".

I've been looking at the Webservice which I can access as below







but how do I know which cart id is the one for the current user?

Also is this approach the best way to show the cart on external pages or is there a better approach?

Link to comment
Share on other sites

  • 2 weeks later...

I gave up on the web service. I got it working but is was really slow (on my WAMP server).

Instead I got the data by placing the following code in a file in the root of the shop, which seems to work and quickly

<?php
include('config/config.inc.php');
include('init.php');
global $cookie;
$blogcart = $cart->getSummaryDetails();
echo '
Products in cart = ' . count($blogcart['products']) . '';

$cartQty=0;
foreach( $blogcart['products'] as $key => $value){
   $cartQty += $value['cart_quantity'];
}
echo '
Number of items in cart = ' . $cartQty . '';
?>

Link to comment
Share on other sites

  • 8 months later...

I hope you guys can help!

 

My prestashop is located in a sub-directory of my website. Meaning I have a normal website (Home, About, Contact, etc) and there is a link to my prestashop. Is there ANY way at all that I could pull the cart information from Prestashop and place it in the usual php files that compose my run of the mill website?

 

I would highly appreciate any insight!

Link to comment
Share on other sites

  • 8 months later...

Hi @sparkyhd

 

I try to do the same thing like you.

I've made a wp-panier.php file with your code inside :

<?php
include('config/config.inc.php');
include('init.php');
global $cookie;
$blogcart = $cart->getSummaryDetails();
echo '
Products in cart = ' . count($blogcart['products']) . '
';
$cartQty=0;
foreach( $blogcart['products'] as $key => $value){
$cartQty += $value['cart_quantity'];
}
echo '
Number of items in cart = ' . $cartQty . '
';
?>

 

When I visite the page http://www.mywebsite.com/wp-panier.php, all it's good. BUT in my wordpress website http://www.mywebsite.com/blog I have a fatal error :

Fatal error: Call to a member function getSummaryDetails() on a non-object in MY_DOCUMENT_ROOT/wp-panier.php line 5

 

In my header.php file in my theme I write :

<?php  include('../wp-panier-dev.php'); ?>

 

Do you now any issue ?

Edited by znorelo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...