Page 1 of 1

[SOLVED] use osCommerce variables across CMSMS

Posted: Mon Apr 18, 2011 11:47 pm
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

Re: use osCommerce variables across CMSMS

Posted: Tue Apr 19, 2011 1:48 pm
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.

Re: use osCommerce variables across CMSMS

Posted: Mon Dec 17, 2012 3:12 pm
by rotezecke
doesnt work since 1.11.4.
unable to edit pages that include this plugin.

Re: use osCommerce variables across CMSMS

Posted: Mon Dec 17, 2012 3:19 pm
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

Re: use osCommerce variables across CMSMS

Posted: Mon Dec 17, 2012 3:20 pm
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.

Re: use osCommerce variables across CMSMS

Posted: Mon Dec 17, 2012 4:02 pm
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.

Re: use osCommerce variables across CMSMS

Posted: Tue Dec 18, 2012 9:03 am
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.

Re: use osCommerce variables across CMSMS

Posted: Sat Jan 05, 2013 10:41 pm
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