Image Caption
Showing posts with label get cookie in prestashop. Show all posts
Showing posts with label get cookie in prestashop. Show all posts

Saturday, October 27, 2012

Prestashop get Cookie value (or) Cart value


Step: 1
Create a new file in home directory named as "get_cookie.php"

Step: 2
Add the Below code to "get_cookie.php"

<?php
require_once dirname(__FILE__) . '/config/config.inc.php' ;
require_once(dirname(__FILE__) . '/config/settings.inc.php');
require_once dirname(__FILE__) . '/init.php' ;

function getAllCookies(){
global $cookie ;
// var_dump($cookie);
return $cookie;
}

$cookies = getAllCookies();

$query = "SELECT p.id_product,pp.id_category_default, pl.name, p.quantity, pp.price, p.id_product_attribute, pp.price * cu.conversion_rate AS orderprice, cu.sign, cu.format FROM ps_cart c
LEFT JOIN ps_cart_product p ON (p.id_cart = c.id_cart)
LEFT JOIN ps_product pp ON (pp.id_product = p.id_product)
LEFT JOIN ps_product_lang pl ON (pl.id_product = p.id_product)
LEFT JOIN ps_currency cu ON (cu.id_currency = c.id_currency)

WHERE c.id_cart = " . (int) $cookies->id_cart . " AND pl.id_lang = 1
ORDER BY p.date_add ASC";


$link1 = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);

if ($link1) {
$db_selecteds = @mysql_select_db(_DB_NAME_, $link1);
$ress = mysql_query($query);
$arrProductss = array();
$sd=0;
while ($rows = mysql_fetch_assoc($ress)) {
 $arrProducts[] = $rows;
 print_r($arrProducts[$sd]);
  $sd++;
}

var_dump($arrProducts); // all products from session cart
}
mysql_close($link1);
?>

Step: 3
Add some product to your website cart. Then Access the get_cookie.php in your browser
"www.yoursite.com/get_cookie.php". It so the product information