Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

temporary shopping cart for guests


me23

Recommended Posts

Hello,

I would like to extend the life of the temporary shopping cart for guests. It looks like it is currently set to about 1/2 hour by a cookie named __utmb. I have looked for the setcookie() function throughout the code, but only found one instance of it in application_top.php and it looks like that only sets the cookie_test cookie. How is this __utmb cookie being set so that I can modify it, or more importantly - is there a better way I can extend the life of a guest's cart?

Thanks for the help!

Anne

Link to comment
Share on other sites

Hello,

I would like to extend the life of the temporary shopping cart for guests. It looks like it is currently set to about 1/2 hour by a cookie named __utmb. I have looked for the setcookie() function throughout the code, but only found one instance of it in application_top.php and it looks like that only sets the cookie_test cookie. How is this __utmb cookie being set so that I can modify it, or more importantly - is there a better way I can extend the life of a guest's cart?

Thanks for the help!

Anne

The cart isn't using a cookie to track the user through the store, it uses a session, and sessions expire in something like 24 minutes by default on most webservers... I've tried changing it on my own store to extend it to 1 hour, to no avail, so I'm afraid I don't have an answer for you there, but maybe someone else can shed some light on this :)

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Hi Richard,

Thanks for the explanation. If that's the case, it seems like guests are being tracked in the wrong way - most large online retailers will not dispose of the items you've placed in your cart after such a short amount of time, but rather keep them there for at least two weeks. I think this is a much more customer-friendly solution because many people shop during the day at work and then wait to make their purchase until the evening or later in the week. The way that oscommerce is currently set up does not allow for this type of purchasing behavior unless someone has signed-in, which the majority of site visitors do not do. I think all oscommerce shop owners would benefit from a fix that would allow items to stay in a guest's cart for a longer period of time.

 

Does anyone else know if there is a way to accomplish this?

 

The reason I thought that changing the cookie expiration would solve this is because when I add a product to my cart, I noticed that a cookie was created with the name __utmb, and this cookie has an expiration date of about 1/2 hour. If I could figure out how to modify the expiration on this cookie, I could at least test it to see if it would work. I just can't find where in the code this cookie is set.

 

Any additional help and/or insight is greatly appreciated!

Anne

Link to comment
Share on other sites

Hi Richard,

Thanks for the explanation. If that's the case, it seems like guests are being tracked in the wrong way - most large online retailers will not dispose of the items you've placed in your cart after such a short amount of time, but rather keep them there for at least two weeks. I think this is a much more customer-friendly solution because many people shop during the day at work and then wait to make their purchase until the evening or later in the week. The way that oscommerce is currently set up does not allow for this type of purchasing behavior unless someone has signed-in, which the majority of site visitors do not do. I think all oscommerce shop owners would benefit from a fix that would allow items to stay in a guest's cart for a longer period of time.

 

Does anyone else know if there is a way to accomplish this?

 

The reason I thought that changing the cookie expiration would solve this is because when I add a product to my cart, I noticed that a cookie was created with the name __utmb, and this cookie has an expiration date of about 1/2 hour. If I could figure out how to modify the expiration on this cookie, I could at least test it to see if it would work. I just can't find where in the code this cookie is set.

 

Any additional help and/or insight is greatly appreciated!

Anne

Actually, oscommerce does provide for this, cookie cart tracking would accomplish what you were talking about up above, where they shop at work and then don't have anything in their cart when they get home, because the cookie with all of their cart info would be stored on their work computer... The session data works in conjunction with the mysql database on the backend, which is where all of the cart items are actually stored, it just kills the session after 24 minutes of inactivity, and the user has to login again... But once they do login again, their cart is just how they left it, with whatever products they had in it the last time they were shopping around... The session just maps that particular browsing instance to a user account, and from there everything is logged on the backend in the database...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

ahh, yes, you're right about the benefit that the database storing the cart information provides - that is very nice to be able to go from one computer to another and still have your cart. I guess what I'm looking for is the best of both worlds - how do retailers that will retain a guest's cart for two weeks do it and is there anyway that would be possible with osc?

Link to comment
Share on other sites

ahh, yes, you're right about the benefit that the database storing the cart information provides - that is very nice to be able to go from one computer to another and still have your cart. I guess what I'm looking for is the best of both worlds - how do retailers that will retain a guest's cart for two weeks do it and is there anyway that would be possible with osc?

Osc will retain a customer's cart indefinitely, until they clear it out themselves, because it's stored in the database indefinitely until they perform that action... I think the question you're asking here is how a store allows the customer to return to the site for up to 2 weeks without having to log back in to see their cart information, in which case, that does indeed deal with cookies, and there are a couple of existing contributions to allow for a cookie login, right here and here...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Well, not exactly - I don't want guests to have to create an account and login at all. I'd just like to make it so that when a guest comes to my store, they can browse it and build their shopping cart without their items disappearing from the cart after 24 minutes of inactivity. This is how the majority of ecommerce sites function, so it is what a customer expects nowadays - try going to any of your favorite large ecommerce sites, adding products, then check it several hours or days later on the same computer and you'll still have those products in your cart. Browsing, searching, and deciding on the products you might want to buy at a later time is a time-consuming process, so if you spend all your time doing this and then you go to lunch and come back to find that all your work was thrown out, you probably wouldn't be happy with the store and not spend the time to rebuild your cart. And many people don't want to create accounts just to have their cart saved for more than 24 minutes - they expect it to be there when they check it again several days later.

 

It sounds like osc is not currently set up to be able to provide this type of experience for the customer, so I need to find a way to do this.

Link to comment
Share on other sites

Well, not exactly - I don't want guests to have to create an account and login at all. I'd just like to make it so that when a guest comes to my store, they can browse it and build their shopping cart without their items disappearing from the cart after 24 minutes of inactivity. This is how the majority of ecommerce sites function, so it is what a customer expects nowadays - try going to any of your favorite large ecommerce sites, adding products, then check it several hours or days later on the same computer and you'll still have those products in your cart. Browsing, searching, and deciding on the products you might want to buy at a later time is a time-consuming process, so if you spend all your time doing this and then you go to lunch and come back to find that all your work was thrown out, you probably wouldn't be happy with the store and not spend the time to rebuild your cart. And many people don't want to create accounts just to have their cart saved for more than 24 minutes - they expect it to be there when they check it again several days later.

 

It sounds like osc is not currently set up to be able to provide this type of experience for the customer, so I need to find a way to do this.

No, osc isn't currently set up to do something like that, although the majority of sites that I've personally seen do behave the same way... The reason for this is that a lot of people also surf websites in public places like libraries, college computer labs, network centers, and any office that has 24 hour operations, so employees share terminals on separate shifts... So if a person went surfing say, Best Buy, and added some stuff to their cart, and then went out for lunch, and someone else took their seat at the computer, and went to Best Buy, they'd have all of this other person's crap in their cart to begin with, which is why most places won't save your cart unless you're registered with their site... I suppose if you wanted to do what you're describing, you could write up some code that would store their items in a cookie, and then check for the existence of that cookie if there were no session currently active, and read that info into the session data, and update the cookie each time another product is added to the cart... But you'd have the same problems in shared computer locations as what I described above...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

  • 2 years later...

I have installes Cookie Cart contribution.

http://addons.oscommerce.com/info/5390

 

All go fine except when i click "Buy Button" , it gets a blank page with the mesage:

Fatal error: Call to undefined method shoppingCart::get_contents() in /xxxxxxxxxxxxxx/includes/write_cart_to_cookie.php on line 27

 

If i go back on explorer the item is in the cart.

 

P.D: what the difference with sessions>Force Cookie Use

Link to comment
Share on other sites

OK, so you still want the cart's session to expire when the customer leaves the store, but while they're still in your store, you want the session to last the full length of time? I haven't looked, but there ought to be some setting when writing out the cookie to not have it expire so quickly. You could, in theory, have a checkbox on the page to make it a permanent cookie (until erased at checkout?), which could be useful for "non-public" computers. Otherwise, someone else on your shared computer will see the juicy items you put in your cart -- you know, the "Bad School Girls" video and "Spanking Illustrated" book.... ;)

Link to comment
Share on other sites

  • 3 months later...

I have installes Cookie Cart contribution.

http://addons.oscommerce.com/info/5390

 

All go fine except when i click "Buy Button" , it gets a blank page with the mesage:

Fatal error: Call to undefined method shoppingCart::get_contents() in /xxxxxxxxxxxxxx/includes/write_cart_to_cookie.php on line 27

 

If i go back on explorer the item is in the cart.

 

P.D: what the difference with sessions>Force Cookie Use

 

Hi,

 

Did you ever figure out how to fix this problem? I am getting the same error.

Rob

----------

working on a way to make Price Groups, any ideas?

Link to comment
Share on other sites

  • 4 weeks later...

I had the same problem, in includes/classes/shopping_cart.php

make sure the code

// Begin Change: Cart Cookie
   function get_contents() {
       return serialize($this->contents);
       }

   function set_contents($contents_string) {
      $arrData = unserialize(stripslashes($contents_string));
      $this->contents = $arrData;
      }
// End Change: Cart Cookie

 

Is not the last thing in the file before the ?>

 

Move it to just above the very last }

Link to comment
Share on other sites

  • 2 weeks later...

I had the same problem, in includes/classes/shopping_cart.php

make sure the code

// Begin Change: Cart Cookie
   function get_contents() {
       return serialize($this->contents);
       }

   function set_contents($contents_string) {
      $arrData = unserialize(stripslashes($contents_string));
      $this->contents = $arrData;
      }
// End Change: Cart Cookie

 

Is not the last thing in the file before the ?>

 

Move it to just above the very last }

 

Thanks Sascha. After checking includes/classes/shopping_cart.php, I realized that I had failed to upload the revised file to the server.

 

Everything seems to be working fine, now. Deleted my old 'cart' cookie and the new expiry is for 2011.

Rob

----------

working on a way to make Price Groups, any ideas?

Link to comment
Share on other sites

  • 3 months later...

Thanks Sascha. After checking includes/classes/shopping_cart.php, I realized that I had failed to upload the revised file to the server.

 

Everything seems to be working fine, now. Deleted my old 'cart' cookie and the new expiry is for 2011.

 

Hi,

 

Hi just installed this contribution, Cart Cookie http://addons.oscommerce.com/info/5390, and I have done everything correct, I triple checked and I tested in 3 computers and on IE, Firefox and Chrome, but it shows the same error in all browsers "Fatal error: Call to undefined method shoppingCart::get_contents() in /home/abcde/public_html/includes/write_cart_to_cookie.php on line 8"

 

Someone could help me please, I really need this working ASAP !!! :'(

 

Thanks

Link to comment
Share on other sites

It also show another error message "Fatal error: Call to undefined method shoppingCart::set_contents() in /home/artpaint/public_html/includes/cart_cookie.php on line 22"

 

Umm, it seems that this contribution is complete garbage. It simple doesn't work....

 

This is the final code in /includes/classes/shopping_cart.php

It is exactly as indicated in the instructions.

 

         } else {
           switch ($this->content_type) {
             case 'virtual':
               $this->content_type = 'mixed';

               return $this->content_type;
               break;
             default:
               $this->content_type = 'physical';
               break;
           }
         }
       }
     } else {
       $this->content_type = 'physical';
     }

     return $this->content_type;
   }

   function unserialize($broken) {
     for(reset($broken);$kv=each($broken);) {
       $key=$kv['key'];
       if (gettype($this->$key)!="user function")
       $this->$key=$kv['value'];
     }
   }
// Begin Change: Cart Cookie V1.3  
   function get_contents() {
       return serialize($this->contents);
       }

   function set_contents($contents_string) {
      $arrData = unserialize(stripslashes($contents_string));
      $this->contents = $arrData;
      }
// End Change: Cart Cookie V1.3 
}
?>

Link to comment
Share on other sites

  • 10 months later...

Hi,

 

It has passed some time, but I would like to correct my former claims about this addon.

 

Now it is working very fine and the reason that it haven't worked before was due that I had installed another contribution to enable a wishlist in the store. Now the compatibility issue was resolved by a coder and it is indeed a very well done contribution.

 

To the authors I would like to thank you very much for this excellent contribution :)

 

Best regards,

João

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...