Dan Matthews
Apr 22, 2009
  7479
(1 votes)

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!

Apr 22, 2009

Comments

Magnus Rahl
Magnus Rahl Sep 21, 2010 10:32 AM

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 :)

Arik Veeder
Arik Veeder Sep 21, 2010 10:32 AM

can you share us with public sites that use EPIStore please ?

Please login to comment.
Latest blogs
I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog

ExcludeDeleted(): Prevent Trashed Content from Appearing in Search Results

Introduction In Optimizely CMS, content that is moved to the trash can still appear in search results if it’s not explicitly excluded using the...

Ashish Rasal | Nov 7, 2024

CMS + CMP + Graph integration

We have just released a new package https://nuget.optimizely.com/package/?id=EPiServer.Cms.WelcomeIntegration.Graph which changes the way CMS fetch...

Bartosz Sekula | Nov 5, 2024

Block type selection doesn't work

Imagine you're trying to create a new block in a specific content area. You click the "Create" link, expecting to see a CMS modal with a list of...

Damian Smutek | Nov 4, 2024 | Syndicated blog

.NET 8 FAQ

I have previously written about .NET compatibility in general and .NET 8 in particular, see blog posts here , here and here . With the end of suppo...

Magnus Rahl | Nov 4, 2024