Post by heizo » Wed Feb 09, 2011 2:55 am

Ive used the methods that were depicted in an earlier post from 2009 concerning getting the opencart session over to wordpress, but I keep running into errors...

here is what I was using.

Code: Select all

require_once('../Store/config.php');
require_once(DIR_SYSTEM . 'startup.php');
require_once(DIR_SYSTEM . 'engine/registry.php');
require_once(DIR_SYSTEM . 'library/session.php');
require_once(DIR_SYSTEM . 'library/request.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/customer.php');

  
// Session
$session = new Session();
Registry::set('session', $session);

// Request
$request = new Request();
Registry::set('request', $request);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
Registry::set('db', $db);

$customer = new Customer();
$logged = $customer->isLogged();
which gives me this error :

HP Fatal error: Using $this when not in object context in /var/www/vhosts/officeoutofthebox.net/httpdocs/Store/system/engine/registry.php on line 10

If anyone knows of a fix or an easier way to get this data, please let me know.

New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by heizo » Wed Feb 09, 2011 4:11 am

ok, managed to figure it out - probably have a lot more includes then I need but at least its working. I put this in the header.php file right under the comments on the top.

Code: Select all

require_once('../Store/config.php'); // Url to your store config.php in the root of the openCart directory
// 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/length.php');
require_once(DIR_SYSTEM . 'library/cart.php');
// Engine
require_once(DIR_SYSTEM . 'engine/action.php'); 
require_once(DIR_SYSTEM . 'engine/controller.php');
require_once(DIR_SYSTEM . 'engine/front.php');
require_once(DIR_SYSTEM . 'engine/loader.php'); 
require_once(DIR_SYSTEM . 'engine/model.php');
require_once(DIR_SYSTEM . 'engine/registry.php');

// Common
require_once(DIR_SYSTEM . 'library/cache.php');
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/document.php');
require_once(DIR_SYSTEM . 'library/image.php');
require_once(DIR_SYSTEM . 'library/language.php');
require_once(DIR_SYSTEM . 'library/log.php');
require_once(DIR_SYSTEM . 'library/mail.php');
require_once(DIR_SYSTEM . 'library/pagination.php');
require_once(DIR_SYSTEM . 'library/request.php');
require_once(DIR_SYSTEM . 'library/response.php');
require_once(DIR_SYSTEM . 'library/session.php');
require_once(DIR_SYSTEM . 'library/template.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// 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);

// Request
$request = new Request();
$registry->set('request', $request);

// 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));

// Length
$registry->set('length', new Length($registry));

// Cart
$registry->set('cart', new Cart($registry));

$logged = $registry->get('session')->data['customer_id']; ?>


then just check $logged on an if statement, true is logged in, false is not logged in. One thing to make sure is that your root URLS are the same in wordpress and your store...so if one is www.yoursite.com, and the other is yoursite.com...the session doesn't carry over...struggled with that for a very long time :(

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by hubmedia » Mon Feb 14, 2011 9:42 pm

Did you manage to get the cart items and total to display as well? Any help on adding this would be appreciated.

Newbie

Posts

Joined
Mon Feb 14, 2011 9:38 pm

Post by heizo » Mon Feb 14, 2011 11:55 pm

Currently working on that aspect - will post code up within the next few days on what needs to be added to do so.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by heizo » Thu Feb 17, 2011 3:44 am

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'];

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by RJonesUSC » Fri Feb 18, 2011 6:40 am

Thanks for posting that code. It's gotten me started handling OC user sessions on external pages. Looking forward to seeing how you mod this.

Is it possible to retrieve quantity, totals, etc. from the cart? I'm looking to use this somehow to quick print a cart and also send a quick email of the cart contents.

Thanks again!

New member

Posts

Joined
Tue Feb 15, 2011 4:03 am

Post by heizo » Wed Feb 23, 2011 3:58 am

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'];

?>

Code: Select all

Replace all of your get_header() 
with include

Code: Select all

(TEMPLATEPATH . "/header.php"); ?>
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.

Now I made a cart module in the sidebar and my code looks like this.

Code: 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']; ?>">&nbsp;</span></td><td valign="top" align="right" style="width:1px"><?php echo $product['quantity']; ?>&nbsp;x&nbsp;</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>


<!--  .......................................................... -->
Make sure to include the jQuery attachment in your header
<script type="text/javascript" src="address to your store/catalog/view/javascript/jquery/jquery-1.3.2.min.js"></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.

Enjoy.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by hubmedia » Fri Mar 04, 2011 3:04 am

That's excellent. Many thanks for putting this together!

Newbie

Posts

Joined
Mon Feb 14, 2011 9:38 pm

Post by kdmp » Mon Mar 07, 2011 11:44 am

I like this, but how do you overcome having to db connections open at the same time? I keep receiving this error:
Error: Could not make a database connection using opencc@localhost
I like heizo's suggestion, but I am not sure how I could get this to work.

Thanks,

Kevin

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'];

Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details


Active Member

Posts

Joined
Thu Jun 04, 2009 10:40 am
Location - Ontario, Canada

Post by heizo » Mon Mar 07, 2011 12:06 pm

Hmmm, I used the same database for both systems, just used a different prefix for Opencart and wordpress - so they both had the same connection info. Just make sure the info in your opencart config file (I believe that is where its stored) Is correct along with your wordpress, otherwise all I can recommend is renaming the opencart variables it uses (in the config file under the //DB comment) for connecting (some of them are the same as wordpress) and do a close connection / open connection before and after your code depending on which database your trying to get to.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by kdmp » Tue Mar 08, 2011 12:30 am

I wasn't thinking about that!! Thanks!

Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details


Active Member

Posts

Joined
Thu Jun 04, 2009 10:40 am
Location - Ontario, Canada

Post by heizo » Tue Mar 08, 2011 1:13 am

actually, I just remembered if you rename stuff in the config file you will be breaking opencart - you will have to rewrite that file in your header instead of including it - or you can save a wordpress version of it.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by kdmp » Tue Mar 08, 2011 4:21 am

I am not sure if I did that right then. I got it working - where I could see that there was 3 items in my cart and that I was logged in. Only problem is when the registry-> object kicked in it broke the wordpress footer. Not sure why. Ever seen that before??? lol

Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details


Active Member

Posts

Joined
Thu Jun 04, 2009 10:40 am
Location - Ontario, Canada

Post by heizo » Tue Mar 08, 2011 5:10 am

did you use an include for the footer or get_footer(), you need to use an include to make sure the database variables are passed to all parts of your template. Try that.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by kdmp » Tue Mar 08, 2011 6:55 am

Ya, but the footer is still going to be controlled by Wordpress. I only want to add the cart and login session data to be used in wordpress. What you have provided works great. But it partially stops the footer from wordpress from loading.

Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details


Active Member

Posts

Joined
Thu Jun 04, 2009 10:40 am
Location - Ontario, Canada

Post by kdmp » Tue Mar 08, 2011 11:23 am

You were right...I used includes instead of get_. Worked like a charm!!

I do have a question - how would I go about adding the total cost of what is in the cart? Also, I am using the cart in the header modification. I have noticed that it is not counting the number of items in the cart correctly. It counts items and the quantities...so say there is 3 items in the cart and one of those items has 2 in qty...it counts 4 items in the cart. If I count the number of items in the cart for the wordpress side it will only report 3 items.

So basically I will get different counts from wordpress to opencart. I guess a better question would be how to count the quantities in the cart instead of the number of items in the cart.

Thanks!

Kevin Davidson
Purolator Shipping Module
Canpar Shipping Module
VQMod - Paypal Transaction ID to Payment Details


Active Member

Posts

Joined
Thu Jun 04, 2009 10:40 am
Location - Ontario, Canada

Post by heizo » Tue Mar 08, 2011 1:46 pm

Total cost was included in my sidebar cart example...I was not getting a bad count in my example that I see, you may want to investigate the code a little to see if there are any bugs.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by Harold Nixon » Wed Apr 06, 2011 1:09 am

Hello all,

I've been following this, and other threads trying to get my OC login/out session to work in Wordpress....but everytime I log into OC (domain/shop) and navigate to my Wordpress page (domain/blog) the session ends (I guess.... :-[ )
My link doesn't change from Login to Logout on the Wordpress page and when I navigate back to OC I have to login again.

I'm using Version 1.4.9.4

Thanks for any help...and keep up the good work :)

Newbie

Posts

Joined
Wed Oct 06, 2010 10:15 am

Post by heizo » Wed Apr 06, 2011 1:20 am

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.

My Blog / Site

$1 Hosting and Free Domain Name for OpenCart, Wordpress, Joomla, Droopal


New member

Posts

Joined
Wed Feb 09, 2011 1:12 am

Post by Harold Nixon » Wed Apr 06, 2011 2:22 am

Thanks for your reply,

I don't have SSL enable yet.....I've been going baby steps and painting by the numbers.

Any other suggestions off the top of your head?

Newbie

Posts

Joined
Wed Oct 06, 2010 10:15 am
Who is online

Users browsing this forum: No registered users and 8 guests