Tim

Footprints in the snow of a warped mind

uCommerce

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

FreeAgent Small Business Online Accounting
Business Protection by Crisis Cover

Tag Cloud

AJAX (4) Analysis (3) ASP (6) ASP.Net (59) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Azure (1) Born In The Barn (1) Business (89) Business Start-up Advice (32) Client (17) Expanding Your Business (23) Recruitment (1) C# (22) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) CIMA (1) Cisco (1) 7970G (1) CMS (1) Code Management (1) Cohorts (4) Commerce4Umbraco (1) Content (1) Content Management (1) Content Management System (1) CSS (4) dasBlog (5) DDD (2) DDDSW (1) Design (11) Icons (1) Development (26) Domain Names (1) eCommerce (12) Employment (2) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Git (1) Google (1) Google AdWords (1) Google Analytics (1) Hacking (1) Helpful Script (3) Home Cinema (2) Hosting (2) HTML (3) IIS (11) iPhone (1) JavaScript (5) jQuery (2) Marketing (6) Email (1) Multipack (1) MVC (1) Networking (3) Nintendo (1) Nuget (1) OS Commerce (1) Payment (1) Photography (1) PHP (1) Plugin (1) PowerShell (3) Presentation (1) Press Release (1) Productivity (3) Random Thought (1) Script (2) Security (2) SEO (6) Server Maintenance (7) Server Management (12) Social Media (2) Social Networking (3) Experiment (1) Software (11) Office (5) Visual Studio (14) Windows (5) Vista (1) Source Control (1) SQL (9) SQL Server (19) Statistics (2) Stored Procedure (1) Sublime Text 2 (1) SVN (1) TeaCommerce (1) Testing (2) The Cloud (1) The Site Doctor (136) Turnover Challenge (1) Twitter (3) uCommerce (13) Umbraco (31) 2009 (1) 2011 (1) Useful Script (2) Virtual Machine (1) Web Development (71) WebDD (33) Wii (1) Windows Azure (1) XSLT (1)

Blog Archive

Search

<May 2013>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Recent Comments

Blog Archive

Various Links

Google+

Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2013 Tim Gaunt.

Sign In

# Saturday, May 11, 2013

Quickly delete all products and orders from uCommerce

Saturday, May 11, 2013 11:09:59 AM (GMT Daylight Time, UTC+01:00)

Sometimes you need to blitz your uCommerce database e.g. just before launch or to remove the testing products etc.

This is a quick database clear script which will clear delete all orders and products in uCommerce.

Be careful - this will remove everything without any form of checks (this is the V3 script let me know if you need it for other versions).

BEGIN TRAN

DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_ShipmentDiscountRelation
DELETE FROM uCommerce_Discount
UPDATE uCommerce_OrderLine SET ShipmentId = NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL
DELETE FROM uCommerce_Shipment
DELETE FROM uCommerce_OrderAddress
DELETE FROM uCommerce_OrderProperty
DELETE FROM uCommerce_OrderLine
DELETE FROM uCommerce_PaymentProperty
DELETE FROM uCommerce_Payment
DELETE FROM uCommerce_OrderStatusAudit
DELETE FROM uCommerce_PurchaseOrder
DELETE FROM uCommerce_Address
DELETE FROM uCommerce_Customer

DELETE uCommerce_ProductRelation
DELETE uCommerce_ProductProperty
DELETE uCommerce_ProductDescriptionProperty
DELETE uCommerce_ProductDescription
DELETE uCommerce_CategoryProductRelation
DELETE uCommerce_PriceGroupPrice
DELETE FROM uCommerce_Product

-- Just double check things have gone
SELECT * FROM uCommerce_PurchaseOrder o
SELECT * FROM uCommerce_Product p

-- For safety's sake, run it in a transaction just in case you change your mind
ROLLBACK TRAN
-- When happy it works, uncomment this line and comment out the ROLLBACK
-- COMMIT TRAN
 

Don't forget to follow me on Twitter.

# Friday, December 14, 2012

Prices including tax on uCommerce

Friday, December 14, 2012 4:03:30 PM (GMT Standard Time, UTC+00:00)

Most of our retailers price point their products to include tax i.e. a shirt that costs you £100 would include a proportion of VAT that the retailer would have to pay (at the moment about £16.67).

One frustration I've had for a while with uCommerce is that although you can opt to show prices with VAT (below), this just toggles the display and the calculations are just the same. This means the website administrator has to enter the prices excluding VAT (in this instance £83.33).

SNAGHTML1121d35

That's not only a laborious task, prone to error for the editor but as we found out on Staunton Moods the other day, can also cause rounding issues when ordering in multiples. On digging into it, the product prices are stored to 4 decimal places whereas the tax is only stored to 2 decimal places so we ended up with the following scenario:

?179.99 inc VAT @ 21% = ?147.9338842975207 exc VAT (or ?147.9339 when rounded to 4dp)

Total Without Tax   ?147.9339 * 2       =  ?295.8678
Tax Total           ?31.07 * 2          =  ?62.14
Grand Total         ?295.8678 + ?62.14  =  ?358.0078 (or ?358.01 when rounded)

Thankfully it's surprisingly easy to resolve in uCommerce. After a little a little playing around with IPricingService and ITaxService on simplygigabyte.co.uk (a blank demo store install) I managed to resolve the issue. The trick is not to override the ITaxService as this results in double calculations. Instead just roll out your own IPricingService like so:

namespace SimplyGigabyteCommon.Catalog
{
    using System;

    using UCommerce;
    using UCommerce.Catalog;
    using UCommerce.EntitiesV2;

    public class TaxIncludedInPricePricingService : IPricingService
    {
        public Money GetProductPrice(Product product, PriceGroup priceGroup)
        {
            // Get the default pricing provider to get the product's price
            var pricingService = new PricingService();
            var incTax = pricingService.GetProductPrice(product, priceGroup);

            // Calculate the tax part of the price
            var tax = CalculateTax(priceGroup, incTax);

            // To avoid rounding issues, subtract the tax value from the item's price
            var excTax = incTax.Value - tax;

            // Return the excluding tax part (the tax can be calculated as normal 
            // with the standard TaxService
            return new Money(excTax, incTax.Culture, incTax.Currency);
        }

        private decimal CalculateTax(PriceGroup priceGroup, Money amount)
        {
            if (priceGroup == null)
                throw new ArgumentNullException("priceGroup");

            if (amount == null)
                throw new ArgumentException("amount");

            var incTax = amount.Value;
            var taxRate = priceGroup.VATRate;
            var priceTotal = 1 + taxRate;
            var tax = (incTax / priceTotal) * taxRate;
            return tax;
        }
    }
}

You'll then need to update your uCommerce configuration file to use your new IPricingService. In post v3 versions of uCommerce, the file is stored in /umbraco/ucommerce/configuration/Core.config.

Change:

<component id="PriceService" service="UCommerce.Catalog.IPricingService, UCommerce" type="UCommerce.Catalog.PricingService, UCommerce" />

To:

<component id="PriceService" service="UCommerce.Catalog.IPricingService, UCommerce" type="SimplyGigabyteCommon.Catalog.TaxIncludedInPricePricingService, SimplyGigabyteCommon" />

And that should be it -just make sure all your prices are updated to include tax in the admin area!

If you're running a pre v3 install then the logic is largely the same but instead of Money we've got PriceGroupPrice:

namespace StauntonMoods.Catalog
{
    using System;

    using UCommerce.Catalog;
    using UCommerce.EntitiesV2;

    public class TaxIncludedInPricePricingService : IPricingService
    {
        public PriceGroupPrice GetProductPrice(Product product, ProductCatalog catalog)
        {
            return this.GetProductPrice(product, catalog.PriceGroup);
        }

        public PriceGroupPrice GetProductPrice(Product product, PriceGroup priceGroup)
        {
            // Get the default pricing provider to get the product's price
            var pricingService = new PricingService();
            var incTax = pricingService.GetProductPrice(product, priceGroup);

            // Calculate the tax part of the price
            var tax = CalculateTax(priceGroup, incTax);

            // To avoid rounding issues, subtract the tax value from the item's price
            // you may also want to round the values here
            var excTax = incTax.Price.Value - tax;

            // Return the excluding tax part (the tax can be calculated as normal 
            // with the standard TaxService
            return new PriceGroupPrice
                {
                    Price = excTax, 
                    PriceGroup = priceGroup, 
                    Product = product
                };

        }

        private decimal CalculateTax(PriceGroup priceGroup, PriceGroupPrice amount)
        {
            if (priceGroup == null)
                throw new ArgumentNullException("priceGroup");

            if (amount == null)
                throw new ArgumentException("amount");

            var incTax = amount.Price.Value;
            var taxRate = priceGroup.VATRate;
            var priceTotal = 1 + taxRate;
            var tax = (incTax / priceTotal) * taxRate;
            return tax;
        }
    }
}

Also, in pre v3 versions of uCommerce, the file is stored in /umbraco/ucommerce/configuration/Components.config.

 

Don't forget to follow me on Twitter.

# Saturday, May 12, 2012

Umbraco powered CheckBoxList or DropdownList nodes in uCommerce admin area

Saturday, May 12, 2012 2:53:24 PM (GMT Daylight Time, UTC+01:00)

CustomControlInUCommerce2uCommerce is a great e-commerce engine for Umbraco and high on our list of options when evaluating new e-commerce projects at The Site Doctor.

One thing that has always bugged me however is the lack of extensibility on the admin backend. This is something I've discussed with Søren in the past and I believe is on the cards to be resolved in the upcoming v3 release but we wanted to see if there was a way we could get it working in the current release. Thanks to Dan's digging we've found it is (ish).

Skip to the downloads.

A Little Background

Before I dive into the code and overview how you should get it all wired up, I think it's worth understanding how uCommerce is structured out of the box:

  • Each uCommerce section has it's own folder under the "umbraco/uCommerce" folder so if you want to extend the functionality for the "Product Catalog" area then you will need to look in the "Catalog" folder.
  • The ASPX files are the main containers (e.g. EditProduct.aspx) and don't generally include any logic as they load up the various UserControls (the ASCX files) as tabs.
  • Adding custom tabs can be done through the uCommerce_AdminTab table but that's outside the scope of this post but Lasse has a good introduction on his blog.

As we plan to alter the product details edit functionality, we'll need to make a few changes to EditProductBaseProperties.ascx. It's worth taking a quick look around the file if you've not before as we've re-ordered the boxes, added classes and hidden the SKU field before, all of which is often useful. You'll notice at the end of the file there's  a repeater "ProductPropertyRepeater" -this is where uCommerce outputs the various custom properties you've setup.

Why's it useful?

Have you ever felt limited by the options of Text/Boolean/Enum/Image/Number and RichText and wished you could implement your own cool control like an image cropper or checkbox list? What about driving that control with data from Umbraco or another data source? If you have, this is the blog post for you as it handles all those scenarios.

Getting Started

If you don't want to know how to do this yourself you can click here to skip to the downloads and get started straight away.

Caution: If you want a CheckBoxList or your own custom control, you need to be running v2.6 as it adds IWebControlAdapter. As of v2.6 I'm not convinced IWebControlAdapter is fully implemented as it allows you to retrieve the value from the control but we will need to override the UserControl which outputs the control which feels hacky.

Create a custom control

Unless you want a fairly standard control (TextBox, CheckBox, DropDownList or ContentPickerUCommerce) you'll need to create a control which uses the IWebControlAdapter interface. This will mean uCommerce is able to get the value from it. You will need to implement two methods:

  • Adapts(Control) - allows you to specify whether it is a control you will be managing.
  • GetValue(Object) - allows you to specify what value the control contains In it's entirety it could be pretty simple:
namespace TheSiteDoctor.Web.uCommerce.Admin.UI
{
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Linq;

    using UCommerce.Presentation.Web.Controls;

    public class UCommerceUmbracoDrivenCheckboxList : CheckBoxList, IWebControlAdapter
    {
        public bool Adapts(Control control)
        {
            return control is UCommerceUmbracoDrivenCheckboxList;
        }

        public object GetValue(object control)
        {
            var li = (UCommerceUmbracoDrivenCheckboxList)control;
            var values = (from ListItem listitem in li.Items where listitem.Selected select listitem.Value).ToList();
            return string.Join(",", values);
        }
    }
}

Create your own DataTypeControlFactory

uCommerce uses DataTypeControlFactory to determine what control to render in the editor so you'll need to override the default implementation because it doesn't look for IWebControlAdapters at the moment.

This is simple enough, it needs to accept a Page (the page you'll be adding the control to) and the work out what control it should output e.g.:

public class CustomDataTypeControlFactory : DataTypeControlFactory
{
    Page _page;

    public CustomDataTypeControlFactory(Page page)
        : base(page)
    {
        _page = page;
    }

    public Control CreateCustomControl(IProductProperty productProperty)
    {
        if (productProperty == null)
            throw new ArgumentNullException("productProperty");

        return CreateCustomControl(productProperty.ProductDefinitionField, productProperty.Value);
    }

    private Control CreateCustomControl(ProductDefinitionField productDefinitionField, string value)
    {
        var fieldType = productDefinitionField.DataType.TypeName;

        if (fieldType.StartsWith("Something"))
            return base.CreateControl(productDefinitionField, value);

        // Some logic to work out whether you should be creating the control
        return customControl;
    }
}

Add a custom ProductPropertyEditor.ascx

Now you'll need to create your own ProductPropertyEditor.ascx which calls your new DataTypeControlFactory:

public partial class CustomUcommerceProductPropertyEditor : ProductPropertyEditor
{
    protected new void Page_Load(object sender, EventArgs e)
    {
        InitializeControl();
    }

    public override void DataBind()
    {
        base.DataBind();
    }

    private void InitializeControl()
    {
        Controls.Clear();
        Control child = CreateControlToRender();
        Controls.Add(child);
    }

    private Control CreateControlToRender()
    {
        if (ProductProperty == null)
        {
            throw new InvalidOperationException("Cannot create control, ProductProperty not set.");
        }

        var factory = new CustomDataTypeControlFactory(Page);
        return factory.CreateCustomControl(ProductProperty);
    }
}

You may notice that we're clearing the controls in the InitializeControl which is called from Page_Load whereas uCommerce makes the same call from DataBind(); this is intentional. I've not yet figured out why but if you don't do it from Page_Load, uCommerce still outputs a TextBox.

Wire it all up

To get this all outputting, you now need to replace the call to ProductPropertyEditor in EditProductBaseProperties.ascx with a reference to your own ASCX file, you can do this by updating this line:

<%@ Register Src="~/Umbraco/UCommerce/Controls/ProductPropertyEditor.ascx" TagPrefix="commerce" TagName="ProductPropertyEditor" %>

To:

<%@ Register Src="~/Umbraco/UCommerce/Controls/[YourFileNameHere].ascx" TagPrefix="commerce" TagName="ProductPropertyEditor" %>

Edit your Presenters.config

At this point if you were to load up your uCommerce backend you'd find that it outputs as intended but when you saved the file you'd either get an error or the value doesn't save. The reason for this is although you've replaced the display aspect of the editor, uCommerce is still looking at it's old "GetValue" implementation instead of your new control.

Open /umbraco/ucommerce/configuration/presenters.config and add a reference to your control which implements the IWebControlAdapters interface:

<component id="UCommerceUmbracoDrivenCheckboxList"
			service="UCommerce.Presentation.Web.Controls.IWebControlAdapter, UCommerce.Presentation"
			type="Your.Custom.uCommerce.Namespace.ControlName, Your.Custom.uCommerce.AssemblyName" 
			lifestyle="PerWebRequest"/>

That's it, you're done, you can now add your own controls to the backend of uCommerce.

CustomControlInUCommerce

Download

To make life easier I've packaged the files up into an Umbraco package and have also added the source:

Download the source code with references (C#) - 800KB

Download the Umbraco Package - 12KB

Instructions on using the package

If you download the source code you may have noticed we're doing some funky things with the DataTypeName. The idea behind the control is that it allows us to output a DropDownList or CheckBoxList containing values based on a Document Type and start node purely from the name of the DataType.

I can go into more detail about how we're doing this if it's of interest, just leave me a comment below but to start using it straight away you will need to use the following naming convention for your DataType's name:

  1. TSD_: This is the prefix we use to identify whether it's a control we should be handling
  2. Control Type: Currently this can either be "ddl" for a DropDownList or "chkl" for a CheckBoxList
  3. Start Node Id: This should be the id of the Umbraco parent node. You can cheat and use the root node but it's best to use the parent
  4. Document Type: This is the Document Type's alias to use

Example: if you wanted a list of checkboxes for ShapeType (as above) then your name would be: TSD_chkl_1234_ShapeType and a DropDownList would be: TSD_ddl_1234_ShapeType

What next?

This is something we're using more and more in uCommerce these days as it allows us to use the power of Umbraco to power uCommerce which is allowing us to do some really interesting things. Although we'll only be developing it as we need it at the moment we do have plans to add support for:

  • Radio Button Lists
  • Image Cropper
  • Adding nesting to the list of items (to offer better support for hierarchical data)
  • Powering it by the members and media sections
 

Don't forget to follow me on Twitter.

# Friday, April 06, 2012

How to generate customer purchase cohorts from uCommerce data

Friday, April 06, 2012 10:02:29 AM (GMT Daylight Time, UTC+01:00)

I've had a couple of people ask how they can create customer purchase cohorts from their uCommerce data since my last post so here's a quick script.

Depending on how you've setup your uCommerce store, the customer ids might be different so instead of using customer id. I would use the email address of the customer personally as the identifier as this means you'll be able to analyse those customers who have chosen to check out anonymously Smile

Here's the SQL to output the data in a format suitable for www.quickcohort.com.

WITH Actions (FirstAction, LastAction, UniqueId)
AS (
	SELECT min(dateadd(dd, datediff(dd, 0, o.CompletedDate), 0))
		 , max(dateadd(dd, datediff(dd, 0, o.CompletedDate), 0))
		 , ltrim(rtrim(LOWER(cc.EmailAddress)))
	FROM [uCommerce_PurchaseOrder] o LEFT JOIN uCommerce_Customer cc ON cc.CustomerId = o.CustomerId
	GROUP BY ltrim(rtrim(LOWER(cc.EmailAddress)))
)
SELECT a.[FirstAction]
	 , a.[LastAction]
	 , count(a.[UniqueId]) AS [CountOfCustomers]
FROM
	Actions a
GROUP BY a.[FirstAction]
	   , a.[LastAction]
HAVING 
	min(dateadd(dd, datediff(dd, 0, a.[FirstAction]), 0)) IS NOT NULL
ORDER BY a.[FirstAction]
	   , a.[LastAction]

GO

 

Not using uCommerce as your e-commerce provider? Let me know and I'll knock up a script for you.

 

Don't forget to follow me on Twitter.

# Wednesday, August 31, 2011

How to hide a tree node in uCommerce or Umbraco

Wednesday, August 31, 2011 10:37:04 AM (GMT Daylight Time, UTC+01:00)

Have you ever needed to hide a node in the Umbraco or uCommerce trees? It's actually very easy, we needed to hide the Orders, Marketing and Analytics nodes of a new uCommerce install we were working on. All you need to do is set the "treeInitialize" value in the umbracoAppTree to false. This will then hide the entire tree.

The Update SQL

BEGIN TRAN

UPDATE dbo.umbracoAppTree SET treeInitialize = '0' WHERE appAlias = 'uCommerce' AND treeTitle = 'Analytics'

ROLLBACK TRAN

 

To use the SQL you will need to know the appAlias (this is the bit after the # in the Umbraco admin url once you've clicked the section icon e.g. in "http://www.domain.com/umbraco/umbraco.aspx#uCommerce" the appAlias is uCommerce). If you know the treeAlias it might be better to use that but it's probably easier to use the tree's title (in our case this would be Orders, Marketing and Analytics).

Not sure what tree you should be hiding? Just open the umbracoAppTree table and you'll have the trees from all sections there.

uCommerce tree before

HideTreeNodesBefore

uCommerce tree after

HideTreeNodesAfter

Couldn't be any easier could it!

 

Don't forget to follow me on Twitter.

# Friday, June 17, 2011

uCommerce is now free and why it’s great news

Friday, June 17, 2011 12:38:15 PM (GMT Daylight Time, UTC+01:00)

freeThose of you who were lucky enough to make it to CodeGarden 11 (or have been following the #CG11 hash tag) will no doubt already know that uCommerce Starter Edition is now free.

Why this is good news

For quite some time we've been lacking a good all-round e-commerce solution with CMS ability (regardless of platform). Many of us have written hacks, combined multiple solutions together to form a behemoth -usually involving multiple logins etc or attempted to write our own solution which (either down to time or budget limitations), is never quite re-usable. Ultimately, there's been no all encompassing solution that was affordable but more importantly, able cater for small stores as easily as it could enterprise level solutions.

Umbraco has been working hard over the past couple of years to make the CMS as robust as possible and is now powering sites like www.asp.net, http://msdn.microsoft.com and a fair few other enterprise solutions. Being a proven concept is great because it means your investment is minimal -you only need to learn one solution which is mature enough to cater the majority of scenarios and now adding e-commerce to it's arsenal means it covers all bases.

Which uCommerce version do you need?

One question that I heard a lot around CodeGarden was "yes it's free but what have they removed from it?". Usually when someone is giving away something for free, it's not quite what you need/want. Thankfully that doesn't appear to be the case with the free edition of uCommerce.

Depending on your requirements, you'll more than likely find that the starter edition more than covers your needs (it's what powers most of our solutions). I find the thing that usually confuses people is the use of "Catalog". In uCommerce, a catalog is a group of categories and most e-commerce sites only need one catalog.

You may need multiple catalogs in the following scenarios:

  1. The Umbraco instance runs multiple websites, each website needs to have it's own product catalog, shipping rules etc (basically it's own store)
  2. You want to have different category/product structures for different countries

How do they compare?

This is so hot off the press that they've not yet had a chance to update the comparisons so I may need to update this table but here's a quick look at the comparisons and I also currently don't know the prices

Starter (FREE) Edition Professional Enterprise
Unlimited Categories
Unlimited Products
Product Relations (What Customers Also Bought)
Multiple Shipping Methods
Multilingual  
Marketing Foundation (built in marketing, promotion codes etc)  
Review System  
Multiple Catalogs  
Multiple servers supported out of the box    
Multiple Catalogs with user level security    

What can you do with it?

uCommerce is able to handle pretty much any e-commerce scenario you're able to throw at it. We've reviewed all the e-commerce sites we've worked on over the years (either developed entirely or partly by us) and we have found very few scenarios that uCommerce isn't able to accommodate.

The really nice thing about uCommerce is if there's something missing you can simply write it yourself and plug into one of their many pipelines using .Net controls, XSLT, Ruby or Python (if you really wanted to!).

What does it mean for the competition?

There are a couple of other e-commerce solutions for Umbraco already namely Commerce4Umbraco (free and open source -based on dash commerce) and TeaCommerce. They've both got their strengths and weaknesses and that's for a different post but making uCommerce free will stir things up a little but in a very good way. It now means that regardless of your budget or requirements, you have a great choice of options.

I don't think this will kill off the other projects (and I hope it doesn't) because although uCommerce is most likely what we'll use every time, the other providers have got their uses in different scenarios and competition is healthy. If you're more confident in Umbraco itself then you'll probably "get" TeaCommerce quicker than uCommerce as they are structured slightly differently.

Borat_Two_thumbs_up_yoursWhat does it mean for the community?

This is massively good news for those who already use Umbraco as it means that you can let your customers sell online from the same interface that they're already using, but I think this has wider implications for the industry as a whole.

As I mentioned earlier, Umbraco have been working hard on making the CMS a very robust offering. Being able to plug in an e-commerce solution now means you can offer your customers an end-to-end solution which easily rivals the enterprise (paid) solutions currently available. What's better for your customers is that it's all from one login whether it's content, e-commerce, blogging, Job listings etc.

I think that offerings like Magneto will be very interested to check out what they're doing. For those of you who think it's finally knocking out DotNetNuke as an offering, I'm afraid Umbraco did that in V3. Winking smile

Why am I shouting about it?

Ultimately it now means that there really is now no reason to not choose Umbraco -regardless of what platform you usually develop on (which is great because it means the community will grow).

Not a .Net developer? Don't worry, although it helps with customisation, it shouldn't stop you. The great thing with Umbraco and uCommerce is that you don't need to know any .Net to get running. The entire thing can be wired up through the web backend but if you don't believe me, get in touch and we'll go through it.

Disclaimer: I have been blogging and using uCommerce since it's first release and I am a proud wearer of their official t-shirt at CodeGarden but I still try and look at these things from an unbiased view point as if a better solution for our clients is presented to us then we'd consider it. Either way, I think this is a good move and if you want help with uCommerce, just get in touch.

 

Don't forget to follow me on Twitter.

# Friday, April 08, 2011

Taking UCommerce emails to the next level and include the order id in the subject, multiple recipients and Google click tracking

Friday, April 08, 2011 2:05:24 PM (GMT Daylight Time, UTC+01:00)

ucommerce-logo-emailOne of the things that I've felt has always been a little lacking in uCommerce was their email system, it's a great idea and nicely implemented but it was rather inflexible in earlier version -you couldn't send "other" emails easily etc.

Most of these bug bears have now been resolved however I still feel that even the latest v1.5 release is a few lacking features that we have tended to build into our email systems by default:

  • No ability to use place holders e.g. include the uCommerce order id in the subject line or write "Dear John" as a greeting
  • It didn't allow you to send to multiple CC or BCC recipients
  • There's no click tracking built in

So what does it do?

In our recent project - www.ChalkboardsUK.co.uk, we extended the existing EmailService and "patched" the missing functionality. There's more we can (and will) do with this in the future but for now this should get you started.

By passing in a combination of QueryString and Placeholder parameters, you can send personalised emails to your customer e.g. have a subject line of "Your order with our store #1234" or start your email with "Dear John".

EmailExample

As well as enabling place holders it allows you to send your email to multiple recipients at the same time by simply separating the CC or BCC addresses with a semi-colon.

Finally (and I think this is pretty darn cool), it automatically tags the links within your email with the Google Analytics tracking code! By using the EmailProfile it will enable you to see whether customers are clicking through on links etc within your emails. Pretty cool eh!

OrderConfirmation

The future

We're open to your thoughts on this and ideas for moving it forward but at the moment, we will be adding functionality:

  • Pass in a core objects e.g. a purchase order to give them access to any aspect of the data
  • Add the ability to format strings
  • Repeating regions (though this should really be done within your XSLT) Let me know what you think by leaving a comment, tweeting @timgaunt or emailing me.

Download It

You can download the file right now by clicking here (TheSiteDoctor.UCommerce.EmailService.zip).

How to use it?

The use of this depends on your individual setup, in this post I'm going to assume you've got a separate assembly which you can include this in however I'll post another post soon which wraps this all up into a pipeline. We also use this for the customer "welcome" emails as well so we can send a pretty email welcoming them to the store.

uCommerce changes

Nothing needs to change in the way that you setup your emails in uCommerce. If you would like to send to multiple CC or BCC recipients, simply separate the addresses with a semi-colon (;) as you would in your standard email client:

s

UCommerceEmailProfiles

Umbraco Changes

If you want your content editors to be able to include properties from the order in your email, they'll need to use place holders. At present, the place holders are fairly limited in that there's no repeating regions etc. You can inject anything you want (you'll just need to add the key to dictionary of place holders when constructing the email. The user can then use that value in the email by surrounding the key with square braces e.g. [Order.Total].

An example email:

Hi [Customer.FirstName]

Thank you for your order of £[Order.Total] on [Order.Date]. The details of your purchase are below.

Using it in your code

I would think the most common application for this at the moment will be within your own custom pipelines. If you've already used the UCommerce.Transactions.EmailService then you can retty much just replace the code. If you've not, here's an overview of how you can do it yourself:

// Create an instance of the EmailService
var service = new TheSiteDoctor.uCommerce.Transactions.EmailService();

try
{
    // Get the current catalog's email context
    var profile = SiteContext.Current.CatalogContext.CurrentCatalogSet.EmailProfiles.Single();

    // Setup the QueryString Parameters for the page that's got the various content on -in this instance we're just getting an order confirmation so just pass in the order number
    Dictionary<string, string> qs = new Dictionary<string, string>
        {
            { "orderNumber", purchaseOrder.OrderGuid.ToString() }
        };

    // Add the various bits of information you want to be able to pass to the content
    Dictionary<string, string> ph = new Dictionary<string, string>
        {
            { "Customer.FirstName", customer.FirstName },
            { "Customer.LastName", customer.LastName },
            { "Customer.EmailAddress", customer.EmailAddress },
            { "Order.Number", purchaseOrder.OrderNumber },
            { "Order.Date", purchaseOrder.CompletedDate.Value.ToShortDateString() },
            { "Order.Total", purchaseOrder.OrderTotal.Value.ToString("f2") }
        };

    // Send the email
    service.Send(profile, EmailTypeName, new MailAddress(customer.EmailAddress), qs, ph);
}
catch (Exception ex)
{
    // Something "not good" happened so add any other info that might be of help
    // Add the customer data
    ex.Data.Add("Customer.FirstName", customer.FirstName);
    ex.Data.Add("Customer.LastName", customer.LastName);
    ex.Data.Add("Customer.EmailAddress", customer.EmailAddress);

    if (purchaseOrder != null)
    {
        ex.Data.Add("OrderId", purchaseOrder.OrderId);
        ex.Data.Add("Order.Number", purchaseOrder.OrderNumber);
        ex.Data.Add("BasketId", purchaseOrder.BasketId);
    }

    // Send/log your alert
}
 

Don't forget to follow me on Twitter.

# Wednesday, March 09, 2011

Output the currency symbol in uCommerce

Wednesday, March 09, 2011 5:06:12 PM (GMT Standard Time, UTC+00:00)

currency-trading[1]One thing that's always bugged me about uCommerce is the way the prices are displayed (using the not so inviting ISO codes), this is a simple switch statement to output the (prettier) HTML symbol instead.

<xsl:choose>

    <xsl:when test="@currency = 'GBP'">

        <xsl:text disable-output-escaping="yes">&amp;pound;</xsl:text>

    </xsl:when>

    <xsl:when test="@currency = 'EUR'">

        <xsl:text disable-output-escaping="yes">&amp;euro;</xsl:text>

    </xsl:when>

    <xsl:when test="@currency = 'YEN'">

        <xsl:text disable-output-escaping="yes">&amp;yen;</xsl:text>

    </xsl:when>

    <xsl:otherwise>

        <xsl:text disable-output-escaping="yes">$</xsl:text>

    </xsl:otherwise>

</xsl:choose>
 

Don't forget to follow me on Twitter.

# Thursday, March 03, 2011

Remove uCommerce Product Definition Field in SQL

Thursday, March 03, 2011 8:11:10 AM (GMT Standard Time, UTC+00:00)

Sometimes you need to remove a product definition field from uCommerce e.g. one created in a test environment. Although you can just right click and click "delete" within the administration area, this sometimes doesn't work e.g. when it's a pre-release so this is a simple script which allows you to remove a product definition field from the database.

USE [YourDatabaseName]
GO

BEGIN TRANSACTION

-- Get a list of the current product definitions
SELECT * FROM dbo.uCommerce_ProductDefinition

DECLARE @ProductDefinitionId int, @ProductDefinitionFieldId int
SET @ProductDefinitionId = 23

-- Check that this is the right product definition
SELECT * FROM dbo.uCommerce_ProductDefinition WHERE ProductDefinitionId = @ProductDefinitionId
-- Get a break down of the various fields for the product definition
SELECT * FROM dbo.uCommerce_ProductDefinitionField WHERE ProductDefinitionId = @ProductDefinitionId

-- Set the field id
SET @ProductDefinitionFieldId = 40

-- Check the right field and descriptions will be removed
SELECT * FROM dbo.uCommerce_ProductDefinitionField f INNER JOIN dbo.uCommerce_ProductDefinitionFieldDescription d ON f.ProductDefinitionFieldId = d.ProductDefinitionFieldId WHERE f.ProductDefinitionId = @ProductDefinitionId AND f.ProductDefinitionFieldId = @ProductDefinitionFieldId
SELECT * FROM dbo.uCommerce_ProductDefinitionField f INNER JOIN dbo.uCommerce_ProductProperty p ON f.ProductDefinitionFieldId = p.ProductDefinitionFieldId WHERE f.ProductDefinitionId = @ProductDefinitionId AND f.ProductDefinitionFieldId = @ProductDefinitionFieldId
SELECT * FROM dbo.uCommerce_ProductDefinitionField WHERE ProductDefinitionId = @ProductDefinitionId AND ProductDefinitionFieldId = @ProductDefinitionFieldId

-- Remove any product property definitions
DELETE p FROM dbo.uCommerce_ProductDefinitionField f INNER JOIN dbo.uCommerce_ProductProperty p ON f.ProductDefinitionFieldId = p.ProductDefinitionFieldId WHERE f.ProductDefinitionId = @ProductDefinitionId AND f.ProductDefinitionFieldId = @ProductDefinitionFieldId
-- Remove any associated descriptions
DELETE d FROM dbo.uCommerce_ProductDefinitionField f INNER JOIN dbo.uCommerce_ProductDefinitionFieldDescription d ON f.ProductDefinitionFieldId = d.ProductDefinitionFieldId WHERE f.ProductDefinitionId = @ProductDefinitionId AND f.ProductDefinitionFieldId = @ProductDefinitionFieldId

-- Remove the field itself
DELETE FROM dbo.uCommerce_ProductDefinitionField WHERE ProductDefinitionId = @ProductDefinitionId AND ProductDefinitionFieldId = @ProductDefinitionFieldId

ROLLBACK TRANSACTION
-- When you're happy, uncomment this line
--COMMIT TRANSACTION
 

Don't forget to follow me on Twitter.

# Tuesday, October 26, 2010

Retrieve the customer’s last address when logging into uCommerce

Tuesday, October 26, 2010 11:31:55 AM (GMT Daylight Time, UTC+01:00)

header[1]Probably one of the most common features of an ecommerce systems is to "retrieve my details" when logging in -after all that's why you create an account with the seller isn't it?

Out of the box, uCommerce has XSLT to retrieve the customer's last x addresses but one thing it didn't do was automatically re-assign the customer's details when logging in using the built in Umbraco membership code so we need to work around it ourselves -don't worry, it's not too hard (all the code is below for you).

Background

All customer addresses are stored in the uCommerce_Address table automatically, there should be one unique address per customer however if you're on an earlier release you may find you have several copies of the same address for each customer -this is a bug that's been sorted in v1.0.5.0 so upgrade if you can.

Now you'd be forgiven for thinking that you can just select the address from the uCommerce_Address table and then assign the id to the BillingAddressId property of your purchase order however if you do that, you'll find you get the error:

The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_uCommerce_PurchaseOrder_uCommerce_OrderAddress". 
The conflict occurred in database "CommsReadyCMS", table "dbo.uCommerce_OrderAddress", column 'OrderAddressId'.
The statement has been terminated.

 

You'll get this because there is also a second table involved -uCommerce_OrderAddress. uCommerce_OrderAddress stores the actual address used throughout the order process incase the customer changes an address in the future, the order will always have the correct address.

The Solution

Working around this isn't actually too difficult as mentioned before. The easiest solution is to create a new User Control in Visual Studio (I'll call mine login.ascx) and hook into the LoggedIn event. Once logged in, get the Umbraco member and from that, get the customer's billing address.

There's one caveat that I found with uCommerce and that's the way it gets the address. At the moment, there is a function on customer "GetAddress", this is great however if you check out the code it calls, it actually gets the customer's first address from the database -rather than the last address used. I don't think this is a bug as in most cases the first address you enter is your main address. I'll blog separately about managing a default address within the members section.

The code below however retrieves the most recently added address from the database

Login.ascx

<asp:literal runat="server" ID="litLoggedIn" />
<asp:literal runat="server" ID="litLoggedOut" />
<asp:Login runat="server" id="lgnForm" CssClass="checkout-details" 
	DisplayRememberMe="false" TitleText="" OnLoggedIn="lgnForm_LoggedIn"
	UserNameLabelText="Email Address" />

 

Login.ascx.cs

protected void lgnForm_LoggedIn(object sender, EventArgs e)
{
    //If the user has a basket, wire up the shipping address with their last order details
    var basket = SiteContext.Current.OrderContext.GetBasket(true);
    if (basket != null)
    {
        //Get the customers current order
        var po = basket.PurchaseOrder;
        //Look for a shipping address
        var add = po.GetBillingAddress();
        //We only need to assign the address if there isn't already one assigned to this order
        if (add == null)
        {
            //Get the customer who's just logged in
            var mem = Membership.GetUser(lgnForm.UserName);
            //To be safe check that we have a member
            if (mem != null)
            {
                //Find the customer
                var customer = Customer.ForUmbracoMember(Convert.ToInt32(mem.ProviderUserKey));
                if (customer != null)
                {
                    //Get the customer's most recent address
                    var previousAddress = customer.Addresses.ToList().LastOrDefault(a => a.AddressName == "Billing");
                    //If you want to get the customer's first address just uncomment this line
                    //var previousAddress = customer.GetAddress("Billing");

                    //Populate the billing address with the address)
                    if (previousAddress != null)
                    {
                        OrderAddress address = new OrderAddress
                                {
                                    FirstName = previousAddress.FirstName,
                                    LastName = previousAddress.LastName,
                                    EmailAddress = previousAddress.EmailAddress,
                                    PhoneNumber = previousAddress.PhoneNumber,
                                    MobilePhoneNumber = previousAddress.MobilePhoneNumber,
                                    CompanyName = previousAddress.CompanyName,
                                    Line1 = previousAddress.Line1,
                                    Line2 = previousAddress.Line2,
                                    PostalCode = previousAddress.PostalCode,
                                    City = previousAddress.City,
                                    State = previousAddress.State,
                                    Attention = previousAddress.Attention,
                                    CountryId = previousAddress.CountryId,
                                    AddressName = "Billing",
                                    OrderId = new int?(po.OrderId)
                                };
                        //Store the address in the database
                        address.Save();
                        //Assign the address to the purchase order
                        po.BillingAddressId = new int?(address.OrderAddressId);
                        //Save the purchase order (shopping cart)
                        po.Save();
                    }
                }
            }
        }
    }
}
 

Don't forget to follow me on Twitter.

# Monday, October 04, 2010

Delete all UCommerce baskets older than x days

Monday, October 04, 2010 10:14:31 AM (GMT Daylight Time, UTC+01:00)

After my last UCommerce post on how to delete test orders and baskets from UCommerce, Søren suggested I extended the delete all baskets code to take into account when it was created. As my last code was relating to deleting test orders/baskets (and so would want to get rid of them all), I decided to post this one separately.

Delete all baskets older than x days

To use this, all you need to do is change the @addedBefore parameter to whatever date/time you want (or just adjust the –7 which represents seven days in the past.

--Delete all carts purchaseorders and associated data within x days
DECLARE @addedBefore smalldatetime
--By default the script deletes everything older than 7 days
SET @addedBefore = DATEADD(dd, -7, GETDATE())

BEGIN TRAN

UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL WHERE OrderNumber IS NULL AND CreatedDate <= @addedBefore
DELETE a FROM uCommerce_Shipment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE a FROM uCommerce_OrderAddress a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE a FROM uCommerce_OrderProperty a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE a FROM uCommerce_OrderLine a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE a FROM uCommerce_Payment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE a FROM uCommerce_OrderStatusAudit a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL AND b.CreatedDate <= @addedBefore
DELETE FROM uCommerce_PurchaseOrder WHERE OrderNumber IS NULL AND CreatedDate <= @addedBefore

--Uncomment this
--COMMIT TRAN

--And comment out this
ROLLBACK TRAN
 

Don't forget to follow me on Twitter.

# Friday, October 01, 2010

Deleting test orders and baskets from uCommerce

Friday, October 01, 2010 12:53:43 PM (GMT Daylight Time, UTC+01:00)

Although Søren has posted a helpful post on how to delete entire purchase orders from the database here, we needed something a little less “all or nothing” so put the below together.

Delete a specific order id

--Delete purchaseorders and associated data based on order id
DECLARE @OrderNumber nvarchar(50)
SET @OrderNumber = 'TEST-40'

BEGIN TRAN

UPDATE a SET ShipmentId = NULL FROM uCommerce_OrderLine a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE OrderNumber IS NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL WHERE OrderNumber = @OrderNumber
DELETE a FROM uCommerce_Shipment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE a FROM uCommerce_OrderAddress a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE a FROM uCommerce_OrderProperty a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE a FROM uCommerce_OrderLine a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE a FROM uCommerce_Payment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE a FROM uCommerce_OrderStatusAudit a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
DELETE FROM uCommerce_PurchaseOrder WHERE OrderNumber = @OrderNumber

--TODO: Expand this so it checks for other orders
--DELETE a FROM uCommerce_Address a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber
--DELETE a FROM uCommerce_Customer a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber = @OrderNumber

--Uncomment this
--COMMIT TRAN

--And comment out this
ROLLBACK TRAN

 

 

Delete all baskets

--Delete all carts purchaseorders and associated data

BEGIN TRAN

UPDATE a SET ShipmentId = NULL FROM uCommerce_OrderLine a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE OrderNumber IS NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL WHERE OrderNumber IS NULL
DELETE a FROM uCommerce_Shipment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE a FROM uCommerce_OrderAddress a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE a FROM uCommerce_OrderProperty a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE a FROM uCommerce_OrderLine a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE a FROM uCommerce_Payment a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE a FROM uCommerce_OrderStatusAudit a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.OrderNumber IS NULL
DELETE FROM uCommerce_PurchaseOrder WHERE OrderNumber IS NULL

--TODO: Expand this so it checks for other orders
--DELETE a FROM uCommerce_Address a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.NULL = @NULL
--DELETE a FROM uCommerce_Customer a INNER JOIN uCommerce_PurchaseOrder b ON a.OrderId = b.OrderId WHERE b.NULL = @NULL


--Uncomment this
--COMMIT TRAN

--And comment out this
ROLLBACK TRAN

 

Update: At the request of Søren, I’ve altered the delete all baskets post so it allows you to delete all baskets older than a given date, see: Delete all UCommerce baskets older than x days

 

Don't forget to follow me on Twitter.

# Tuesday, August 17, 2010

Getting started with uCommerce

Tuesday, August 17, 2010 5:49:45 PM (GMT Daylight Time, UTC+01:00)

ucommerce-logo-symbol[1]I thought seeing as uCommerce is now an actual product I would start to overview an install/configuration of uCommerce assuming no prior knowledge of uCommerce. Firstly, let me start of by saying that once you've got your head around uCommerce and some of it's complexities, you'll find it a fantastic product that makes creating a new ecommerce website as easy as setting up a standard Umbraco website. It is still missing a few features, but you can easily work around these with a bit of custom XSLT/C#.

Ok, back to setting up your first uCommerce website. I've grouped these into what I feel are logical sections but if I've missed something, please let me know.

1. Install the uCommerce Package

If you've not already done so, go to the uCommerce Download page and download the uCommerce package (at time of writing, I'm using 1.0.4.2) and then download the uCommerce Store package (currently 1.0.1.2).

Install the uCommerce package as you do any other package in Umbraco. Once installed you'll be able to install the store package.

Assuming all your permissions on your Umbraco install are correct, refresh your browser and you should have a new section "Commerce". If they're not right, you'll be told to add a few web.config settings.

2. Wire up the catalog

This is the step that I didn’t “do” when we first got started and it turns out it’s one of the most important steps as it joins the uCommerce catalog to the front end.

  1. Go to your Umbraco "Content" section
  2. Right click on the page you would like to be the store's "home" page (in the example store, this would be "Shop")
  3. Click "Manage hostnames" (see figure below)
    Manage Hostnames Context Menu
  4. Enter your hostname (the domain name the site runs on) in the "Domain" box and then choose the default language for the website
    Manage Hostnames screen
  5. Click "Add new Domain" and then "Close this window"
  6. Click the "Commerce" section button (in the bottom left)
  7. Click the little arrow to the left of "Product Catalog"
  8. Left click the relevant catalog (if you've installed the store package this will be "uCommerce")
  9. Select your new domain from the "Host name" drop down list
    Manage Hostnames screen
  10. Click the save disk button in the top left

3. Setup Your Product Definitions

A “Product Definition” is uCommerce’s concept of document types, it allows you to add additional information to the product. If you’re using the uCommerce starter store, you’ll get a couple of product definitions out of the box –software and support. At the moment, you can't add additional properties through the uCommerce back end (i.e. if you wanted to add additional information such as Meta Keywords/Descriptions etc -I'll cover how we got around this in a later post) but there are a number of default the category/product properties (I've put their XML reference in brackets where relevant):

uCommerce Category Properties

  • Image (@image)
  • Display Name (@displayName)
  • Description (@description)

The default XML looks like this:

<category parentCategoryId="" parentCategoryName="" index="0" id="67" name="Software" displayName="Software" displayOnSite="True" description="" image="" />

uCommerce Product Properties

  • SKU (@sku)
  • Internal name
  • Display on web site (@displayOnSite)
  • Allow ordering (@allowOrdering)
  • Thumbnail (@thumbnailImage)
  • Primary image (@primaryImage)
  • Display name (@displayName)
  • Short description (@shortDescription)
  • Long description (@longDescription)

The default XML looks like this (the variants are not standard but are there because they're setup as part of the store package):

<product index="0" sku="100-000-001" displayName="uCommerce 1.0 RTM" shortDescription="uCommerce is a full featured e-commerce platform with content management features powered by Umbraco. Everything you need to build a killer e-commerce solution for your clients!" longDescription="uCommerce is fully integrated with the content management system Umbraco, which provides not only the frontend renderendering enabling you to create beautifully designed stores, but also the back office capabilities where you configure and cuztomize the store to your liking.&#xD;&#xA;&#xD;&#xA;uCommerce_ foundations provide the basis for an e-commerce solution. Each foundation addresses a specific need for providing a full e-commerce solution to your clients. foundations in the box include a Catalog Foundation, a Transactions Foundation, and an Analytics Foundation.&#xD;&#xA;&#xD;&#xA;Each of the foundations within uCommerce_ are fully configurable right in Umbraco. No need to switch between a multitude of tools to manage your stores. It's all available as you would expect in one convenient location." thumbnailImage="1097" primaryImage="1097" allowOrdering="True" isVariant="False" displayOnSite="True" hasVariants="True" price="3495.0000" currency="EUR">
  <variants>
    <product index="0" sku="100-000-001" displayName="Developer Edition" shortDescription="" longDescription="" thumbnailImage="0" primaryImage="0" allowOrdering="False" isVariant="True" displayOnSite="False" hasVariants="False" variantSku="001" price="0.0000" currency="EUR" Downloadable="on" License="Dev" />
    <product index="1" sku="100-000-001" displayName="30 Days Evaluation" shortDescription="" longDescription="" thumbnailImage="0" primaryImage="0" allowOrdering="False" isVariant="True" displayOnSite="False" hasVariants="False" variantSku="002" price="3495.0000" currency="EUR" Downloadable="on" License="Eval" />
    <product index="2" sku="100-000-001" displayName="Go-Live" shortDescription="" longDescription="" thumbnailImage="0" primaryImage="0" allowOrdering="False" isVariant="True" displayOnSite="False" hasVariants="False" variantSku="003" price="3495.0000" currency="EUR" Downloadable="on" License="Live" />
  </variants>
</product>

Adding additional product properties is simple.

  1. Click the "Commerce" section button
  2. Navigate to: Settings --> Catalog --> Product Definitions
  3. Choose the product definition you would like to edit (or create a new one in the same way that you would with Umbraco document types)
  4. Right click the product definition you need to add extra properties to and click "Create"
  5. Type in a name for your new property i.e. Size
  6. Choose the Data Type for the property (if you need something that's not listed see "Creating your own Data Type" below):
    • ShortText -A textbox
    • LongText -A text area
    • Number -Beleive it or not, a numeric value
    • Boolean -A checkbox
    • Image -A media selector
  7. Click the "Create" button
  8. You can now choose a few additional options for the new property including how it should be shown to the user and whether it's Multilingual.
    • Name -the text used as the label in the uCommerce product editor (it's also the name of the attribute on the XML that will contain it's value)
    • Data Type -the type of control to render in the uCommerce product editor
    • Multilingual -whether the control should be shown on the "Common" tab of the uCommerce product editor or the language specific tab
    • Display On Web Site -A flag that's sent out in the XML so you can decide whether or not to show it on the website
    • Variant Property -Whether this should appear as a table column heading under the "Variants" tab (I'll go into variants more in a later post)
      Note: Do not set Multilingual and Variant property to both true as at the moment, it won't be shown in the uCommerce product editor -you've been warned!
    • Render in Editor -Whether the control should be shown in the uCommerce product editor screen or hidden from the administrator (i.e. for data you want to use internally only and should be editable)
  9. Finally you'll need to enter in a Display Name for the various languages. This is what's shown to the user if you dynamically pull through the various properties on the product details page.

4. Creating Your Own Data Type

Now, you may be thinking that using that set of data types is a little limiting for something like "Size" or "Colour" and you might want to display something a little more flexible to the user -such as a drop down list. This is easy enough:

  1. Right click the "Data Types" node
  2. Enter a name i.e. "Size"
  3. Choose the definition for the Data Type (for size we will use "Enum")
  4. Save and Refresh the "Data Types" node
  5. Right click your new Data Type and click Create
  6. Enter your Option's value i.e. "Small"
  7. Repeat 5-6 until all your options are set i.e. add "Medium" and "Large"

Note: At the moment, the enum values cannot be re-ordered through the UI so make sure you add them in the order you want them in the editor!

5. Load Your Catalog

Once you've finished creating your various product types, it's time to create your catalog. Creating categories and products within uCommerce is as simple as creating pages in Umbraco. Using the same right click menu concept you can create nested categories as deep as your catalog requires. You can add products and categories at any level by choosing either the "Category" or "Product" radio button and choosing your product type.

6. You're Done!

Assuming you've followed the steps above, you should now have a (fairly basic) store setup. Go to your site's homepage and click the "uCommerce" menu item and voila, your categories and products should be listed.

Not getting the categories you were expecting? Perform the helpful xsl “copy-of” trick within either the "RootCategories[XSLT].xslt" file or "Category[XSLT].xslt" file:

<pre><xsl:copy-of select="$categories" /></pre>

and then have a look at the output:

<errors><error>No product catalog group found supporting the current URL.</error></errors>

If you're getting the above error, currently (and this may be a misunderstanding/changed later) you have to have the catalog and catalogue group names the same –in the example site, they’re both “uCommerce”.

As I think the concept store offered with Software/Support isn't particularly real-world, I'm going to work on creating a basic store that you can use to better understand uCommerce and it's intricacies.

Check back soon as I'll be posting an overview of the checkout process, the various XSLT files and integrating payment gateways into uCommerce (initially SagePay, PayPoint, WorldPay and PayPal).

 

Don't forget to follow me on Twitter.