[SOLVED] use osCommerce variables across CMSMS

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

[SOLVED] use osCommerce variables across CMSMS

Post by rotezecke »

Hi
has anyone found a way to synchronise sessions so i can use $_SESSION variables across osCommerce and CMSms?

this is probably more of an osCommerce question as I want to force osCommerce to use the CMSms naming convention but I am open to any suggestion.

cheers, mario
Last edited by rotezecke on Tue Dec 18, 2012 9:04 am, edited 3 times in total.
User avatar
Owens
Forum Members
Forum Members
Posts: 97
Joined: Thu Dec 27, 2007 11:29 pm

Re: use osCommerce variables across CMSMS

Post by Owens »

rotezecke wrote:has anyone found a way to synchronise sessions so i can use $_SESSION variables accross osCommerce and CMSms?
This is a separate topic from my CMSMS Shop Skin Helper, and should probably have it's own thread. However, since you have asked, I did write a plugin (circa 2009) for CMSMS that reads the cookie set by osCommerce v2.2. It isn't perfect and that's why I've never released it.

osc_cookie plugin file attached.

How to use it:

You will need to open the plugin in your php editor of choice, and change lines 28 to 34 under the comment:
/* setup the links */

Then upload it to your CMSMS /plugins/ directory.

To find more instructions on how to use it; In the CMSMS Admin section click on Extenstions -> Tags -> osc_cookie

What it does:

It reads the osC v2.2 cookie and looks up the session information stored in the osCommerce database. You can get:
  • get='customer_id'
    will return the customer id if the customer is logged in. Othewise it will return 0 (zero).
  • get='cart'
    returns the number of items in the cart and the cost of those items as a string e.g. "4 Items ($49.95)"
  • get='cart_qty'
    returns the number of items in the cart e.g. "4"
    this is one of the issues I was talking about above: sometimes the number of items in the cart returned isn't accurate. Didn't really care enough to track down the bug.
  • get='cart_cost'
    returns the cost of the items in the cart e.g. "49.95"
  • get='login_link' will display a login or logout link based upon the users login state.
The license:

Might not be what you are looking for, but it's what I have. Also it's released under the GNU GPL v3 so do what you want with it. Add your own copyright above mine if you re-release it with your own changes.

This also means you could use it as a base to write a plugin that would read osC v3 cookies.

No support provided for this plugin:

Also I'm not going to provide support this plugin, unless someone want's to pay some cash money to have me do it.

I no longer install osCommerce for clients, but I do still support my clients that I haven't convinced to move on yet. It took the osC team 10+ years to release v3 after they announced it as "soon to be released". Guess I got tired of waiting ;) In their latest email the osC team said v3 is going to be a framework and not just an eCommerce platform, so watch for a complete CMS to be developed around it.
Attachments
function.osc_cookie.zip
* I will not be providing support this plugin. Released under the GNU GPL v3.
* Reads the osCommerce v2.2 cookie and looks up the session information stored in the osCommerce database.
* Not for v3 of osCommerce.
(2.84 KiB) Downloaded 149 times
Last edited by Owens on Sat Apr 23, 2011 1:22 pm, edited 1 time in total.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: use osCommerce variables across CMSMS

Post by rotezecke »

doesnt work since 1.11.4.
unable to edit pages that include this plugin.
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: use osCommerce variables across CMSMS

Post by Jos »

Just replace

Code: Select all

  global $gCms;
  $db =& $gCms->GetDb();
With

Code: Select all

$db = cmsms()->GetDB();
And I think it will work again
User avatar
Owens
Forum Members
Forum Members
Posts: 97
Joined: Thu Dec 27, 2007 11:29 pm

Re: use osCommerce variables across CMSMS

Post by Owens »

Yep. This plugin is 4 months away from being 2 years old. It's released under the GPL 3 so someone that's using osCommerce and CMSMS could update it.

Thanks Jos.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: use osCommerce variables across CMSMS

Post by rotezecke »

The plugin actually still works as expected on the front end (@Jos: i had made those changes a while back).

but i cannot edit pages in backend that include the plugin.

when i comment out the plugin (i use it in a global content block which i can still edit) i can then edit the page.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: use osCommerce variables across CMSMS

Post by rotezecke »

Found the problem, not related to this plugin.

I had an include line with a relative path:

Code: Select all

  require('config/db.php');
which since 1.11.4 breaks backend. (but still works in front end). when changing the above to

Code: Select all

  require('../config/db.php');
backend works, frontend breaks.

hence i now grab the path from config file:

Code: Select all

  $config = cmsms()->GetConfig();
  require($config['root_path'].'/config/db.php');
now it works again.
kissack
Forum Members
Forum Members
Posts: 18
Joined: Mon Oct 22, 2007 6:10 pm

Re: use osCommerce variables across CMSMS

Post by kissack »

Jos wrote:Just replace

Code: Select all

  global $gCms;
  $db =& $gCms->GetDb();
With

Code: Select all

$db = cmsms()->GetDB();
And I think it will work again
Thanks. worked a treat for my (UDT) problem :-)
Allan
Post Reply

Return to “Modules/Add-Ons”