My Blog / Site
$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal
Hi Heizo,heizo wrote:if you log in and have SSL enabled (https), the session is wrapped in your SSL, so if you navigate back to your wordpress and wordpress is not wrapped in SSL (so its HTTP and not HTTPS) then you loose the session...I had to wrap both wordpress and the entire shopping cart in SSL to get my sessions to stick through the entire experience.
Let me know if this helps.
Can you let us know how you wrapped both Wordpress and the entire cart in SSL to get your sessions to stick through the entire experience?
Thank you,
SupraTT

My Blog / Site
$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal

I just wrapped all of wordpress into an SSL, so both sides were encrypted. (took some header moding and a few plugins but eventually you can get everything swapped over to SSL)
Other then that little aspect, the code still works and is finished - havn't heard anything back about the wordpress plugin.
My Blog / Site
$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal
Code: Select all
<? if (isset($_SESSION[customer_id])) { ?>
Now i want a language switch on my site, but the translation variables like
Code: Select all
<?php echo $text_login; ?>

Here's the entirety of my code, modified with my filepath:
Code: Select all
</php
//////////////////// Open Cart Login Info
// Configuration
require_once('spradleyshop/config.php');
// Application Classes
require_once(DIR_SYSTEM . 'spradleyshop/system/library/customer.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/currency.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/tax.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/weight.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/cart.php');
// Engine
require_once(DIR_SYSTEM . 'spradleyshop/system/engine/controller.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/engine/registry.php');
// Common
require_once(DIR_SYSTEM . 'spradleyshop/system/library/config.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/db.php');
require_once(DIR_SYSTEM . 'spradleyshop/system/library/session.php');
// Registry
$registry = new Registry();
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Session
$session = new Session();
$registry->set('session', $session);
// Customer
$registry->set('customer', new Customer($registry));
// Currency
$registry->set('currency', new Currency($registry));
// Tax
$registry->set('tax', new Tax($registry));
// Weight
$registry->set('weight', new Weight($registry));
// Cart
$registry->set('cart', new Cart($registry));
require_once(DIR_APPLICATION . 'spradleyshop/catalog/controller/checkout/cart.php');
$product_id = $registry->get('cart')->session->data['cart'];
//var_dump($registry->get('cart')->session->data['cart']);
$tf = false;
foreach($product_id as $p=>$val) {
$array = explode(':', $p);
$product_id = $array[0];
$key = $array[0].':'.$array[1];
if (isset($array[1])) {
$options = explode('.', $array[1]);
} else {
$options = array();
}
$cartSQL = mysql_fetch_assoc(mysql_query("
SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock FROM " . DB_PREFIX . "product p
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)
LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id)
LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id)
WHERE p.product_id = '".$product_id."' AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'"));
////////////////////
foreach ($options as $product_option_value_id) {
$option_value_query = mysql_query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "product_option_value_description povd ON (pov.product_option_value_id = povd.product_option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_id = '" . (int)$product_id . "' AND povd.language_id = '1' ORDER BY pov.sort_order");
if (mysql_num_rows($option_value_query)) {
$option_value_query = mysql_fetch_assoc($option_value_query);
$option_query = mysql_fetch_assoc(mysql_query("SELECT pod.name FROM " . DB_PREFIX . "product_option po LEFT JOIN " . DB_PREFIX . "product_option_description pod ON (po.product_option_id = pod.product_option_id) WHERE po.product_option_id = '" . (int)$option_value_query['product_option_id'] . "' AND po.product_id = '" . (int)$product_id . "' AND pod.language_id = '1' ORDER BY po.sort_order"));
$option_data[] = array(
'product_option_value_id' => $product_option_value_id,
'name' => $option_query['name'],
'value' => $option_value_query['name'],
'prefix' => $option_value_query['prefix'],
'price' => $option_value_query['price']
);
}
}
////////////////////
$products[] = array(
'key' => $key,
'product_id' => $product_id,
'name' => $cartSQL['name'],
'option' => $option_data,
'quantity' => $val,
'stock' => $cartSQL['stock'],
'price' => $cartSQL['price'],
'tax_class_id' => $cartSQL['tax_class_id'],
'url' => 'http://spradleyshop.wiwtyproject.com/index.php?route=product/product&product_id=' . $product_id
);
unset($option_data);
}
//var_dump($option_data);
//var_dump($products);
$logged = $registry->get('session')->data['customer_id'];
?>
heizo wrote:Tried to trim down some of the includes that wasn't needed, still probably not the most efficient but it works. I get login status and cart information. From there you can mod it how you see fit.
NOTE: I am only using one language, wasn't able to figure out how to get language IDs in the time allotted to me, so I manually put them in. From the default install this should work for English.
The products are in a query called $cartSQL and the login info is a bool called $logged. This goes into your header as before.
Code: Select all
// Configuration require_once('../Store/config.php'); // Application Classes require_once(DIR_SYSTEM . 'library/customer.php'); require_once(DIR_SYSTEM . 'library/currency.php'); require_once(DIR_SYSTEM . 'library/tax.php'); require_once(DIR_SYSTEM . 'library/weight.php'); require_once(DIR_SYSTEM . 'library/cart.php'); // Engine require_once(DIR_SYSTEM . 'engine/controller.php'); require_once(DIR_SYSTEM . 'engine/registry.php'); // Common require_once(DIR_SYSTEM . 'library/config.php'); require_once(DIR_SYSTEM . 'library/db.php'); require_once(DIR_SYSTEM . 'library/session.php'); // Registry $registry = new Registry(); // Config $config = new Config(); $registry->set('config', $config); // Database $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $registry->set('db', $db); // Session $session = new Session(); $registry->set('session', $session); // Customer $registry->set('customer', new Customer($registry)); // Currency $registry->set('currency', new Currency($registry)); // Tax $registry->set('tax', new Tax($registry)); // Weight $registry->set('weight', new Weight($registry)); // Cart $registry->set('cart', new Cart($registry)); require_once(DIR_APPLICATION . 'controller/module/cart.php'); $product_id = $registry->get('cart')->session->data['cart']; $tf = false; foreach($product_id as $p=>$val) { if($tf) { $sql .= 'OR p.product_id = "'.$p.'"'; }else{ $tf = true; $sql = 'p.product_id = "'.$p.'"'; } } $cartSQL = mysql_query(" SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE (" . $sql . ") AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'"); while($row = mysql_fetch_array($cartSQL)) { echo $row['name']; } $logged = $registry->get('session')->data['customer_id'];
Attachments
This is the suggested code added to WP header.php file WITH the opening <?php - screenshot2.jpg (277.75 KiB) Viewed 28325 times
This is the suggested code added to WP header.php file without the opening <?php - screenshot1.jpg (349.32 KiB) Viewed 28325 times
Change that and see if that works.
My Blog / Site
$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal
Sending you a message right now

Code: Select all
<?php
// begin the session
session_start();
if(isset($_SESSION['customer_id']))
{
$logged_in= true;
}
else
{
$logged_in = false;
}
?>
I am trying to integrate your code, with my ultimate goal to display the cart header links (welcome, shopping cart items, wishlist links etc.) from inside my wordpress / genesis theme. I have added your code that loads all of the opencart config into my functions.php (genesis doesn't use header.php), and also the link code from the openart header.tpl. but when i load my page, i get a bunch of errors.
Im using Wordpress 3.3.2 and Genesis 1.8.1
My functions.php code looks like this:
Code: Select all
// Configuration
require_once('/home/website/public_html/shop/config.php');
// Application Classes
require_once(DIR_SYSTEM . 'library/customer.php');
require_once(DIR_SYSTEM . 'library/currency.php');
require_once(DIR_SYSTEM . 'library/tax.php');
require_once(DIR_SYSTEM . 'library/weight.php');
require_once(DIR_SYSTEM . 'library/cart.php');
// Engine
require_once(DIR_SYSTEM . 'engine/controller.php');
require_once(DIR_SYSTEM . 'engine/registry.php');
// Common
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/session.php');
// Registry
$registry = new Registry();
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Session
$session = new Session();
$registry->set('session', $session);
// Customer
$registry->set('customer', new Customer($registry));
// Currency
$registry->set('currency', new Currency($registry));
// Tax
$registry->set('tax', new Tax($registry));
// Weight
$registry->set('weight', new Weight($registry));
// Cart
$registry->set('cart', new Cart($registry));
require_once(DIR_APPLICATION . 'controller/module/cart.php');
$product_id = $registry->get('cart')->session->data['cart'];
//var_dump($registry->get('cart')->session->data['cart']);
$tf = false;
foreach($product_id as $p=>$val) {
$array = explode(':', $p);
$product_id = $array[0];
$key = $array[0].':'.$array[1];
if (isset($array[1])) {
$options = explode('.', $array[1]);
} else {
$options = array();
}
$cartSQL = mysql_fetch_assoc(mysql_query("
SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock FROM " . DB_PREFIX . "product p
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)
LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id)
LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id)
WHERE p.product_id = '".$product_id."' AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'"));
////////////////////
foreach ($options as $product_option_value_id) {
$option_value_query = mysql_query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "product_option_value_description povd ON (pov.product_option_value_id = povd.product_option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_id = '" . (int)$product_id . "' AND povd.language_id = '1' ORDER BY pov.sort_order");
if (mysql_num_rows($option_value_query)) {
$option_value_query = mysql_fetch_assoc($option_value_query);
$option_query = mysql_fetch_assoc(mysql_query("SELECT pod.name FROM " . DB_PREFIX . "product_option po LEFT JOIN " . DB_PREFIX . "product_option_description pod ON (po.product_option_id = pod.product_option_id) WHERE po.product_option_id = '" . (int)$option_value_query['product_option_id'] . "' AND po.product_id = '" . (int)$product_id . "' AND pod.language_id = '1' ORDER BY po.sort_order"));
$option_data[] = array(
'product_option_value_id' => $product_option_value_id,
'name' => $option_query['name'],
'value' => $option_value_query['name'],
'prefix' => $option_value_query['prefix'],
'price' => $option_value_query['price']
);
}
}
////////////////////
$products[] = array(
'key' => $key,
'product_id' => $product_id,
'name' => $cartSQL['name'],
'option' => $option_data,
'quantity' => $val,
'stock' => $cartSQL['stock'],
'price' => $cartSQL['price'],
'tax_class_id' => $cartSQL['tax_class_id'],
'url' => 'http://officeoutofthebox.net/Store/index.php?route=product/product&product_id=' . $product_id
);
unset($option_data);
}
//var_dump($option_data);
//var_dump($products);
$logged = $registry->get('session')->data['customer_id'];
}
add_action( 'genesis_header_right', 'openCartHeader' );
Code: Select all
<div id="search">
<div class="button-search"></div>
<?php if ($filter_name) { ?>
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
<?php } else { ?>
<input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
<?php } ?>
</div>
<div id="welcome">
<?php if (!$logged) { ?>
<?php echo $text_welcome; ?>
<?php } else { ?>
<?php echo $text_logged; ?>
<?php } ?>
</div>
<div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
Code: Select all
Notice: Constant DB_PASSWORD already defined in /home/website/public_html/shop/config.php on line 27
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'website_soul'@'localhost' (using password: YES) in /home/website/public_html/shop/system/database/mysql.php on line 6
Notice: Error: Could not make a database link using website_soul@localhost in /home/website/public_html/shop/system/database/mysql.php on line 7
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 10
Notice: Error: Could not connect to database website_soul in /home/website/public_html/shop/system/database/mysql.php on line 11
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 14
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 15
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 16
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 17
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/website/public_html/wp-content/themes/genesis/lib/structure/header.php:31) in /home/website/public_html/shop/system/library/session.php on line 11
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 21
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 49
Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 49
Notice: Error:
Error No:
SELECT * FROM currency in /home/website/public_html/shop/system/database/mysql.php on line 49
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/website/public_html/shop/system/database/mysql.php on line 67
heizo wrote:Tried to trim down some of the includes that wasn't needed, still probably not the most efficient but it works. I get login status and cart information. From there you can mod it how you see fit.
NOTE: I am only using one language, wasn't able to figure out how to get language IDs in the time allotted to me, so I manually put them in. From the default install this should work for English.
The products are in a query called $cartSQL and the login info is a bool called $logged. This goes into your header as before.
Code: Select all
// Configuration require_once('../Store/config.php'); // Application Classes require_once(DIR_SYSTEM . 'library/customer.php'); require_once(DIR_SYSTEM . 'library/currency.php'); require_once(DIR_SYSTEM . 'library/tax.php'); require_once(DIR_SYSTEM . 'library/weight.php'); require_once(DIR_SYSTEM . 'library/cart.php'); // Engine require_once(DIR_SYSTEM . 'engine/controller.php'); require_once(DIR_SYSTEM . 'engine/registry.php'); // Common require_once(DIR_SYSTEM . 'library/config.php'); require_once(DIR_SYSTEM . 'library/db.php'); require_once(DIR_SYSTEM . 'library/session.php'); // Registry $registry = new Registry(); // Config $config = new Config(); $registry->set('config', $config); // Database $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $registry->set('db', $db); // Session $session = new Session(); $registry->set('session', $session); // Customer $registry->set('customer', new Customer($registry)); // Currency $registry->set('currency', new Currency($registry)); // Tax $registry->set('tax', new Tax($registry)); // Weight $registry->set('weight', new Weight($registry)); // Cart $registry->set('cart', new Cart($registry)); require_once(DIR_APPLICATION . 'controller/module/cart.php'); $product_id = $registry->get('cart')->session->data['cart']; $tf = false; foreach($product_id as $p=>$val) { if($tf) { $sql .= 'OR p.product_id = "'.$p.'"'; }else{ $tf = true; $sql = 'p.product_id = "'.$p.'"'; } } $cartSQL = mysql_query(" SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE (" . $sql . ") AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'"); while($row = mysql_fetch_array($cartSQL)) { echo $row['name']; } $logged = $registry->get('session')->data['customer_id'];
Alice.
require_once('../Store/config.php');
I had to use
require_once('http://www.myurl.com/Store/config.php');
If not the screen would go blank. Even after that I had to hardcode all of the other require_once to get the page to even load... not sure if it is getting the right files at all.
Now I just get the following error:
Error: Could not load database file DB_DRIVER!
My databases are separate. I have tried to change all the database info in this code to be the same as those in the config.php but then I get the error:
Error: Could not load database file mysql!
I haven't change get_ to include yet because I didn't think that it would make a difference in connecting to the session.
Any tips or Ideas on what I am doing wrong? I am using WP 3.5 and OC 1.5.4
heizo wrote:This will get you user session and cart contents including tax and modified prices based on options.
In the header of wordpress add this just below the comment text.
Code: Select all
//////////////////// Open Cart Login Info // Configuration require_once('../Store/config.php'); // Application Classes require_once(DIR_SYSTEM . 'library/customer.php'); require_once(DIR_SYSTEM . 'library/currency.php'); require_once(DIR_SYSTEM . 'library/tax.php'); require_once(DIR_SYSTEM . 'library/weight.php'); require_once(DIR_SYSTEM . 'library/cart.php'); // Engine require_once(DIR_SYSTEM . 'engine/controller.php'); require_once(DIR_SYSTEM . 'engine/registry.php'); // Common require_once(DIR_SYSTEM . 'library/config.php'); require_once(DIR_SYSTEM . 'library/db.php'); require_once(DIR_SYSTEM . 'library/session.php'); // Registry $registry = new Registry(); // Config $config = new Config(); $registry->set('config', $config); // Database $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $registry->set('db', $db); // Session $session = new Session(); $registry->set('session', $session); // Customer $registry->set('customer', new Customer($registry)); // Currency $registry->set('currency', new Currency($registry)); // Tax $registry->set('tax', new Tax($registry)); // Weight $registry->set('weight', new Weight($registry)); // Cart $registry->set('cart', new Cart($registry)); require_once(DIR_APPLICATION . 'controller/module/cart.php'); $product_id = $registry->get('cart')->session->data['cart']; //var_dump($registry->get('cart')->session->data['cart']); $tf = false; foreach($product_id as $p=>$val) { $array = explode(':', $p); $product_id = $array[0]; $key = $array[0].':'.$array[1]; if (isset($array[1])) { $options = explode('.', $array[1]); } else { $options = array(); } $cartSQL = mysql_fetch_assoc(mysql_query(" SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.product_id = '".$product_id."' AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'")); //////////////////// foreach ($options as $product_option_value_id) { $option_value_query = mysql_query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "product_option_value_description povd ON (pov.product_option_value_id = povd.product_option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_id = '" . (int)$product_id . "' AND povd.language_id = '1' ORDER BY pov.sort_order"); if (mysql_num_rows($option_value_query)) { $option_value_query = mysql_fetch_assoc($option_value_query); $option_query = mysql_fetch_assoc(mysql_query("SELECT pod.name FROM " . DB_PREFIX . "product_option po LEFT JOIN " . DB_PREFIX . "product_option_description pod ON (po.product_option_id = pod.product_option_id) WHERE po.product_option_id = '" . (int)$option_value_query['product_option_id'] . "' AND po.product_id = '" . (int)$product_id . "' AND pod.language_id = '1' ORDER BY po.sort_order")); $option_data[] = array( 'product_option_value_id' => $product_option_value_id, 'name' => $option_query['name'], 'value' => $option_value_query['name'], 'prefix' => $option_value_query['prefix'], 'price' => $option_value_query['price'] ); } } //////////////////// $products[] = array( 'key' => $key, 'product_id' => $product_id, 'name' => $cartSQL['name'], 'option' => $option_data, 'quantity' => $val, 'stock' => $cartSQL['stock'], 'price' => $cartSQL['price'], 'tax_class_id' => $cartSQL['tax_class_id'], 'url' => 'http://officeoutofthebox.net/Store/index.php?route=product/product&product_id=' . $product_id ); unset($option_data); } //var_dump($option_data); //var_dump($products); $logged = $registry->get('session')->data['customer_id']; ?>
with includeCode: Select all
Replace all of your get_header()
and anywhere else you want this information to show up at (sidebar, footer) make sure those includes are included with the include function and not wordpress's get function.Code: Select all
(TEMPLATEPATH . "/header.php"); ?>
Now I made a cart module in the sidebar and my code looks like this.
Make sure to include the jQuery attachment in your headerCode: Select all
<?php /** * The Sidebar containing the primary and secondary widget areas. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ ?> <div id="primary" class="widget-area" role="complementary"> <?php if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?> <?php endif; // end primary widget area ?> </div><!-- #primary .widget-area --> <!-- .......................................................... --> <?php $display_price = 1; //var_dump($products); ?> <div id="module_cart"> <div><img src="http://www.officeoutofthebox.net/Store/catalog/view/theme/default/image/shopping_cart_header.jpg" alt="" /></div> <table cellpadding="4" cellspacing="0" style="width: 232px; border-left:#ebebeb 1px solid; border-right:#ebebeb 1px solid; border-bottom:#ebebeb 1px solid; "> <?php if ($products) { ?> <?php foreach ($products as $product) { ?> <tr> <td align="left" valign="top" style="width:1px"><span class="cart_remove" id="remove_<?php echo $product['key']; ?>"> </span></td><td valign="top" align="right" style="width:1px"><?php echo $product['quantity']; ?> x </td> <td align="left" valign="top"><a class="cartLink" href="<?php echo $product['url']; ?>"><?php echo $product['name']; ?></a> <div> <?php foreach ($product['option'] as $key => $value) { ?> - <small style="color: #999;"><?php echo $value['name']; ?> : <?php echo $value['value']; ?></small><br /> <?php if($value['prefix'] == '+') { $product['total'] = $product['price'] + $value['price']; }else if ($value['prefix'] == '-') { $product['total'] = $product['price'] - $value['price']; } } ?> </div></td> </tr> <?php $total += $product['price'] * $product['quantity']; /////////////// if ($product['tax_class_id']) { if (!isset($taxes)) { $taxes = ($product['price'] * $product['quantity']) / 100 * $registry->get('tax')->getRate($product['tax_class_id']); } else { $taxes += ($product['price'] * $product['quantity']) / 100 *$registry->get('tax')->getRate($product['tax_class_id']); } } /////////////// ?> <?php } ?> <tr><td align="right" colspan="3"> <?php if ($display_price) { ?> <table cellpadding="0" cellspacing="0" align="right" style="display:inline-block;"> <tr> <td align="right"><span class="cartTotals"><strong>Sub-Total:</strong></span></td> <td align="right"><span class="cartTotals2"><?php echo number_format($total, 2, '.', ' '); ?></span></td> </tr> <?php if ($taxes > 0) { ?> <tr> <td align="right"><span class="cartTotals"><strong>Ohio Tax:</strong></span></td> <td align="right"><span class="cartTotals2"><?php echo number_format($taxes, 2, '.', ' '); ?></span></td> </tr> <?php } ?> <tr> <td align="right"><span class="cartTotals"><strong>Total:</strong></span></td> <td align="right"><span class="cartTotals2"><?php echo number_format(($total + $taxes), 2, '.', ' '); ?></span></td> </tr> <tr><td colspan="2"><div style="padding-top:5px;text-align:center;clear:both;"><a class="cartLink" href="http://www.officeoutofthebox.net/Store/index.php?route=checkout/cart">View Cart</a> <span class="cartLink">|</span> <a class="cartLink" href="http://www.officeoutofthebox.net/Store/index.php?route=checkout/shipping">Checkout</a></div></td></tr> </table> <?php } ?> <?php } else { ?> <table cellpadding="4" cellspacing="0" style="width: 232px; border-left:#ebebeb 1px solid; border-right:#ebebeb 1px solid; border-bottom:#ebebeb 1px solid; "> <tr><td><div style="text-align: center;">0 items</div></td></tr></table> <?php } ?> </td></tr> </table> <br /> <?php if ($ajax) { ?> <script type="text/javascript" src="catalog/view/javascript/jquery/ajax_add.js"></script> <?php } ?> </div> <script type="text/javascript"><!-- function getUrlParam(name) { var name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; } $(document).ready(function () { $('.cart_remove').live('click', function () { if (!confirm('Confirm?')) { return false; } $(this).removeClass('cart_remove').addClass('cart_remove_loading'); $.ajax({ type: 'post', url: 'http://www.officeoutofthebox.net/Store/index.php?route=module/cart/callback', dataType: 'html', data: 'remove=' + this.id, success: function (html) { $('#module_cart .middle').html(html); if (getUrlParam('route').indexOf('checkout') != -1) { window.location.reload(); } } }); }); }); //--></script> <!-- .......................................................... -->
if you want them to be able to delete items from the cart - also make sure you copy over the appropriate styles for everything.<script type="text/javascript" src="address to your store/catalog/view/javascript/jquery/jquery-1.3.2.min.js"></script>
Enjoy.
Users browsing this forum: No registered users and 8 guests