Embedding WordPress into OS Commerce Part II

It has been almost twelve months since I published my first tutorial on embedding WordPress into OS Commerce. At the time, I was relatively new to working with OSC, so I was unaware of the many different template modules available for the software. Through the comments on my post, I learned that the OSC install that I was working with used the Basic Template Structure (BTS). However, people inquired about adjusting my tutorial for use with the Simple Template System (STS). Still more persons asked questions pertaining to default installs of OSC MS2.2.

osc_wordpress.jpgKeeping all of these comments in mind, this month I put together a default install of OSC MS2.2 with an integrated WordPress blog (demo no longer available, sorry). What follows is a step-by-step tutorial (with the novice in mind) showing you how to do this. For the many people who are looking for an effective way to integrate OS Commerce and WordPress, I hope this tutorial proves to be a valuable and effective contribution to the OSC Community.

  1. First, you will need to install OSC MS2.2 on your web server. This tutorial will assume that your OSC install is located in the default location for a typical OSC install: http://yourdomain.com/catalog/.
  2. Next, install WordPress in the /catalog/ directory (i.e. http://yourdomain.com/catalog/wordpress/). Once you’ve installed WordPress, login to your WordPress admin and set Options > General > Blog address (URI) to “http://yourdomain.com/catalog/blog.php” (Note: If you would prefer to have your blog file named something other than blog.php, be sure to set this value accordingly and rename the file that you upload in step 4).
  3. Now, just after the opening comments of the /catalog/includes/application_top.php file, add the following PHP code:
    // turn off WordPress themes and include the WordPress core:
    define('WP_USE_THEMES', false);
    require('./wordpress/wp-blog-header.php');
  4. Next, download these two files (blog.php and stylesheet.blog.css) and place them in the root of your OSC install.

Additional Refinement: Displaying Blog Headlines on your Catalog Homepage
For added functionality, here are instructions for including a WordPress static page and blog headlines on the homepage of your OSC store:

  1. Before making this edit, you’ll want to make a backup of your default OSC homepage by renaming the file /catalog/index.php to index.ORIGINAL.php
  2. Now, download this new index.php file and upload it to your /catalog/ directory. This new index file will display your last 4 blog headlines in a column on the right of the page body. Plus, the value for TEXT_MAIN found in /catalog/includes/languages/english/index.php will display in the left column of the page body.
  3. In addition, starting on line 292 of this new index file, I have a switch inserted that will check for the presence of Vito Tardia’s Improved Include Page WordPress Plugin. If you install Vito’s plugin in WordPress, you can edit the iinclude_page() function call on line 294 to include the contents of any WordPress static page by simply editing the page ID in the function’s arguments.

Needing Additional Help?
If you’re a total novice when it comes to the web, you can hire me to perform the aforementioned services for you. At the demonstration website mentioned in this post, you can purchase one of these options:

Comments

  1. hi micheal, ur contribution is clear way to get the blog in oscommerce page , and my problem is when i signin to oscommerce and click on wordpress comments link or i post a comment in wordpress my oscommerce login session expires and i again want to signup in oscommerce , so any one there to help me to overcome this Problem ? if somebody can help me friends

  2. Hello,

    I read before that someone had a problem with Danish characters. I have the same issue.

    For some reason it messes with the Swedish charachters äåö and also with the € and £ symbols in OSC itself. They don’t show as themselves.
    http://www.ulvdesign.com/armbanden-c-23.html?language=se

    So they show correctly in the blog itself, but not in OSC. I found that if I changed the code for euro in the admin to € it seems to work. I used these tags:
    http://www.chami.com/tips/internet/050798I.html

    But to go and do all this for all the characters on the swedish part of the site is going to be a a lot of work.

    This problem didn’t occur until I put the code into my Application_top.php.

    Thanks in advance

  3. Do you know any fully functioning sites using WP and OSC?

  4. I got my site functioning now.

    I solved the problem with the characters so my question above has solved itself.

    Thanks for this contribution!

  5. @Jon Z:

    Hi Jon.

    I would also be keen to know the answer to that question. You are probably well aware of http://wordpress.org/extend/plugins/wp-oscommerce/ ? However, while it looks great, it functions terribly and there are heaps of bugs. The support is typical of a freebie – none or very little anyway!

    Please post anything else you find here.
    Cheers

  6. @Jon Z and @Sol – I need to write a new tutorial as I am currently using a new technique for client sites that use WP and OSC. Here’s an example: http://www.logoandstitch.com/products/.

    Instead of embedding WordPress, now I’m creating an OSC theme that loads the WP core via a require() statement. Then the OSC theme produces the WP theme around the OSC pages via WP functions like get_header() and get_footer(). This method works much better as changes to the WP theme automatically get reflected on the OSC pages.

  7. Michael, that’s genius!

    I sent you an email – pls check it.
    Cheers
    Sol

  8. @Jon Z and @Sol – One other thing: I forgot to mention that the example I link to regarding my new technique is an integration of WordPress and ZenCart. I’ve been using it lately as its template system was easier to work with and my impression of that project is that it is better maintained than OSC.

  9. @Rodo:

    Hi!

    I am tearing my hair of, getting those characters to work. How did you figure it out to work?

    Extremly thankful for any respons you can give me.

    Best Regards

    David phillips

  10. @David,

    Save your hair, the solution is dead simple.

    Go to your wordpress admin -> Settings -> Reading

    In there change the encoding from UTF-8 to latin1_swedish_ci. It might be wise to check the encoding of OSC in your database and match it to this one, but since you’re website is in swedish, it’s likely this one.

  11. Wow, brilliant. Thanks Rodo!

  12. Mike Raccine says:

    Is there a way to use the built in WordPress RSS links with the OSC setup?
    When I try to add the feature, the URL becomes mydomain.com/blog.php/feed/ which is obvious incorrect.

  13. @Jon Z:

    This is an example of webSite working with WordPress and OSCommerce
    http://www.greensupplyenergy.com

    but i also have the same issue that “dinesh” had.

  14. Hi Michael, I want to get WP for my site as well. I have loaded ultimate SEO urls for my site, do I need to do anything after install your contribution?
    many thanks

  15. I have just got my site successfully integrated with WP.
    http://www.cu2nite.com.au
    I love it very much. Thanks again to Michael. What a great work!

  16. nice article, after install how do i integrate both oscommerce & wordpress , having a common admin authentication ?

  17. @david: That’s a great question. Unfortunately, I haven’t tackled that problem yet.

  18. Obviously the site is under development.

    The sites main language is Swedish so the characters got all weird. The solution you posted earlier worked great to get the osc characters to work correctly.

    The problem now is that in WP I can’t post with å ä ö.
    Posts that have been made earlier are displayed with the weird characters. The data in the database is not beeing changed, it’s just how the characters are displayed.

    Anyone got a solution to this?
    Thank you in advance

  19. Everyone, the PixoPoint Theme Integrator looks like it might be a new alternative for integrating WP and OSC, or WP and ZenCart. Check it out here: http://pixopoint.com/products/pixopoint-theme-integrator/

    My guess is that it is similar to my new technique for integrating WP and ZenCart as seen here: http://www.youtube.com/watch?v=yWC-m-d-N5E

    • Hi,
      I have intrgrated the wordpress blog into my oscommerce website but I need to integrate buddypress into my oscommerce website aswell. Please can you explain a way of doing this please.
      Many Thanks.

  20. Hi all,

    I’ve been integrating WordPress into 4 websites I maintain. On one of the osCommerce websites I can’t get it working properly.

    The domain: http://www.goldbull.co.za

    Blog URL: http://www.goldbull.co.za/catalog/blog.php

    If you go to the first URL you can browse the site with any problems but as soon as you go to the Blog URL some weird DB error starts manifesting, then any other page you try go to will not work until you restart the browser.

    To remedy the problem I have tried installing wordpress in the root and as a sub dir in the catalog dir. I’ve tried installing wordpress in the same db as the store (MySQL 4) and also in a separate db. I’ve tried upgrading both DBs to MySQL 5 but still the problem persists.

    I actually have no clue as to what the problem is.

    Currently my install is as such:

    1. WordPress installed in wordpress dir in webroot (httpdocs) in its own db on a MySQL 5 DB server
    2. osCommerce installed in catalog dir in webroot in its own db on same MySQL 5 DB server
    3. Created blog.php to access wordpress content.

    /catalog/blog.php contents:


    add(NAVBAR_TITLE, tep_href_link(FILENAME_BLOG));
    ?>
    ?>

    <html >

    <meta http-equiv="Content-Type" content="text/html; charset=">
    <base href="">

    <!-- header //-->

    <!-- header_eof //-->

    <!-- body //-->

    &lt;td width=&quot;" valign="top"&gt;&lt;table border=&quot;0&quot; width=&quot;" cellspacing="0" cellpadding="2"&gt;
    <!-- left_navigation //-->

    <!-- left_navigation_eof //-->

    <!-- body_text //-->

    &lt;?php echo &#039;<a href="' . tep_href_link(FILENAME_DEFAULT) . '" rel="nofollow">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?&gt;

    <!-- body_text_eof //-->
    &lt;td width=&quot;" valign="top"&gt;&lt;table border=&quot;0&quot; width=&quot;" cellspacing="0" cellpadding="2"&gt;
    <!-- right_navigation //-->

    <!-- right_navigation_eof //-->

    <!-- body_eof //-->

    <!-- footer //-->

    <!-- footer_eof //-->

    I have it working on the other sites without any problems, not sure what could be causing this.

    osCommerce Project Version: osCommerce 2.2-MS2

    On the other sites: osCommerce Online Merchant v2.2 RC2a

    Not sure if the project version difference could cause the problem.

    If anyone has any ideas please let me know.

  21. Is there a way to not have the .php part in the url? So catalog/blog/ instead of catalog/blog.php ?

Trackbacks

  1. [...] A few months ago I started my first ecommerce site at TikiTemplates.com where I have several Photoshop templates aimed at photographers available – some free, some for sale. And to try and draw a few visitors over there I&#8217;ve posted a couple times here with new templates. Fortunately I found a post on embedding WordPress in osCommerce and set up a new blog on my TikiTemplates.com site and this blog will get to go back to the random photography and PHP postings that fill up the most space. [...]

  2. [...] you just want to embed an OS Commerce Store in your blog you can find some useful information at the OS Commerce Forum [...]

Leave a Reply