Page 2 of 3
Re: Combining OpenCart with Wordpress
Posted: Wed Aug 25, 2010 3:22 pm
by fireatwire
Has someone tried to combine opencart with wordpress, both in multi-languages? What do I need to do to get it work?
Re: Combining OpenCart with Wordpress
Posted: Fri Aug 27, 2010 6:18 pm
by mystifier
I have been playing around with Wordpress as a front-end to (multi-store) Opencart on a development website but, aside from the fact that it is a single (combined) database and shared stylesheet, the two admins are completely seperate.
It is effectively nothing more than having two templates that look the same.
Re: Combining OpenCart with Wordpress
Posted: Wed Sep 01, 2010 5:37 pm
by fireatwire
Do you have different languages? How do you link the "wordpress language" to your opencart language when hitting the shop-link and switching to the shop?
Re: Combining OpenCart with Wordpress
Posted: Wed Sep 01, 2010 7:18 pm
by mystifier
I don't use multi-languages in either Wordpress or Opencart.
My Wordpress simply has a (multi-store) shop selector page so I guess I would have a version in each language. As far as Opencart goes, each store can have a different default language no problem, so you could have uk.yourstore.com and spain.yourstore.com with a common admin opening in different languages.
Re: Combining OpenCart with Wordpress
Posted: Sun Nov 14, 2010 3:45 pm
by fibebo
hello there,
I've integrated OC into WP as it was suggested in this topic. I have managed to look the design the same. What I can't figure out is how to return to the wp section - blogs etc. from the shop? I would put the main site's link to the Home tab and/or when people click on the header/logo. Or would ad a new tab...
Please give me a detailed answer with codes.
Thank you!
Re: Combining OpenCart with Wordpress
Posted: Mon Nov 15, 2010 11:16 am
by dramony
can you show us some demo? thanks.
Re: Combining OpenCart with Wordpress
Posted: Mon Nov 15, 2010 8:04 pm
by fibebo
demo?
It is my own site. Not something to release - unfortunately.
Re: Combining OpenCart with Wordpress
Posted: Tue Nov 16, 2010 9:47 am
by dramony
can we a have a look at your site?
Re: Combining OpenCart with Wordpress
Posted: Fri Nov 19, 2010 4:12 am
by fibebo
If you promise to tell me the secret.
I wonder why is it so complecated.
Re: Combining OpenCart with Wordpress
Posted: Fri Nov 19, 2010 9:03 am
by cmebd
Very nice site......

Re: Combining OpenCart with Wordpress
Posted: Tue Nov 30, 2010 4:34 am
by broadsighted
I'd like to know if it's possible for them to use the same database.
Wordpress is installed at root, and OpenCart is installed under the directory gallery/.
Can't I just create another table within the "Wordpress Database" for OpenCart? Would OpenCart and Wordpress interfere with each other?
How can I make this work? Or is another database necessary....
Thanks.

Re: Combining OpenCart with Wordpress
Posted: Thu Dec 02, 2010 7:20 am
by mystifier
Of course Wordpress and Opencart can reside in a single database. It is a good idea to use a prefix for both such as wp_ and oc_ to keep a clear segregation.
Although the databases are still effectively seperate, other than that they are in the same physical database for convenience, it does make queries that contain information from both easier.
Re: Combining OpenCart with Wordpress
Posted: Thu Dec 09, 2010 5:45 am
by unknownmale1
I think i am going a backwards way about this....Basically I am aiming for a feed of the latest word press posts to show up on the homepage.
so I added this to home.php
Code: Select all
define('WP_USE_THEMES', false);
require('./wordpress/wp-load.php');
query_posts('showposts=1');
but as both wordpress and opencart are on the same database they have DB_PASSWORD as a constant which it sees as pre-defined.
I tried creating a new wp-config.php and wp-load.php by duplicating them, renaming them and directing to them, but got in a whole mess of trouble.
anyone see a work around?
thanks.
Re: Combining OpenCart with Wordpress
Posted: Mon Jan 24, 2011 9:55 am
by kdmp
I ran into the same problem as Moyger...Using $this when not in object context in registry.php on line 10.
I am attempting the same thing as 3rdcorner. Any reason why this would happen?
Using 1.4.9 OpenCart and 3.0 Wordpress... Wordpress is in the root and Opencart in ./shop/
Code: Select all
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
require_once('./shop/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();
?><!DOCTYPE html>
Is this error due to the change over from self:: to $this->?
Re: Combining OpenCart with Wordpress
Posted: Tue Jan 25, 2011 12:29 am
by kdmp
An easier question is this....how can I check for a logged in session for opencart from Wordpress? I just want to show the correct the links.
I have opencart in the directory shop. Wordpress is in the root. After I logged in to opencart as a customer, I went back to the wordpress page that I have print_r($_SESSION). I would have half expected to see customer_id in there somewhere.
Re: Combining OpenCart with Wordpress
Posted: Thu Apr 28, 2011 12:10 am
by xds
3rdcorner wrote:So far I've gotten wordpress to pull in customer login information from OpenCart by including the bare minimum requirements for /system/library/customer.php
Here's what I include in my wordpress header.php:
Code: Select all
require_once('./shop/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();
For this to work on opencart 1.5 I have made the following changes:
Code: Select all
require_once('../development/oc/config.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');
// Registry
$registry = new Registry();
// 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($registry);
$logged = $customer->isLogged();
Re: Combining OpenCart with Wordpress
Posted: Thu May 26, 2011 4:01 am
by heizo
Ive gotten many of the features asked for working in pre 1.5 open cart installations. Here is the forum for example code (scroll to the last pages for complete code).
http://forum.opencart.com/viewtopic.php?f=128&t=26860
Re: Combining OpenCart with Wordpress
Posted: Thu Jun 02, 2011 8:37 am
by SupraTwinTurbo
Hmmm... I checked the link and the last pages have no complete code. Can you verify?
Re: Combining OpenCart with Wordpress
Posted: Sun Jun 05, 2011 10:34 pm
by joejac
Hello,
This is very nice topic.
My question is, If a web site has 3 years with WordPress (WP) and all the products, descriptions and prices, are already in WP,
1.- Could it be possible to add a buy button for each product in WP that takes to OpenCart (OC) so the visitor can browse WP for products and click in their respective buy button?.
2.- Can I pass to OC through the buy button the product information like name, brief description, price and quantity via get or post in the URL?
OpenCart should add that product to the shopping cart, OpenCart will also be displayed inside an iframe of a WP page, so the buyer can see how is going his shopping cart, and do the checkout when he is ready.
I do not need to show OC menu, just the registration and shopping cart, because products description and prices are already in WP, I do not want to eliminate the products from WP and to include them in OC, too much work I think.
How can I do all this integration?, are there tutorials, examples or related links or documentation?
Hope I was able to explan myself.
Thanks for your nice help in advance
Best regards
joejac
Wordpress in sub directory of Opencart - Error fix
Posted: Sat Jun 18, 2011 4:43 pm
by innuoluke
For the people who have installed Opencart, and then put wordpress in a sub directory (like me!), I have found the following solution to the "using $this in non-object context" error.
Replace the code from above with this, still in your wordpress header.php:
Code: Select all
//Pull in some stuff from opencart so that we can check if the user is logged in TO OPENCART (not necessarily wordpress!!)
require_once('../config.php'); //Changed to point at Opencart root (one level up)
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');
// THIS BIT IS NEW!
// Registry
$registry = new Registry();
// Session
$session = new Session();
$registry->set('session', $session); //Changed
// Request
$request = new Request();
$registry->set('request', $request); //Changed
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db); //Changed
$customer = new Customer($registry);
$logged = $customer->isLogged();
That should fix the error, and if you print_r() the $_SESSION you will see customer_id when the user is logged in to opencart
Hope this helps... I found this thread from a google search, so hopefully this can help a few more people than just me!
EDIT:
OK, so having re-read some of this thread this is the same as the Opencart 1.5 code, but nevertheless, its helpful!
I did come across a few more errors when wordpress was trying to access the database later in the page load (particularly around the comments area of the page). I solved this problem by moving all of the code above OUT of the header.php and putting it into the wordpress index.php (in my case "/news/index.php").
By doing this the page loads the relevant stuff from opencart into the session right at the start, and is then able to overwrite variables if they are needed within wordpress itself.
If it helps, I put the code above after "define('WP_USE_THEMES', true);" but before "require('./wp-blog-header.php');".
The only "problem" I can see with having this code in the index.php rather than header.php is that the resulting variables etc will be visible to all themes, but personally I think this is an advantage as it means we can create a new wordpress theme if required and not have to remember to add the code again!
Oh... and the fact that upgrading wordpress will nuke the code out

Bugger
