Jump to content


Photo

A shopping basket, not a shop


  • Please log in to reply
7 replies to this topic

#1 PaulD

PaulD

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 413 posts

Posted 30 July 2006 - 09:02 PM

I am sorry for the 'middleman' feel about this question but I would appreciate your opinion on this.

I asked a friend of mine to write a php shopping basket I could use with Etomite. He prefers asp but I thought I could probably use asp within etomite, at least a call to a seperate link that then fired up the asp.

Either way with all the PHP shopping carts around I knew it must be possible. (I only wanted a shopping basket and checkout, not a whole shop/stock system, the actual product pages I intended to lovingly create myself individually and categories would be a sinch with list docs etc.) OS Commerce et al are all easy to set up but a pain to use. As flexible as a brick.

Anyway, This is what he said. (The jaromatherapy site refferred to was supposed to be my wife's website but has instead turned into my etomite playground.)


I've had a play around with some PHP code snippets on the Jaromatherapy site, and there seems to be an issue with session state, which I think is going to make it very difficult (maybe impossible) to set up a shopping cart in this way.

A simple way to demonstrate the problem is to create a simple snippet based on this example: fluidthoughts.com/howto/php/session_counter
</quote>

Here is the code he refers to;
<code>
session_start();
session_register("count");

if (!isset($_SESSION))
{
$_SESSION["count"] = 0;
echo "<p>Counter initialized</p>\n";
}
else { $_SESSION["count"]++; }

echo "<p>The counter is now <b>$_SESSION[count]</b></p>".
"<p>please reload this page to increment</p>";



$Id: session_counter.php,v 1.3 2002/08/30 04:14:14 willn Exp $
</code>

He reads as a bit patronising here but he is talking to me - a php beginner.
<quote>
Which just counts how many times the page has been reloaded by the current browser session.

Opening a new browser window and pointing at the same URL resets the counter to 0 as we would expect.

Running the code as a snippet in Jaromatherapy though has erratic results which I think are caused by the way the CMS interprets the snippets, and worst of all, opening a new browser window and reloading the site doesn't reset the counter! In other words the Jaromatherapy site doesn't distinguish between the two sessions.
</quote>

And this is the really important bit;

<Quote>This makes a shopping cart system a non starter if we use code snippets, and I don't think there is another way to do it if you want to retain control over the look and feel of each product page with the Etomite CMS...
</Quote>

Sorry for the long post. Any opinions would be gratefully recieved.

Thanks

Paul

Edited by PaulD, 30 July 2006 - 09:05 PM.


#2 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 31 July 2006 - 03:37 AM

I'm not totally sure I grasp what you intended with your previous post but maybe I can help clear the waters... Shopping carts, or shopping baskets as you choose to call them, generally work with sessions and/or cookies... Due to the fact that Etomite uses sessions for all visitors, whether logged in or not, it is very easy to implement a shopping cart... Using a snippet, or a group of snippets, for a shopping cart is actually quite simple... Making it work for each individual need is the hard part... The other hard part is the secure payment management... Actually tracking a cart is so simple that I slapped together a proof of concept cart about a week ago in a matter of minutes just to prove to myself how easy it could be done, but more as a refresher in using objects in sessions... All I did was to write some code that maintained a cart object as a session variable and split that object into customer and item sub-objects, with a few other pieces thrown in for good measure... But don't ask me to write a shopping cart module as I have bigger fish to fry right now...

#3 breezer

breezer

    Likes Etomite Forums!

  • Member
  • PipPip
  • 308 posts

Posted 31 July 2006 - 06:07 AM

PaulD,
here is the code you supplied above in the snippetized form. I tested it and it works perfectly, the counter is incremented as needed.

/*
  session refresh example snippet
  
  [[sessionrefresh]]
  [!sessionrefresh!]
  
*/

// start the output
$output ="";


session_start();
session_register("count");

if (!isset($_SESSION["count"]))
{
$_SESSION["count"] = 0;

$output .="<p>Counter initialized</p>";
}
else { $_SESSION["count"]++; }

$output .="<p>The counter is now <b>$_SESSION[count]</b></p>".
"<p>please reload this page to increment</p>";

return $output;

a few key notes to keep in mind with snippets:
1. starting and closing php tags are not required
2. always "return" the output, a snippet is basically a php function
3. never use echo or print
4. for dynamic snippets, such as this simple counter, always make sure you set the document which contains the snippet to "uncached". You can call the snippet uncached, but sometimes the results are not the same.

your idea is very feasible, it's just a matter of grasping the way snippets are coded and utilized.

Edited by breezer, 31 July 2006 - 06:38 AM.


#4 PaulD

PaulD

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 413 posts

Posted 31 July 2006 - 09:29 PM

Thank you.

I appreciate the feedback. Perhaps I just gave in too early.

#5 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 29 January 2008 - 12:00 PM

How did you go with this Paul? I've been delving into shopping carts more deeply and am interested with any code that works with etomite that I could learn from or adapt to suit my needs for a simple and secure etomite based cart.

#6 PaulD

PaulD

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 413 posts

Posted 06 February 2008 - 02:55 PM

How did you go with this Paul? I've been delving into shopping carts more deeply and am interested with any code that works with etomite that I could learn from or adapt to suit my needs for a simple and secure etomite based cart.


Sorry, Just noticed this post.

I didn't get on at all but only due to time constraints. I simply used cubecart. However I have grown out of cubecart to a certain extent and now want the power of etomite again. I was about to start playing with the eto-cart but there is SOOO much coding to be done.

Instead I am having a great time with user APIs. The permissions stuff of etomite is so cool. Once I have my first real community site working (a learning vehicle really) I will return to the shopping cart issue. From my experiences with cube cart the complicated bits are the integration with payment provider (protx or similar) and dealing with https. Not done either with etomite yet.

So busy paying the mortgage (am self employed) that I dont get enough time for eto. If I could I would do this all day every day.....

I have just got the controller snippet working to authenticate and present data if allowed etc. Am about to try your fantastic snippet too! (Membership validator). I love reading your posts with Ralph and Dean, it is just amazing how much there is yet to learn for me. Every time I think I am getting on top of it I find another WORLD of stuff to learn.

Speak soon,

Paul.

#7 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 06 February 2008 - 05:06 PM

Paul,
I like cubecart as well...
If you're going to be hand coding each item on the page and if Paypal is a gateway option there is a simple DW plugin from webassist that is basically a form that passes variables to paypal in a new window. Paypal then handles sessions and ssl. you don't really need the plugin - if you're able to hand code the form.

the downside is users temporarily leave your site (new window)and you have very little control over how the paypal window displays. i think all you get is an image/logo option. it is, however, the simplest cart i have found and works fine for some of my non-profits who are very budget conscious.

#8 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 06 February 2008 - 09:10 PM

Well since posting this question about 2 weeks ago, I have adapted plaincart for use with etomite. The front-end is complete, Unfortunately the table-based layout is embedded quite often in the code so it is hard to modify drastically, but the upside is that is can take on your existing etomite templates. That could change. The shopping basket and checkout and mini-cart are all separated, all being called from separate snippets using a display controller. I am working on the back-end admin at the moment. @ PaulD you were right about there being Soooo much coding!. Anyway, when I have finished the back-end and have an installation wrapper, I'll post it for alpha testing. You can view the shop on my testing site: http://www.artimental.com/plainCart.html.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users