Jump to:

2088 Posts in 1007 Topics by 455 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » thousands of empty orders

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 747 Views
  • janulka
    Avatar
    Community Member
    80 Posts

    thousands of empty orders Link to this post

    Hello,

    The client has small ecommerce site (SS 2.4.? (5-6-7..? I think) and ecommerce 0.8.1), and is recieving around 30 orders per month. But in database, hundreds of empty orders are being created every day, and since last time I tested one month ago, it has been created more than ten thousand of these. They are completely empty, and all have status "Cart"

    What is happening? Is there a way to block this?

    Thanks in advance

  • HansR
    Avatar
    Community Member
    140 Posts

    Re: thousands of empty orders Link to this post

    @janulka

    A new cart (i.e., Order object) is created for every new visitor, and that includes any bots that visit. Yes, those empty entries are annoying.

    I happen to have solved this problem for one of my sites recently (link). Basically, order creation is delayed until a visitor actually adds an item to a cart (or visits the cart or checkout pages).

    If you want more details on the fix, let me know.

    Hans

  • janulka
    Avatar
    Community Member
    80 Posts

    Re: thousands of empty orders Link to this post

    Yes please!

    It would be great if order creation was delayed until visitor adds an item to a cart

    Thanks in advance!

  • HansR
    Avatar
    Community Member
    140 Posts

    Re: thousands of empty orders Link to this post

    @janulka

    Attached are the changes to the PHP files (relative to version 0.9). This patch doesn't solve the problem by itself, but it does provide the needed functionality. Basically, it adds $allowCreate as a parameter to methods such as ShoppingCart::current_order() and EcommerceSiteTreeExtension::Cart()), but the default behaviour is still to create the cart.

    You will still have to manually update all of your ecommerce templates. For example, my dropdown cart looks like this:
    <% if Cart(0) %>
       <% control Cart %>
          <span id="$SideBarCartID">
             <% include CartDropDownInner %>
          </span>
       <% end_control %>
    <% else %>

    Note the "Cart(0)" at the top. Passing 0 ensures that the cart won't be created if it doesn't exist.

    I recommend temporarily inserting a user_error() call in ShoppingCart::current_order() just before the code that creates a cart. That way you can visit various pages on your website, and it will spit out an error if it tries to create a cart. Even better, the stack trace will tell you what you need to change. **

    I hope that this helps.

    Hans

    ** IMPORTANT: Clear the cache first, or open an incognito window before trying this. You won't get an error if a cart already exists for the current session.

  • janulka
    Avatar
    Community Member
    80 Posts

    Re: thousands of empty orders Link to this post

    Thanks a lot for the code.

    Oh, it's a shame I do not know how to use this fix for earlier version, ecommerce version on that site is 0.8.1

    747 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.