Six Steps to EPiStore Success
Christmas seems to have come early! EPiServer is releasing a number of great products including Relate+, but as Santa does his rounds there is one nice little module that seems to have been overlooked when the presents were given out.
EPiStore is a small, compact eCommerce module that has been around for quite some time and is used by EPiServer customers who need something affordable and well integrated with EPiServer CMS. It isn’t what I would describe as a fully-featured eCommerce site but it does a good job of simple things.
The current release, 2.5, works with EPiServer CMS 5 R2 SP1, but probably because of the focus on the big releases recently, there are just a few little things to be aware of when installing it for the first time. To make things easy for you, here is a little guide with six steps to getting it right. Note that these instructions are only based on EPiStore 2.5 and EPiServer CMS 5 R2 SP1 with the Public Templates installed. They may work for other versions and packages but I haven’t tested them.
1. Install in the right order
EPiStore 2.5 is installed from the EPiServer Deployment Centre, which is a nice touch. When you set up a new EPiServer 5 site you get the option to install it along with the Public templates (and Demo templates too, if you have those installed). However, don’t choose to install EPiStore yet! When you try and run the install it will tell you that it cannot be installed at the same time as a site, and you’ll have to go back and do all your settings again.
So set up your shiny new EPiServer 5 site and then go back into the EPiServer Deployment Centre and choose to deploy EPiStore. It will prompt you for the website to deploy too. Choose your new site and all should then work fine.
2. Prepare the EPiStoreSample project for changes
For our next tweaks, we need to change the EPiStoreSample project. Load it into Visual Studio 2008 and try to compile. You might get some errors about assembly versions. This is because the assembly references are outdated. Replace the following assembly references with new references to the latest SP1 versions:
EPiServer
EPiServer.BaseLibrary
EPiServer.Configuration
EPiServer.Enterprise
EPiServer.UI
EPiServer.Web.WebControls
You should now be able to compile the project and we are ready for the next step
3. Fix: Translation bug
If you log into the Edit area and go to the Action Window you will see a new link to search EPiStore orders. If you go into that you may see that all the labels for the textboxes and buttons are messed up (e.g. [Missing text /shopping/admin/searchorder/listfrom for ]). This is because there is some legacy translation code in EPiStore that we need to comment out.
In your EPiStoreSample project, open the SearchOrder.aspx.cs file in /Shopping/Admin. You will find two lines in there as follows, firstly in OnLoad:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(EPiServerProfile.Current.Language);
and also in OnUnload:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language);
Comment both of these lines out and recompile. Your translate tags should now work correctly, provided that you are using English, Swedish or Norwegian. You can also add your own languages of course.
Note that you can also ‘fix’ this issue by making sure that all your Editors have a specific language set in their Display Options, but that’s more of a workaround and I think it’s best to fix it properly.
4. Fix: Order search bug
If you actually try to search for orders you will only find orders that you placed and no others. You can prove this by logging on as someone else and placing an order, then logging back in yourself and searching for orders. This is because there is a bug in the order search page, but it is very easy to fix.
In your EPiStoreSample project, open the SearchOrder.aspx.cs file in /Shopping/Admin. Find the line below in the DoSearch method:
DataSet orders = cartDB.ListOrders(storeID,
EPiServerProfile.Current.UserName,
fromDate,
toDate,
Email.Text,
(OrderStatus)Int32.Parse(Status.SelectedValue));
Replace the parameter EPiServerProfile.Current.UserName with an empty string, “”. This will cause the search to look for orders for all users and not just the currently logged on user. Recompile and test it and you should see all orders now being displayed.
5. Fix: Missing email addresses
Note: This section only applies when using the SQL based role/membership providers, which you’ll have to use if you are registering new shoppers on the example site.
When you go to checkout and you are not logged in, you are prompted to log in or register. If you choose to register, then you are taken to the example registration page. Once registered, you are returned to the checkout. You may notice however that your email address that you just used to register is missing and if you try to send the order you get the following error:
“An e-mail address must be set in your personal settings to be able to place an order.”
There is a reason for this, although not a very good one. When you registered, you used the ASP.Net SQL Membership provider. However, EPiStore is looking for an email in an ASP.Net SQL Profile, which doesn’t actually exist yet. You can workaround this by filling in your ‘Personal Settings’ in the EPiStore area and saving them, and it will then work fine. However, this is a bit messy as you have now entered two email addresses and they might not even match.
Fortunately, it’s not hard to make a little fix. EPiServer provide a nice little way to get the email address of the current user from the profile and ‘fallback’ to the email address in the membership provider if it can.
To implement the fix, we need to amend two files. Firstly, load up CheckOut.ascx.cs which is found in /Shopping/Units. In there, replace the references to .Email with a reference to .EmailWithMembershipFallback
Firstly, in RegisterOrder_Click (note there’s two references in here):
else if (EPiServerProfile.Current.Email == null ||
EPiServerProfile.Current.Email.Length <= 5)
And in SaveCartForCurrentUser:
order.Email = EPiServerProfile.Current.Email;
And in LoadUserSettings:
Email.Text = EPiServerProfile.Current.Email;
Next load up PersonalSettings.ascx.cs in the same folder, and in the LoadUserData method change the reference in the following line:
Email.Text = user.Email.ToString();
Save all files and recompile. This will now allow the Membership email to be used if the profile is missing an email address. Note that the user could still enter a different email address into their Personal Settings if they wanted. Maybe this is an extra change you could make to prevent that. You may also want to make the username textbox read-only as changes to that can’t be saved anyway.
6. Suggestion: Secure your site
The administration plugins for EPiStore could possibly be run directly by an anonymous user if they could figure out the structure of your website. It might be unlikely, but it’s best to prevent this. The simple way to do it is to add a new location to your web.config, as below:
<location path="shopping/admin">
<system.web>
<authorization>
<allow roles="WebEditors, WebAdmins, Administrators" />
<deny users="*" />
</authorization>
</system.web>
</location>
This will mean that access to the administration functions is limited to the groups you specified.
Summary
EPiServer have tried to make EPiStore as open and easy to use as possible, which is why all these fixes and suggestions are so simple. Hopefully these will help someone out and if you have any more comments about EPiStore please let us know!
Great post! I have recently migrated a site that had an existing EPiStore installation and I too had to fix these things, but the translation bug had slipped through :)
can you share us with public sites that use EPIStore please ?