Showing posts with label Commerce Kickstart. Show all posts
Showing posts with label Commerce Kickstart. Show all posts

Tuesday, 11 June 2013

Using Calculation Rules to Add Per-Item Shipping in Commerce Shipping

Transcribed videos: -
[Drupal 7 / Ubercart video tutorial 7 of 10 showed how to use the default catalog module]
[Drupal 7 / Ubercart video tutorial 8 of 10 showed an alternative flexible method of showing a catalog]
[Drupal 7 / Ubercart video tutorial 9 of 10 shows how to use product kits, stock, and order states]
[Drupal 7 / Ubercart video tutorial 10 of 10 shows a simple checkout, reports, and suggests a theme] These videos are not related to the transcription below but may help anyone trying to get a Drupal ecommerce site running as quickly as possible.


Text introduction:
In this screencast I demonstrate how to do shipping charges per item in the cart. It shows using a loop in Rules and how to do something new and different with shipping.

We want to add $5.00 to the shipping charge for every item they have. So if the quantity is 5 for some line item, we'll add $25 to the shipping charge.

The technique is this:

    Add a shipping service. We're using a flat rate service with a $10 base rate.
    Add a new "Calculation rule" for that service.
    Add an action loop that loops through the line items in the order.
    Add an action "Calculate a value" & multiply the quantity times 500 ($5.00) & put the result in a named variable.
    Add an action "Add an amount to the unit price" that adds the named variable to the unit price of the shipping line item.


Using Calculation Rules to Add Per-Item Shipping in Commerce Shipping from Randy Fay on Vimeo.
Hullo! My name is Randy Fay. I'm [email]on Drupal.org, and I work with Commerce Guys on their Drupal Commerce Project, and I've been doing a series of screencasts showing how to configure shipping - Commerce_Shipping 2.0 - and I've demonstrated the new Commerce Flat Rate module, and also how to use Commerce UPS.

I want to show some more advanced rules techniques now.

I hope that if you aren't familiar with Shipping that you watch some of the other videos first because we are going to pretty deep into Rules this time. But lets just take a look at what we have for configuration, first of all.  If we go under Store>Configuration>Shipping , we have basically three things that we can configure, and we've looked at these in previous videos. [shows as three tabs on the screen]

|SHIPPING METHODS | SHIPPING SERVICES| CALCULATION RULES |

Under SHIPPING METHODS [tab] we have the provider, essentially. It could be flat rate, it could be UPS, it could be something else. And then each one of those can create SHIPPING SERVICES so we can create flat rate services for example, and I actually have a plain vanilla flat-rate service set-up here.  But the tab that we haven't looked at yet is called CALCULATION RULES. That's what we're going to do this time: we are going to demonstrate how CALCULATION RULES work.

Let's just take a look at what we have in the flat rate SHIPPING SERVICES right now: we don't have anything. It's just plain vanilla. And we have this - er - set up just for flat rate, and if we go back and look at the quick edit link here, we will see that this is the $10 base rate. And if we go to the checkout right now, every order would cost $10. - but..

Let's just say that we are actually going to charge per item that we put in the cart; that we do not want a flat rate. We want to charge per item with a minimum of $10. Let's say $10 plus $5 for each item that we add to the cart. Because each of these things costs us money to send. Let's go ahead and work on that. We'll use CALCULATION RULES to do that.

Again: our goal is to have a $10 flat rate, which we already have, and to add to that $5 for each item that they [the customer] have in their cart. So each item is not a line item; it is line item x quantity in that line item , so we have to do the calculation here.

We are going to go to CALCULATION RULES [tab]...

 |SHIPPING METHODS | SHIPPING SERVICES | CALCULATION RULES |

...we are going to say "add a calculation rule", and this is going to be [3'00"]
Name: "Add $5 for each product shipped", let's say.

When we do this calculation, what we have, is:
We are listening to the...
 Events EVENT Calculating a shipping rate
...event.
What we get passed into this rule is a shipping line item that is all ready-to-go; it has everything we need.
But when we see a line item here in this particular rule, it is the shipping line item and of course the shipping line item is associated with the order which can access the rest of the line items, which is what we are going to do.
So we have a shipping line item in our hands. Now we have to, under Actions, we have to  add a loop. We have to go through each of the line items and figure-out how much we need to add to the cost of shipping [4' 00"] for that line item.

We are going to add a loop here: +loop. The List that we are going to loop over is going to be
Add a new loop > List > Data Selector >

that is the list. So we are reaching out of our shipping line item out into the parent order , and from there we are getting the line items. So now in the current....
Now we have to name these things [by typing a name into the box], so I am going to call this
CURRENT LIST ITEM > Variable label> "line item"  and
CURRENT LIST ITEM>  Variable name>line_item

Now we have a way to examine every line item.
I am going to add an action...
Actions > OPERATIONS > Add action
Be careful to click the +Add action here [on the right, under OPERATIONS] under the loop rather than under the Actions [at the bottom left of the box in a blue stripe] [5'00"] or it won't be doing the right thing. You can drag these things around and place them in the right place. But this action needs to go under the rule.

What we are going to do is we are going to calculate data values
Add a new action > Select the action to add > calculate a data value
So we are going to multiply the quantity x $5.
We are going to say ... our commerce line item ... quantity : quantity is in there ...
INPUT VALUE 1 (the first input value for the calculation) > Data selector >

We are going to use multiplication

OPERATOR (the calculation operator) > Value > *
Down here we are going to put a value.
INPUT VALUE 2 (the second input value.) > Value > 500
In Rules we are always dealing with minor units, so 500 there for £5.
The result of this is going to be [types-in a name][6'00"]
Provided variables > CALCULATION RESULT > Variable label > "Calculated Line Item Shipping"
Provided variables > CALCULATION RESULT > Variable name >calculated_line_item_shipping

So this is the total shipping that we will add for this line item, which comes from multiplying the quantity of the line item times $5.

OK, so now we have that information.
Now we need to add one more action.
I will add an action here
Actions > OPERATIONS > Add action
Now what I am going to do (under "Commerce Line Item" among the options on the drop down menu) is choose
Actions > OPERATIONS > Add action > Add an amount to the unit price
Here we are adding to the shipping line item's price. We are all set here.

[7'00"]
The amount, though: I need to switch to
AMOUNT > Data selector and use the
AMOUNT > Data selector >

...which we have just created.
I am going to say that the Component should be flat rate.
PRICE COMPONENT TYPE > Value >
...
This isn't flat-rate shipping any more, but we'll call it that. um - so
What we are doing here is that we are adding another action that applies to this shipping line item that we have in our hands.  So. And..
We are going to add the amount that we calculated.
AMOUNT (specify a numeric amount to add to the unit price) > Data Selector >
..... to the existing amunt, and put it into the flat rate. So let's try that.
Take a look at the rule that we have. So this is just a standard thing.
We are listening for when calculating the shipping rate .
We don't have any conditions at all.
We create a loop.

Actions > ELEMENTS > Loop Parameter: List [commerce_line_item_order...
List Item [line_item]
> Calculate a value
Parameter: Input Value 1 [line_item_quantity], Operator:[*], Input Value 2: 500
> Add an amount to the unit price

And the loop is... the first thing it does is calculate... [8'00"]
It's a loop of line items, and for each line item, it calculates how much we should charge for that line item by multiplying the quantity - we have 500 here - and then add that amount to the unit price. And now we ought to have this. Let's go ahead and see what we've got.


I'll go out here [to a shopping page] and see what I've got. I've got some cheap products and some expensive products. I'll buy a Heavy Product and a Light Product
We expect that the shipping should be $10, which was our base rate for shipping, plus $5 for each of these line items. So we are expecting to ay $20. So we go to checkout. Order total is $100.  We go to the next step and calculate the shipping. And it shows $20. [9'00"] Which is what we expected. So lets go back and we will do that - lets change the cart where we have one light product, so that we have nine of these products. So now we have ten items in our shopping cart.  Ten items in our cart. So were are expecting to pay 10 x 5 + 10, so it should be $60. Let's try that. And the flat rate amount that we are expected to pay is $60. So that's working correctly. Let's go ahead and do that...

Oh I wanted to show you one little thing that I like to do when I am working on these things.
I should actually show you two things that I like to do when I am working on these things.

One is that I always edit the Views that I need to work on, to make them show the components;
I like to see what the components are, that are going-in to these. [10'00"] This [technique] is really useful with tax, and it's really helpful here as well. So you see that we have the flat-rate component. Anyway, I recommend changing the formatter on some of these fields to - Showing all the components, when you are working on something. The

Other thing that I recommend is:
Always turning-on the Rules debugging when you have any questions. So if you go to
Admin > Configuration > Workflow > Rules, and go to Settings
Turn on "show debugging information Never In case of errors  Always.
And then you will be able to debug - to debug quite a number of things. Let's go back here to our ordering [page]. I'll refresh it. [11'00"]. And here is our old [Rules] evaluation log. We can do down and we can see all of the things that we wanted to see.  And drill-down and study them very carefully. It takes a bit [of patience] to get used to this but you really have to do it; you have to understand how that works.

OK: sorry about that little diversion!

What we did is that we wanted to add $5 for every item in our cart.
What we did was we went to Store > Configuration > Shipping and we went to | CALCULATION RULES | this time, and we added a single rule which only had actions in it. It had a loop that went through the line-items and for each line-item it calculated the quantity x 500 (or $5).  Then it added that amount; it stored that amount in a variable. It added that amount to the unit price.
OK?
Well I hope that helped, and I hope you're doing well with shipping. Thank you so much for listening

If anyone is interested in stuff from the same person who transcribed this video, here is a series about Ubercart.


Sunday, 9 June 2013

Introduction to Commerce Shipping by Randy Fay


Introduction to Commerce Shipping from Randy Fay on Vimeo.
Finally Commerce_Shipping [module] is coming of age!

I want to give you a quick tour of how to do some things with commerce shipping.
What we're looking at today is this
So that's what we are going to work with. (and) [50" fifty seconds into the video]
What we are going to do is, first of all,
  • we are going to create a flat rate shipping class; we are going to say that it costs $10 to ship.  Then, after we experiment with that,
  • we are going to create free shipping, for products that are within Colorado. So we'll just go and change the rules, and we'll have free shipping within Colorado, and $10 shipping outside Colorado. So lets' give that a shot.


First of all go and enable the modules. So we will go over and enable the modules here [from modules>list he uses a filter to find "shipping" and "flat rate" which are installed as part of the Kickstart distribution he's using]. OK. Well. I'd already enabled them, but those are the ones that you want, and you'll find them under Commerce (Shipping) [picking from a grey-backed column on the left side of a page] you'll want Flat Rate, Shipping, and Shipping UI. [Shipping User Interface]

Later on, in another podcast in another screencast, I will show you how to do UPS [United Parcel Service] and in a further screen cast we'll do some more complicated rules like "free shipping over $100" - that kind of thing. 

But in this one, we're just going to do two shipping rates, one for within Colorado and one for outside Colorado.  We'll give that a shot and see if we can make that work.

So the first thing we're going to do is: we'll go-over to Store>Configuration>Shipping, and we're going to take a look at what we have here: We have [three tabs] -

| Shipping Methods | Shipping Services | Calculation Rules |

All we are going to do today is we're going to look at | Shipping Methods |, which is just there [the visible tab] by default: Flat Rate [method] is what we've got [by default], and | Shipping Services |. We can have one or more Flat Rate Shipping Services. You could think of them as "shipping instances", or whatever you want to call them.
[3'10"]
I'm going to say "add a flat rate service", [does so] and I'm going to say... I am going to call it "Flat Rate", and it's going to be $10. And now we have a new shipping service, under the tab

| Shipping Methods| Shipping Services | Calculation Rules |

Display Title: flat rate... ... ... ...  so this is all set-up. It will automatically be available as a shipping method for any purchase that we make. So let's go ahead and make a purchase.  We'll buy "product three" - how about that! Checkout.  And [add] shipping information.-I'm going to be in Palisade Colorado. Fill this in here. Continue-on.  We see that we are offered Flat Rate Shipping. That is the only service that we have to find.  And we go for it. So, here we are [at the "review your order" screen] - it's done exactly as we asked: it has added flat-rate shipping $10 on to our charge.  and... I've got no payment required. I've got free payment. That's not something you'd want on any site but I can have free payment on this one!

OK - so, Now.
I want $10 shipping in the rest of the USA but in Colorado I want just free shipping.  So there is
What we need to do is create another "free shipping" type. We're going to Store>Configuration>Shipping, and we're going to add another flat-rate service. We'll call it "free shipping inside Colorado".  [copies text for display title. leaves description blank]. And... price is zero.  [presses "save"] And now we have another service: it's called "free shipping inside Colerado"

What we need to do now is remember that this is a Rules component [of the Rules module].  Every rule has an 
  • event, a 
  • condition [or condions] and an 
  • action.  [points to the Conditions and Actions sections of the screen].  
Events are what a rule listens to, conditions decide whether it takes the action, and actions which are things that we are going to do. We are already listening for the "rate shipping" event, and we are going to say "should this rule apply to us", in other words "should we select free shipping"

[5'19"]

...so I'm going to add a condition [from a long drop-down menu including "Commerce Order" as a subheading in bold], and it's going to be a Commerce Order address component comparison. So there we go. The value that I want to compare against: the address that I want to use is the shipping address.. The address component that I want to compare is, first of all, I want to compare the Country. I'll make sure we get the country in there. Otherwise, there might be a "CO" abbreviation in some other country. By the way, this is the two-character country code for the country that I was talking about.  So we have a condition for that.  Now we are going to add one for the State. We're going to do the exact same thing again - Add a new condition> ORDER>Data selector> commerce_order

It's the shipping address that we want... [on the same page further down]
ADDRESS COMPONENT>Value>Administrative area (State / Province).
VALUE>Value
The two-letter code for Colerado is CO.
Save.

So now we have - er - two conditions on there [in the Conditions ELEMENTS box] One is:
Is the country US? The other is
Is the state Colerado?
Then we're going to add that there [in the Actions ELEMENTS box below].

So now we are going to go back and fix the other one so that we don't offer free shipping.
So let's go ahead and do that: we're not going to offer free shipping anytime that they are not shipping to Colerado. So: Store>Configuration>Shipping>ShippingServices 
And now we have to edit the flat rate - and this we don't want to offer if they are outside Colerado.

So let's just say that we only want to offer shipping in the US, because that's [  ] a separate thing.  So lets just go ahead and say [on Add a new condition] ORDER>Data selector ...
and the value of the administrative area [options are = / not =  / contains] lets say "equals" CO. And then we're going to say [with a tick box just above the save button at the bottom of the page] "Negate":  [9'30"] This does not contain Colerado so don't do it. Save.

Lets go ahead and add the other condition, about the US.
Add a new condition > Select the condition to add > drop down menu
Commerce Cart > ?
...just in case there is some other sort of thing [that has a CO abbreviation]. We'd probably take care of this another way, by offering a different shipping [service] outside the US, [which would] just tell them that we couldn't do it.
DATA SELECTOR > Country >
OPERATOR > equals
...just for now I am going to say "equals US"
We are going to say that this [flat rate shipping rule] applies to shipping that is in the US, but is outside Colerado.
[...]

And so now lets go-see if that works: [10'35"]
...you'll see that it already thinks that I'm in Colorado. No - it just doesn't know yet. It didn't ahve any information. Now we know. Now lets try again. Lets try shifting the state to Kentucky. ...and now it's offering only the flat rate $10 ammount. So now it's doing what we told it to do. The first time we tried this, we didn't have a way to choose [where we are] at the checkout.

...Colerado: then we get free shipping.


Let's just take a look at what we've done. First of all we've used
Commerce_Shipping [module] 2.X . We've used
Commerce_Flat_Rate - (
not the older (what do you call it?)... not the older Commerce_Shipping_Flat_Rate, which is basically depricated now.
Using those two, we have gone-in to Drupal admin (with Drupal Commerce enabled and a Store menu on admin).
  • We have gone into Admin>Store>Configuration>Shipping
  • We have a flat rate SHIPPING METHOD.
  • We hae added two services. Let's take a look at the two services we added. The two services are
  • Flat Rate (Machine name flat_rate), which is the $10 one, and
  • free Shipping inside Colorado (Machine name free_shipping_inside_colerado), which would be $0.
  • And then we added a Rules component to make sure that they were chosen at the right time. So free shipping is chosen if we are shipping to the US, and we are shipping to Colerado.
  • And we did the opposite on the other one.
So that's the basics! That's the first and easiest configuration of flat rate shipping .
I will do a couple more screen casts. I'll do one on Commerce_UPS, which is now working, and I'll also do one on fancy rules. So, thanks for listening, and see you in the issue queue and everywhere else! Thanks - bye bye.



.

Wednesday, 8 May 2013

Why is this difficult?

I thought Wordpress was the simplest fresh start, but found that there is trouble in paradise too -
Wordpress.tv/2013/02/18/justin-sainton-wordpress-e-commerce-2/
...tells me that at 4'49" "whatever e-commerce software you use, it's going to be awful in some way", but that e-commerce developing has the best rewards in happy customers when it goes right

The knack of combining various databases into a site for someone who wants to focus absolutely on shopping carts and not learn anything else is, well, asking for trouble when it gets complicated. In the US, tax is complicated for example.

In the UK, shipping is complicated. Royal Mail is not kind to plugin-writers, so any free ones are likely to become out of date. And UK shopkeepers are mercantile people in a little country, unlikely to rule-out selling to Australia or Germany if an order comes-in. All that's needed is a matrix quote system for prices or weights verses zones. Royal Mail has three or four world zones, and you can add more if your products to the UK have different volumes or you use a courier as well. I have a separate post about Royal Mail's zones and prices for ecommerce developers.

Even if I buy a textbook about a wordpress plugin or a good clear set of videos by  on how to use Wordpress for Ecommerce and watch patiently while taking notes, I'm likely to find an un-acknowledged gap where shipping options ought to be. Or an intended gap.

Wordpress has several ecommerce plugins jostling for trade, but all the ones I have discovered tend to charge for vital things like breathing or shopkeeping or posting objects via special essential modules. So these programs are open source crippleware, hoping to make money by charging you for something essential.


On the other hand, wordpress users seem a lot more recognisable as real low-budget people than Drupal users. There are plenty of plugins for hosting your pictures on flickr or plus.google to save bandwidth and disk space. This saves money. This saves the amount you have to sell in a recession to break even. This keeps you fed when others fail.



 
Magento is another easy option, or so I thought, because nearly all my stallholding shopkeeping rivals use it.
I bet a packet of biscuits that it will have some kind of stock reporting system that can be used for wholesale customers as an essential, and for stock control as a desirable option.
I bet one of my hadgehogs that Shipping will probably be sane compared to other carts. You just fill-in a configuration column about how many countries you would like to ship to, and I haven't finished the instructions but I guess that everything might be included in the core program with no ifs and buts and demands for £50 software. I don't know if zones will be allowed, or if every customer has to scroll through a list of countries starting with American Samoa, but something will be available.

Instructions exist, by the way. You type your version and language into a site and it emails you a 250 page .pdf book to read beginning to end, or to page 45 in my case.

A nifty .php file will check whether your test server suits Magento, and none of my 100% free accounts allowed it, but a nearly free one called Freehostia Chocoloate passed the test. (Freehostia Chocolate is free if you have a spare mainstream domain). Officially is allows 250MB equalling 262,144,000 bytes of disc space. Five hours later my attempted FTP upload stopped for lack of space after I tried uploading 6,396,182 bytes from Bitnami as a first experiment. This was just the relevant-looking files in a folder called Magento. This does not come-up in the easiest-to-find comparisons of shopping cart software.


Magento finds cheap servers a problem, as does Drupal. The programs are gross.
My fast UK web server that I want to use for real shopkeeping has these price breaks for disc space. It's smaller than some free but slower ones. Prices are per year (developers please note that servers can be priced per year as well as per month)
0200MB £050 + 20% tax
0400MB £100 + 20% tax
0600MB £150 + 20% tax
1200MB £250 + 20% tax

Further Googling finds that Magento likes to cache a lot. It has complex internal tables. And I haven't yet seen a free plugin that lets you host your pictures on a free website. So, basically, I can see why I am still in business and some rivals who use Magento have been struggling a bit in a recession. Maybe that's why some of them are on slower servers.

As with other shopping cart software, enthusiasts who sell support or blog about the product seem unaware of why it's difficult or even doesn't work for so many users.

I have another post called Free Fast and Pretty: which shopping cart? but it is has no clear conclusion yet.



Tuesday, 25 December 2012

Happy winter!

The new Commerce Kickstart installation is OK with a few error messages "right out of the box" as they say on the videos, and seems to work very slowly. Ignoring the error messages, I know from using Drupal Core that there is a heading in the menus called performance for things like cache to turn-on and make it fast. How to turn them on in Kickstart?

  • Core Drupal 7: I can speed-up the program by turning-on the cache (but I can't follow instructions for adding a product which is tricky, so I'm not using this dashboard for my shop). In Core Drupal, I try menu options until Configuration: my speeding-up options are in a box there marked Performance. Once there, the path reads:

    Home » Administration » Configuration » Development 
  • Commerce Kickstart 7.2: I can begin to follow instructions for adding a product, but I can't speed-up the program by finding the cache setting and turning it on. Moreover, the jargon has changed. Core Drupal had nodes and now has content. Commerce Kickstart has - something I still need to get my head around, which uses other terms.

    Found the answer! There are two settings menus and the second hides a lot of tekkie stuff away somewhere where I thought I'd looked, but had missed it. It's easy to miss something called Development when you know you're not a great developer. Trying the Kickstart web site it turns-out that I have asked this question before and got an answer, suggesting that cache still does exist so I had another look.



I was going to post a great picture of a man in Pants to Poverty undies standing next to a decorated cow, but their Shopify site is down today.



Update: Pants to Poverty have a picture of a dressed-up cow back online today, and I have disabled the overlay module which helps according to guides like http://friendlymachine.net/posts/2011/5-ways-to-improve-performance-in-drupal

Update: Pants to Poverty are now on http://pantstopoverty.org.uk

Oh. That page doesn't mention disabling the Overlay module [done] and replacing Toolbar with Admin Menu as other googlable pages do. Do I loose the toolbar if I disable the Toolbar Menu? Probably. One thing I did notice is that the module list is most easily searched from the top left index to modules called "All". I used this to disable the Jiraffe module, which eats money.

A note for later is that the Boost module works on cheap shared hosting where Memcached doesn't.


https://www.youtube.com/watch?v=aJcJbKaCZJs is a Lynda.com video that shows pictures of the sites that speed-y-up modules come from, but doesn't say much about which work with which.


Tuesday, 23 October 2012

Commerce Kickstart 2 works on my hard disc now

Commerce Kickstart 2 works on my hard disc now,
very slowly, but seems to speed-up a little bit now the cache is turned-on

Installation was very very slow. It takes a lot of pottering-about and avoiding the computer while blue bars work their way from left to right across the screen over an hour or so.

Installation of the full Kickstart 2 with core Drupal installed a slightly older version of Drupal core.

Discoveries or methods: Drupal Core can be unpacked on the desktop
(with anything except windows unzipping utility which can change file names)

Every drupal standard file can be cut-and-pasted in one go over the top of your old Drupal Core installation.
(non standard files are in the "sites" folder which should not be cut and pasted)
(there are probably other complications, but this method worked for me to replace a new old Drupal with a new new Drupal within a version number)

Experiments that didn't work.
Tweaking the auto-installed Aquia Drupal didn't work. I couldn't get rid of all their bits from the control panel, nor cut-and-paste over them in the folder.

Sunday, 22 January 2012

Building an awesome e-commerce site in 25 minutes (without losing your soul)

http://www.youtube.com/watch?v=ViS2xFvnZwc&feature=BFa&list=PLCDB80A0209EC71E1&lf=plpp_video


Hullo. My name is Andrew. I work for a company called Real World Technology. We do a range of different things, but I am here to talk about a wonderful thing in the Drupal ecosystem in my opinion, and that's called Drupal Commerce. So you're probably, or you might have heard other people speaking about it a little bit this weekend. It's come-up. It's been cursed in some talks; it's been praised in some talks. I think it's one of the best things that's come to the e-commerce community as part of Drupal.

We're going to have a chat a little bit about that, and we're going to have a go at making a working, ready, production, e-commerce website, in - pretty much on 25 minutes. So all being well; no computer and technical glitches, that should be all good.

What is Drupal Commerce? [screen]
  • A modular eCommerce framework
  • Designed to let you "build" new stuff
  • It's really cool

So before we actually get-in-to Drupal Commerce, I just want to do a quick show of hands:
how many of you have built an ecommerce site before? OK.
How many of you have enjoyed the experience? I've got two hands! And a half!
Who has used Drupal Commerce before now? OK: we've got a few people around.
How many people have used Ubercart? OK: a few more of you.
Magento? Yes.
OSCommerce? [two or three]
Who has written their own [holds-up his own hand]
Things not written in Drupal that do e-commerce?
Anyone used Shopify or any of those sorts of things? No: OK. One. That's good. OK.

Well,
Drupal Commerce is a little bit different to most other ecommerce distributions that are available on the market. Drupal Commerce is really a framework to allow you to build ecommerce stores and ecommerce platforms. Drupal Commerce in and of itself is a bunch of really really small modules that do a set of small, defined, contained things. And, out of the box if you just go to Drupal.org and grab the Commerce project and install it on your site, you're probably going to be finding that what you've got is something that
  • doesn't do a lot, is
  • pretty confusing, and a
  • little bit hard to get started with.
So,
We're going to talk a little bit about that today, but the thing about Drupal Commerce, that sets it apart from everything else, is that it is a set of components that allows you to build something big. And build something better. My background: I build e-commerce sites. I've been building them since I was about 15.  The first e-commerce site I built was a custom-built site. It lived in asp.net. Or I should say "asp": this was before .net even existed. It sold products for a store. I can't even remember what it did. It had a Microsoft Access database back-end because - you know - when you're 15, Access is cool. Then you grow-up and realise that it really wasn't, but that's OK! That was the first site that I built. Since then I've built sites on Magento; things built on Zend framework, some stuff built on Syphony, ran a very large website built in OSCommerce for around five years. So I've had a bit of an exposure to what's available in ecommerce platforms, and building different things. And together with my company we've built web sites for some very very small people, through to some very very large NGOs and other organisations that wanted to extend their business onto the internet.

The thing that I found, time and time again, is that when I go and I download something like Magento, or I go and I download something like Ubercart,  I discover that, provided that what I want to do works straight out of the box, the solution is absolutely perfect. But the moment that my customer comes to me and says "what I want is X and Y and Z", and I can't quite do it; the modules don't quite get there or I can't change what I want easily.... I end-up hacking something together and making changes and doing things that break my upgrade path. That in the end means that the customer gets a solution that they're not really happy with. It just becomes a bit of a mess.

Now,
I see that Drupal Commerce addresses a number of these issues, by - instead of trying to be something that is all things to all people out of the box - it tries to be building-blocks that give you pieces of the bigger puzzle. So: it's really cool like that.

So,
What does Drupal do? It does most of the things that you'd expect an ecommerce platform to do.

What can it do?
  • Manage products and display them
  • Manage orders
  • Take payments
  • Calculate tax
  • Give discounts
That's what it will do pretty much out of the box.  We can also handle shipping; we can do stock, we can do coupons and vouchers. Some of those things might not sound like very big business goals. But I started using Magento when it was a 0.9 release. It was the coolest php-based shopping cart system available on the market and probably one of the best that was available at the time. It had a nice UI (user interface); a nice customer experience that was only rivalled by some of the really really big ecommerce stores. But then we wanted to give coupons to our customers to allow them to buy on it. They only realeased that module into the community about 12 months ago. That's like three years after the product was there. But Drupal Commerce has it today there right now. So they are really quite good.

What are people using Drupal Commerce for?
  • Everyday online stores (eg ozonekites.com.eu)Today if you are online you can go and jump on there now. It's an Australian-based store. They sell kites. It's pretty cool.
  • Membership websites (eg subhub.com)Dries mentioned in his keyonote [speech] this morning Subhub.com. Subhub is an example which I've come accross which is really unique. They have a Drupal-based-web-site that sells Drupal-based-web-sites to sell stuff! Which is, kind of, a bit of inception, but it's pretty good! So you can go and you can buy a website from Subhub to sell subscriptions to your magazine. Or to allow you to download music from your music-band-thing that you play in or record for or something like that. It's pretty cool.
  • Discount style websites... is another unique thing. Someone has gone and built an entire clone of the Groupon website, in Drupal Commerce, packaged it up as a Drupal Distribution, and you can go, download that, install that on your web server, add a bit of theming and bits and pieces: and you've got your own Groupon site. And you can give your friends and family discounts to - I don't know: whatever it you want to give them discounts to. Or however that wants to work. But it's there. It works today right out of the box.
  • Donations (eg ioby.org)... and there's
  • Many more (see drupalcommerce.org/showcase) There's a long list there. That's only half of what Drupal Commerce is doing out-there in the wild today.
One of the things that I promised was that we were going to build and awesome Drupal Commerce website from scratch in only 25 minutes. So let's get-in and do that. We've only got 13 or 14 minutes left in this session!

Installing Commerce
  • So, we're going to Start with something called the Commerce_Kickstart install profile
    Commerce Kickstart is basically a full Drupal 7.10 (at the moment) distribution, with all of the Commerce bits and pieces ready to go, which you can download. Install on your web server [if it has the capacity which cheap ones don't: you have to install from a database]. Follow the install script. And have a functional working Drupal Commerce website.
  • But it's really designed for being used in the US. So what we're going to do, then, is: we're going to grab the Commerce_Australia module for some country specific configuration - which has some configuration for currency display and GST Time, and it just makes it easy to get them up and running, and install that, and taht's what we're going to do to start with.
  • Let the fun begin
[...] [8' 20 seconds]
I've pre - downloaded an installer module onto my machine, set-up a web host: all of those sort sof things

OK, it's going to run away and it's going to install all the modules. It's going to configure everything as a kind of a base starting point and get us ready to go, and when this is finished in just a few seconds we'll get to the configure site . I'll set some settings like you would if you were normally installing Drupal. And then we install some example stuff. And we wait. This is probably the most boring bit. If anyone feels like donating me a faster macbook pro I'll gladly accept.

The advantage that the Commerce Kickstart module has over downloading Drupal and adding the Commerce module is that there is a bunch of things that you need to get Commerce working. We'll talk a little bit more about some of those things in a minute but there's a lot of dependencies, which are normal things that you'd probably run on your Drupal website, but the Commerce Kickstart distribution has those things in it from day onee. So you don't need to worry about those sorts of things. You can install it in a Drupal site if you've got it up and running and add bits and pieces. We're just doing it this way because we have limited time, because I set  a rediculous time limit!

We're going to call the site... I think we're going to sell some Ferraris. [see screen] Save and continue.
We're going to put some example content in because it makes our life easier. In case you were wondering, we have now been running for three minutes out of our 25 minutes, and we now have installed Drupal Commerce, and we have a working functioning ecommerce store.

So
  • I can add products to my cart
  • I can view my cart
  • I can make the quantity five
  • I can update my cart
  • I can checkout
  • I can fill-in some details and go right through and it will work. We'll look at that a little bit more later.

But
What we're going to do is we're going to do a little bit more than that; there is a little bit more to be done.
So
This is what we're actually going to build. We are going to build the Drupal Downunder 2012 Farrari Store. We are going to sell Micky Mouse cars; we are going to sell Honda Civics and Farraris - maybe. We'll definately sell Farraris: I'm not so sure about the rest of them.
So
A couple of things that Commerce can do. One of the nice things is that it groups products together like this [attributes] so that we can have a yellow Farrari featuring red starbursts; we can have a lime green Farrari. You'll notice that as I do this it updates the displays and it changes the price and the text and you'll see that there's some features on some of these cars: I think the yellow car features starburst paint. They're all updating nicely in the background. As a website developer, and a themer (and bits and pieces) I've done nothing to get that working out of the box. It's just there. It just happens. It just works. No effort involved. Straight working, day one. [so why can't I do it?: because there are no instructions. Will the nice man explain?]

The other thing that we are going to do, if I actually add this car to my cart - we'll just jump across to the checkout. We've got our starburst Farrari here at $59.95 . We've got some shipping in here. There's no [?] doubledation on this. Whatever. We're not going to talk about that today but it can be done. We've got some shipping and we've got two different shipping rules. If you've got a product that you want to sell for less than $100 - or less than $50 in this particualr store - you'll get $15 shipping charged. And when your cart value is over $50 you get free shipping. So the idea is that you might want to give some particular shipping to some people, or if they are some kind of VIP customer or things like that: all sorts of things that we can do. We can go right through [as a customer], confirm, put in some payment details, and then magically checkout is complete. I can view my order, and see what I have bought. I can go into my account and see what I have bought before. I've got a few orders in there including one that's been deleted and one order that's been completed. I can come in here as an admin; view some orders. See what's been - ordered. I can delete an order. I can modify the payment details. These are some of the things that you can do with Drupal Commerce straight out of the box, mostly, without too much work.

Understanding the Workflow
Install Commerce>>Confirgure Currency>>Configure Tax Rates>>Build Product Types>>Add Sample Product(s)>>Build Product Display>>Configure Shipping / Payment methods>> Add more products and displays>> Test and Launch?

So
how to we go about actually getting from a base install to something that is relatively functional; which we can use to delivery an e-commerce product to our customers?

So the first thing that we do is that we
install Commerce. Relatively straightforward.
Then we
configure the currency settings. By default Commerce installs, running in $US. Not that that's really a problem, but you probably want your store, if you're in Australia, to be running in Australian dollars.
  • We set-up some tax rules and tax rates.
  • We build our product types - and I will explain a little bit more about what that is in a moment.
  • We add some sample products.
  • We build product displays.
  • We configure shipping and payment methods.
  • We finish populating our store.
  • We test it to make sure it's working right
  • Then we go live and we make lots of money because everyone makes lots of money when they launch an online store. [laughs]

Understanding Rules
Rules govern the operation of each element of the store - including calculating prices, discounts, checkout steps, add-to-cart rules, confirmation emails, user registration.
The first thing about Drupal Commerce is that it makes use of standard Drupal ways of doing things. So there are some key components of Commerce which live in the background and aren't immediately obvious. They make Commerce work and really really sing when it comes to Commerce being a good ecommerce tool. The first thing is Rules. Rules drive Drupal Commerce. Rules are your business logic that detirmines how your ecommerce store works. So you have Rules to calculate tax. You have rules to detirmine whether you can add a product to your cart. You have Rules that set what shipping method you can choose. You have Rules that detirmine whether or not the user is allowed to check-out. You have a Rule, and there's actually a screen-shot of one here, that detirmines what emails get sent to the customer when they purchase the item, and whether or not you as a store admin get the email. You have Rules which integrate Drupal Commerce with your back-end ERP system. So if you have something like AdEmpire [?] or you're making use of a financial package like, say, Zero or Sassuu or something like that, someone can write modules that interact with those Rules, so that, say, when you place an order it triggers the invoice to be created in Zero, the payment to be recorded, and all of those thing fit together very very nicely. Now: no-one has done that yet, but it is entirely possible within the way that Drupal Commerce works.

Understanding Views
Views display (almost) every part of the store - including order lists, the checkout, shopping cart and product listings.
The next thing to say about Drupal Commerce is that it relies heavily on Views. So Views is a way of representing data within your website. You can have Views that display nodes; you can have Views that display all kinds of different things. One of the neat things about Drupal Commerce is that pretty much whenever it displays a list of stuff, it is using Views. So if you want to change the columns that you see... One of the common things that customers say to me is that "We've got our web site, we've got our admin section; we've got our product listing, and we want to change the order of things". So: take something like Magento. You can print a picking-list out of Magento, which my default shows the product code, product name, price, and that's about all. And if you want to change that, you've got a change a bunch of stuff:
- you've got to change a bunch of XML files
- you've got to change a bunch of PHP files
- change the way that that all comes together. It's a little bit messy and a little bit nasty.
With Drupal Commerce you jump-in, you edit the View; you edit the column, and you're done! It's really nice. Really really easy. You want to display the SKU, so the part code appears in the shopping cart: you just go-ahead and you add the column. That's the way that it works. It's really really nice because it makes use of standard Drupal features, that people who are used to building and assembling Drupal websites use every day and night.

Understanding Products
A product is an item you want to sell, and is an "entitity". A product contains all the important details about an item, and there is generally one for each part code in the catalogue.
The next thing to say is that Products are not Nodes. If you are coming from a Drupal 6 mind-set, where everything is a node, it's really important to understand that products are not nodes. Products are products, and they are displayed using nodes. We'll talk about product displays in a minute. A Product is essentially a group of fields, which is a group of information about a product. So a Product must contain an SKU - which is a part code; a product must contain a name, and a product can (but doesn't have to) contain a price. Most products will contain a price. Although some people want stores where they don't actually want to sell anything - they just want to put products online. So those kinds of things are there. But say you wanted to record the colour of an item. You can add a field to your product type that has a colour in it, much in the way that you can add a field to your content type to record the information. But they're distinct from product types.

Understanding Product Displays
A product display groups one or more products together for display, and is a "node". Product displays usually contain descriptions and formatting rules.
Prouduct Displays groups products together into logical groups. So an example which I have been (kind of) thinking-through is... Say I was an Apple reseller, and I wanted to sell Iphones. There's currently eight or nine different models of Iphones you can get. But want I want to do is have someone come to my online store, and be able to pick-up, or go to the Iphone page and have all of the different options listed there together, so there is one page for them to go and see. I don't really want them to go to a page that has the 34gig Iphone, the 64gig Iphone, and black and white - and there's way more than six models I've just realised - I want them all grouped together in a single node. So that's what a Product Display is: it groups products together in a form for display. And you can add extra information there. You can add descriptions - in fact, any field you want to add to a product display, you can.

Understanding Currency
Multi-currency aware. Products can be priced in more than one currency. Currencies can be selected based on rules.
Currency is the next thing we are going to talk about. Drupal Commerce is actually is multi-currency aware. So if you wanted to sell products in Australian dollars and US dollars and  New Zealand dollars and British Pounds, and Yen, or whatever it is you want to do, Drupal Commerce on day-one out-of-the-box supports multiple currencies. By default it has not way of converting between currencies, so if you put prices in in Australian dollars, it won't go and work out what the price is in US dollars or something like that. But there's no reason why you could not do that, if you wanted to. Most people probably wouldn't want to do that because they want to sell in nice numbers, so they want to sell at $49.95 in Australian dollars and $199.99 dollars in the US or however that works.

Which currency people see can be selected using Rules. There are modules which will tell Rules what country someone is in. Rules will detirmine on the basis of that what currency someone should see when they look at your store.

Understanding Taxes
Taxes are very flexible. Consist of Tax Types and Tax Rates. Fully managable by Rules.
The other thing that we'll quickly touch on is taxes. In Australia taxes are relatively boring. There's just one single tax for everything and that's called GST (Goods and Services Tax). It's about 10% of the product price. Most of you probably deal with that when you deal with everything you buy. In other countries there are other tax rules. But say you wanted to sell houses using Drupal Commerce. In New South Wales where I am from, we have this thing called Stamp Duty. Stamp Duty is 1½% of the sale price. So you could have a tax rate for Stamp Duty within Drupal Commerce, know when to calculate that Stamp Duty using Rules, and correctly apply it to the products, using  Rules, all automatically, without having to do anything. So you can have mulitple tax rates, multiple tax types; you can display prices including, excluding: all those types of things. You can have taxes not on. In fact - a kind of self plug here - the Commerce Australia  module which you can download from Drupal.org, it has a rule in there which says "If you are in Australia, charge GST, and if you're not in Australia, don't charge GST", because if you ship the product outside of Australia then you don't charge GST on it. When I used to run a website in OSCommerce, that was a big pain whenever someone placed an order from New Zealand, because we had to take the GST off and modify it and a bunch of things like that, and it didn't do it well, and then we tried it in Ubercart and it was even worse. So it just works out of the box, day one. Great.
22
So lets actually get-in and do this. We've got 25 minutes from now. Maybe some time for questions. By the way, feel free to stop me at any time and ask questions on what we're doing.
  So
This is the website we've just installed.


The first thing we're going to do is actually not jump into configuration but jump into modules and the first thing I'm going to actually do is I'm going to install the module filter module, simply because it makes my life a lot easier. If you've worked with a site that has lots of modules and you've never found the module filter module : what it does is it changes the display of this page and puts all the modules down on the left hand side, which is really handy. It's kind of quick.
  So
The first thing that we're going to do is we're going to install the GST (Goods and Services Tax) module, and while we're at it we'll probably also install the currency display . They're part of the Commerce Australia module. What they do is the GST module sets-up the GST rules , and Currency Display makes it display Australian Dollars with a $ sign. That's pretty much all that they do. Basic but important.

Now we are going to
>>Configure our Store [from the admin menus].
  So
The first thing that we're going to do is: we're going to set the currency. We're going to jump-in here. We're going to change that to Australian dollars. You'll see the default is US dollars. Because we're in Australia. What that's done is that it has enabled the Australian currency in here. But we no longer want to have US dollars available for our store so we will just turn that off.

OK:
First step done.

The next thing that we'll do is we'll just have a look at the taxes. We don't need to do it because the Tax Rates have already set it up for us. We have a Tax type here: it is called "GST". We have a look at it. It displays taxes of this type already included in the price, it has got some rounding rules, it is called "Goods and Services Tax". And we've got a Tax Rate which is 10%, which is actually the GST because that's what GST is. We can make it 20%, 50%, 150%, -0.1%: all sorts of things. I don't know why you would ever want to do that but you can! I am sure there are countries in the world where that's an important option to be able to have.

OK: so
That's our basic Configuration.

The next thing that we're going to do is: we are going to
>>build our Products.  [product types]

We click on View Products and there's three default products in, because we clicked on Commerce Kickstart install and told it to intstall demonstration products.

Our Farrari store is going to sell cars, so we want to go and configure it to sell cars. So the first thing we are going to do is: we are going to add a product type. We're going to call [in the NAME box] it a car. We are going to make it [typing in the DESCTRIPTION box] "a really good car that we can sell". And we are going to save and add some fields [on the MANAGE FIELDS tab]. So you can see: by default we've got the SKU - that's the part code.  We've got the title. We've got the price which we could delete if we wanted to. We've got a status which is whether or not a product is disabled, or something like that, so you can just disable the product. And what we are going to do now is that we are going to add [ADD NEW FIELD] a field for colour.  It's going to be a list of text type: a select list. We'll save that. This is relatively manual, but we are doing it for real so we will go-through [with it]. An allowed value list. Here is one I prepared earlier (you've got to take some shortcuts!). Now we'll save that . And that's done.

The other thing that we're going to do is that we are going to add some features for our cars which we want to sell. So we're actually going to make it a text field and we are going to allow multiple values once we get through. [presses SAVE FIELD SETTINGS]. Ladada dada.  [NUMBER OF VALUES] Number of values: unlimited. And of course we want a photo of our cars here. There's an existing field which we can use called a product image [near bottom of the screen] which we'll just drag-up and we might actually put that there. We'll put it in after the price because we can. And we'll save it as an image. It doesn't have to be "required". OK. That will do. We can play with the settings a bit later.

OK: We've got a product type.

  So
Lets go and  
>>add some Cars.

So - There's a quick navigation-bar-thing here. I click on add a product. We've got two options. I could click on a standard product. Or we are going to use the product type car. Call it F1. We'll call this our red Farrari. We'll sell that for $49.95 including GST: a bargain Farrari. Get them while you can. Limited stock available. We'll go for our red Fararri [image]. We'll set the colour to be Ruby Red. And this one can have Magnesium Alloy wheels. And we'll save and add another. We'll repeat this. F2: this can be our pink Fararri. We'll sell this one for $59.95. In case you're wondering why we have a pink Fararri: I asked a bunch of people what colour Fararris they wanted and  and Donna Benjamin said she wanted a pink Farrari, so we got that. [select] Penultimate Pink. This is going to be just for Donna. We'll save and add another one. Product SKU: we are up to F3. I think - I don't know what colours I have left. We'll go for colours this way. We'll go for a lime green Fararri. This is because Peter said he wanted a lime green Fararri. We'll call this "Lime Green Farrari". We'll sell this for $199.95 - it's a bit of a preimum model. We'll upload the image because I forget to do that sometimes. It is lushiously good lime green. That is alliterarion for you, in case you didn't notice. This one has no features because it is boring. And the last one, which is actually my favourite: this is my yellow starburst Farrari. Sorry if you are a Fararri lover. We are going to sell this for $499.99. We're going to add my starburst Fararri. And you can see it there: beautifull! It's yellow with red starbursts all-over it. [COLOUR DROP-DOWN MENU] It is a Yamourific Yellow Farrari. [FEATURES MENU IS PLAIN TEXT WITH A + SIGN TO ADD EXTRA FEATURES] Features: Starburst Paint. And while we're here we'll add another feature. A four-wheel drive Fararri. That sounds great!

OK: We've got four products. They're in our store. But hang on a second. They are not showing-up. Does anyone know why they are not showing-up? Yet. Yes: that's right. Those Fararris are not showing up in a product display.

   So
We are now going to
>>add a Product Display
.[Add Pruduct display on the 2nd row of the menu]
We are going to call [TITLE field under Create Product Display] it a Fararri. [BODY field] "Fararris are cool you should buy one". (There's a reason why I don't write copy). And here [PRODUCT]: this is where we set-up our links to our products. So we've got an F1, an F2, an F3, and an F4. So you can put as many fields as you want in there, separated by commas. It's an auto-complete field. It's nice. It just works. You can have one; you can have 10. It doesn't matter. You can have 100 if you want it. I don't know what it performs like if you have 100. Probably still fine. And we'll save that. And we'll save that. Good. OK.

And here's our Fararri. It's red. I can choose "yellow starburst Farrari". I wanted to do this so that I could show you what the yellow starburst Fararri looks like in all of its glory. And I just selected that here: and you can see the features updated; the image updated, the colour updated. I haven't done anything particularly special to make that happen. We've just added the fields to the product type. We added them to the standard product display straight out of the box. And that's what happens and that works. OK? That's cool.

Now: we are going to do a couple of nice little things. We don't actually like the product image being that big. So we are going to format that a little bit. We are going to manage the display. The default display of the product image. Now: this is where it gets a little bit messy.

You modify the display settings for each field on the product-type display settings; not on the product display settings. There are some things you modify on the product display, but these ones you modify on the product type.

So we are make this one - image type - we are going to display a medium image because it fits nicely, and we are going to hit save. Close that, and the page refreshes. And there we go. OK? Alright so far? All good.

So the next thing that we are going to do is:
we are going to come-in here and we are going to modify our shopping cart a little bit. I mentioned that this was all built around Views. So I'm just going to give you a little example of what sort of thing we can do. We are going to edit the view here. And what I want to do is: I want to add the product code into the shopping cart. So that when I come to see the cart I can see what the model number is, at the shopping cart stage. So we are going to add a field. And we are going to add the SKU field. Hang-on: that's not on the list. This is the first little bit of magic which I am going to show you. We are going to cancel out of there. We are going to use the relationships [menu] to add a relationship to the Commerce - to the Product. Er - that's not actually the one I want. I want the car. Hang on. No: maybe that is the one I want.  Add and configure relationships. Apply. OK. So we've got a reference here, theoretically, to the product. So when I come in here and select a product and choose "add", I should now have an option for SKU. There we go. It's in there. Product is linked. That's where the relationship is. Create a label. We'll rearrange that. And we want it to appear first because that's a nice place for it to appear. We'll apply that. We'll save a View. Come back. And there we've got the SKU. Product F3 is in our cart. And if we want to show Features of our product plugged-in there, or anything like that, we just follow exactly the same process. So if you wanted to: if I come back and add a red Fararri to my cart, and I come across to the checkout, and I want to show the colour in here, I could do exactly the same thing: add the colour field in the column using Views and it all happens nicely, all straight away; no particular work to make that happen. OK.
That's pretty much what we need to do.


  So
The next thing we are going to do is we are going to play with  
>>Shippingand shipping is the first time when I'm going to show you a little bit about how Rules works to configure the logic of our online store.

The first thing we're going to do is we're going to jump-in to Modules.
We're going to grab the Commerce Shipping Module,
We're going to turn-on the flat rate module, and the base shipping module.
And the Shipping UI (user interface) because that's how we configure it.
And we're going to save these things: click save configuration....
...whenever you are ready...as I said: if anyone is willing to buy me a faster MacBook Pro, I'm all willing.
So we're going to configure our shipping we click on Configure Store, come-in: click on Shipping, and that's all relateively self-explanatory. [moves to second tab called shipping services]. And what we are going to do is: we are going to configure two shipping services. We are going to configure a shipping service that is [types in title field] Standard Shipping, which we will call "standard shipping" [in the Display Title field]. We'll sell it for $15 including Goods and Services Tax. We'll save that.

We are also going to add a service that is free shipping ; free shipping, $0 including GST, flat rate. 
It could be $0 including GST: it doesn't really matter.

And now when we come in here [to the cart?] all of a sudden we have got our shipping information - and we popped this [delivery address] in last time. And we've got options! We can choose our shipping costs. We can get free shipping or standard shipping. I don't know why I should ever want to choose standard shipping if I've got free shipping as an option, so let's now build some rules which detirmine when those should be displayed, and then we'll test them, make sure that they work, and go from there. So we'll click on shipping. Click on shipping services. And we are going to use this configure component link to modify the rules which detirmine when this gets displayed. So for free shipping, we are going to add a rate for shipping service to an order, but only when we do a data comparison, and we discover when we discover that the commerce order - commerce order total amount - is lower than (hang on: we are doing free shipping aren't we? We'll do it this way) ... is lower than: what do you reckon? $150? OK.

Worth knowing a little trick of the trade: when you do this dollar comparison it is done in cents; not done in dollars. Now, this particular rule isn't multi-currency-aware and that can be done but that's just too complicate dso we won't worry about that. So if the order is less than $150 we don't actually want to give them free shipping; we want to not give them free shipping. There is a reason why we did that. I'll explain in a moment.

We'll come-in and we will make the opposite rule for the standard shipping. Add condition. Data comparison. Commerce Order: Commerce Order Total. Amount. We are going to click Continue. "Is lower than $150": that's what we set it to - right? There we go. It's there. And we'll leave that there.
   Now.
The reason why we set one rule as "less than $150 - NOT" and one rule as "less than $150" is because there is no less-than-or-equal comparison for the data comparison rule. That's the only reason why we did it that way. So if someone buys $150-worth of something: if we set one [rule] to be less than $150, and one to be greater than $150, and you order something worth $150, there's no shipping available to you and that's just a bit of a pain. That's why you do it that way. You could have quite complicated rules. You could have multiple conditions; you can have "or"s, you can have "and"s. All of those sorts of things. You can nest the conditions against each other, and pretty-much anything can be compared, and Rules is way-complicated, and there's brilliant screen-casts online. If you are writing rules, go online: watch the screencasts. And then when you are thoroughly confused, jump on IRC (internet relay chat): that's the way to go.

By the way, while we are here: if you're looking for an IRC client and you're on a MAC and you haven't found one that you like: there's this great thing in the App. Store called Textual. I found it this week. It actually makes IRC usable in my opinion, so I really like it.
   So
We've now got shipping in our store. And lets just prove that that works. We've got free shipping on this order. So let's go back, and let's modify our shopping cart, which presumably I can do by clicking here and press cancel. And coming in here. And it was $150. So lets just cancel one of these. So they're going to charge me shipping on my Fararri: what a rip-off! Seriously. (I could have just changed the quantity but I removed a very expensive item from my cart). Now my order is only - whatever it was - $15: give it a go. Now we've got Goods and Services Tax on there; it's got shipping at $13.64 ex-GST. You can change the order of those fields. We''l talk about that later. Pop-in a payment. Continue to the next step: order done! We are actually done! We've built our online store. It's fully functional. Beginning to end in under 25 minutes.

Just hang on a second. We'll get the microphone.


Q: Can you configure the shipping cost based on the post code?
A: Yes you can make the shipping - built on any rule. So you can do
- instead of a quantity-based comparison -
you can do an
- address-based comparison -
much in the same way that we do an address-based comparison to detirmine the tax rate. So I'll show you what the rule might look like, based on the tax rule. Here's the other place you can get to rules: configuration > workflow > rules. So this is just using the Rules module that's built-in to Drupal. And so in here we have a "calculate taxes GST" rule, and it's a general rule. We have an addition that's an "order address component" comparison. In here we've got "commerce line item", "order address", "country", bla bla bla bla bla.

Keep in mind that you're using the flat-rate shipping module here. Most of the time if you're using postcode-based shipping, your shipping is probably calculated from an external service like Australia Post Shipping Calculator, or you're making use of (in Australia) Star Track Express, or TNT, or any of the other big shipping companies, and they can expose their APIs (application interface) which they can expose. Then someone can write a module, (whether that be yourself, or someone that knows stuff about writing modules - whatever that is) - to integrate those things together. There is an Australia Post module in sandbox on Drupal. I don't know if has been released. I don't know if it works.

Q:I just have two questions for you. A: Yes. Q: One is:
If you currently have an existing site in Drupal 7 and you want to turn it into a Commerce site, how relatively easy...? I mean from what I've looked at it looks pretty relatively easy to just drop the Commerce modules in there and then turn those nodes into products?
A:Yes. That's pretty much all you need to do. (Q - I'm sorry: go-on.) A: And then the thing to keep in mind is that there are dependencies for the commerce modules so you will also be running CTools, Views, Rules, and a bunch of things like that, which most people are probably be running anyway.

Q: And just one other question:
If you've got a site that is currently in Drupal 6 / Ubercart (A: I'm sorry!) (Q: Not as sorry as I am: I've got wo work with it!) What would your recommendations be for getting into Commerce? Just literally starting fro scratch again?
A: Yes. I'm talking about this with one of my clients at the moment who has a quite heavilly-hacked version of Ubercart running their website. It's running a slightly older version of Ubercart that hasn't had security patches applied to it for a little while which makes me a little bit nervous. So we are talking about the fact that we need to get to Drupal Commerce with them at some stage over the next year, and we are going to re-build it from the ground up.
Q: [inaudible: about transferring data from Ubercart to Commerce].
I imagine it would be a relatively trivial module to export from Ubercart to Drupal 7 Commerce end-of-the-world. No one has written it yet. I have spent a lot of time looking at the tables in Ubercart and they're not all that sophisticated, so it could be done, but it's not something that... - it's probably not something for the feint hearted.
We are going to re-input all the products; we are going to re-input all the data, re-create the users. And, you know, that is a problem with choosing to run your business logic out of a web-based ecommerce platform: what is the upgrade path?

The guys that wrote Drupal Commerce were also the guys that wrote Ubercart, and in one of the rist presentations they gave publicly on Drupal Commerce, the very first thing that they said was: "Sorry". Ubercart is great provided it does what you want. If it doesn't do what you want then it's a little bit messy. The migration path is not very nice. Same with Drupal Commerce though. There are a lot of things it doesn't do. I started using Drupal Commerce when the first RC (request for comment) or Beta was released about 12 months ago. We half buit a site and got stuck because we discovered that a bunch of things weren't working and we stopped. And a lot of people have started working with Drupal Commerce just a little too early. I think in the lst three months is when it's really got to a point when it's mature enough that most of the things that you want are mostly there and mostly working. But it is a work in progress and the community is quite happy to help, so: get online and contribute.

Q:So where is all the link to the payment stuff? Does it link to Paypal and where do you configure that?
A: I haven't turned-on any payment methods in this example store, except for the example payment method which is turned on by default. There is a Paypal payment method. There is an Authorize.net payment method. There is Securepay for Australia. There's a bunch of different payment gateways which developers have written and made available on Drupal.org. If you want a payment gateway that isn't there it's relatively trivial to write one to put in there - or find a developer. There's a few good Drupal developers in Australia that work with Drupal Commerce that are happy to write payment gateways if someone pays them, because they have to put food on their table.

I think that's about it.

https://web.archive.org/web/20130413095747/http://www.youtube.com/watch?v=MS2P7PYaZ6A&gl=US&hl=en
http://drupaltv.org/video/building-awesome-e-commerce-store-25-minutes
is another lecture from Real World Technology on how to set-up Commerce Kickstart very quickly. The catch with both lectures is how to install kickstart on a server before the clock starts ticking, or else how to convert a standart drupal installation from something like scritpulicious into a drupal commerce installation. If there's a quick way of doing that - I'd like to know if anyone wants to comment.


Thursday, 29 December 2011

http://vimeo.com/33628943 Practical Drupal Commerce, with Ryan Szrama at Drupal Camp Austin, Texas, 2011

Transcription of a free-to-watch video on Vimeo. Translaters see footnote. Best seen on another screen but this is the ebedded version
https://vimeo.com/33628943

HI - I guess we'll go ahead & get started. You are in the
Practical Drupal Commerce Session. I am Ryan Schama of Commerce Guys. I live in Louseville Kentucky but I - I've been to two Drupal Camp rosters. I went to the first one two years ago. I don't know why we didn't make it out last year, but I was pretty bummed, and so I pushed hard for us to come this year.

And what I'm going to be doing today is not talking about Drupal Commerce so much as showing what it would actually look like to set up a site using Drupal Commerce. And I have a couple of demo sites that I'll also use to show you examples. I'm going to treat it like I've just been given a project by a client to build a Dallas Cowboys fan site. Just selling some Dallas Cowboys Merch[andise] . And if you want to introduce some Scope Creep as I am building this site feel free to raise a hand, and we'll take in a different direction. So feel free to introduce some scope creep on me this one time only!
1' [one minute]


So just a little bit of background about myself. I have been with Commerce Guys since 2009. We were just three guys and now we are up to about 36 based in the US & Paris. Part of that growth came out of a merger with the french company AF83 that put-on Drupalcom Paris if you were there. Their Drupal guys came-in to Commerce Guys and we started afresh in Paris. Which is why I am a cheese fan and have brought some cheese with me.
Whenever commerce first started I was the project lead for Ubercart for Drupal 5 and Drupal 6 and we were getting close to thinking about Drupal 7 Ubercart, and that's about when Commerce Guys started, and I quickly because Drupal Commerce. So I am no longer the project lead and maintainer of Ubercart; instead I am the lead developer for Drupal Commerce. Which is a complete re-write of Ubercart, with a functionally equivalent feature-set on Drupal 7, taking advantage of Drupal 7's Core Entities and Fields and Rules2 and Views 3, and so-on, and so-forth, and everything good that has come accross the Drupal world in the last couple of years 
My last Ubercart presentation was here in Drupal Camp Austin in 2009. Vimeo.com/9322909
I said"here is what you can do with Ubercart" because we had an application mind-set in which what really mattered was the out of the box experience.
What you could do once you had installed the actual modules themselves.
What kind of store would you have?
How few steps would have have before you started selling your stuff online using Ubercart?

I guess that what that sort of mind-set got us was a lot of application dead ends for developers to really customise what they could do with their ecommerce web site. And so you had challenges with multi-lingual sites; multi-currency web sites. We had challenges with sites where you didn't have traditional product models : where you didn't need a product page for example; where you just wanted a sort of product floating somewhere like an event registration or a membership or something else that's not a traditional product-page-type-of-thing. You were really tied to Ubercart's understanding of your business model or understanding of your product presentation or checkout workflow. You couldn't customise the checkout. You couldn't rip the checkout and the cart in the checkout apart. But if you installed everything at once and needed a store to run as Ubercart ran it was great! It still is. If you need to build a site right now, using Ubercart on Drupal 6, you can probably get going quite quickly. A lot of the contrib[uted module]s are there that you would need. It's still very application focused. If you think about Drupal: how many other modules do you use on a consistant basis, where all you really care about is how the module works once you install it?
4'
There are some smaller-feature modules were that is true, but you don't just install Views, and expect not to have to tinker with Views. You install Views because you want a system that you can customise how you are displaying your content on different parts of the web site. Or your RSS feeds or your export feeds or whatever. Or if you think about Content Construction Kit (CCK) at the time. You didn't just install CCK out of the box. The major contributed systems in Drupal were more about giving you a tool set or a framework for building a different kind of thing, whether it was your content type or your display page or perhaps your organic group system or whatever else.

Drupal 7 has really privelaged us to think again about how we can build an ecommerce framework (we call it) that focusses less on what you can do with it out of the box and more on what you can build with it. We took queues [ideas] from Views and CCK. At the same time Rules and Organic Groups [modules] also did this. We were focussing more on the components that you need to drive your ecommerce web site, and how they are loosely-coupled but can be adapted and mixed-and-matched to create the ecommerce experience that you need for your website.

What I like to say is that Drupal Commerce will give you a store out of the box if you just install all of the modules. But it is going to make hardly any hard-coded assumptions about your business logic; about your business model, about whatever it is that you are selling, about how you need to display it. Hardly any hard-coded assumptions. There are less tools for you as a developer to work against; more tools for you to work with.

We have let people from the git clone [?] use Drupal Commerce for a wide variety of sites. The very first one that was really big and publicised was Eurocentres.com, which if you want to check it out is ...res.com instead of ers.com because it is a European site.
6'
What they did was they were selling language learnig courses all over the world with a multi-lingual, multi-currency site, with highly custom add-to-cart-forms and custom checkout processes. It was just a very custom web site that was built because of Drupal Commerce. They could not have done this it on Drupal 6. They really needed the new data models and the flexibility of fieldable entities and the changes in rules to  make their stuff happen.

And quickly after that, like way on the other side of the map was a donation-based web site where it was donation campaigns. It was kind of a Kickstarter.com for green initiatives in different boroughs in New York City called IOBY.org. And next thing was they're creating a totally custom add-to-cart process, where you're able to specify a donation amount for the project, map it to a campaign, and then they had their Views you know, taking all the payments for this one campaign, and sort of filling-up their "progress meters" and all this stuff. Because all they knew they needed was a way to track a monetary amount linked to a line item which references in itself some campaign. And then they could do all the visualisation and reporting that they needed to do. And because of the flexibility of Drupal Commerce's pricing system they were easily able to sort-of change the price of whatever donation product was in the shopping cart to match whatever the customer said. And I can actually demonstrate that although how that fits-in to selling Cowboy shirts I'm not sure!

[screen: let's build a cowboys fan site that .....
  • sells autographed merchandise
  • sells official team jerseys
  • lets you customize a jersey
  • charges flat rate shipping
  • offers bulk shipping discounts
  • collects 6.25% Texas sales tax]

But I said I didn't want to talk too much [7-8"] about Drupal Commerce sort of high-level without just digging into a site. But we're going to do that now and this is sort of the template that we're going to follow here.
7'22"-7'44" repeats screen
I really do want this session to be practical & hands-on, so if you do have any questions just raise your hand and I will call on to you.
7'55"
And I'm also going to show this off. So this is my Do It With Drupal site that's a clone of Apple's online store. So I use this to preface, I guess, how we are going to sort of build stuff. I'll give you a visual sort of how-we-are-going-to-build-stuff that we can look at while we are waiting for our Drupal site to install.

Alright: so. Lets flip-over to the browser, because the first thing we are going to do is install Drupal Commerce. So I just got handed this project; I just got tasked with it. I need to build a store quickly, and one of the fastest ways that you can get up and running with Drupal Commerce is with Commerce Kickstart. It's an installation program that I maintain. That will install Drupal Commerce with all of its dependencies. That includes Views, Rules, Addressfield, C[haos]tools and ... [screen shows a progress bar and lists of modules installing]
So it will install all its dependencies and a couple of modules and configue to make sure that your shopping cart block is showing, to make sure that your permissions have been granted properly and everything else. And it will also give me an opportunity to set-up some sort of example store content.

So while that progress bar is going, this is the Pinapple store that I built for
9'
Dua Drupal. And as you can see it looks strikingly similar to store.apple.com And the lions' share of the work in this web site was actually (- oh it's not adaptive apparently. It wasn't disigned for a xxxx display -)
So the lion's share of work in this site was theming. So I spent about 40 hours building this website. Maybe five of those was throwing the Drupal site and Commerce and Views together. The other 35 hours would have been making it look like apple.com.  And learning some tricks along the way. So if you're curious about those tricks feel free to find me afterwards but I'm not a great theme writer. I did put my "themer" sticker on [for the conference seminars] but I'm very much amateur. This is my first theme ever. So I'm guessing that some of you could do this much faster than I did.

So I'm interested in that we're going to sell just regular merchandise. So we have just a regular product page. We do have some of those on this website. And you can go to the piPhone, and then click-over to select our piPhone,
10'
- not responsive. Looks great on 1074 x 758px. And Apple has these sort of splash pages that then redirect to their actual product pages. And this would be - once it loads - just a basic product page to select some attribute of the piPhone, whether it is your colour, or your hard disc size. As you select the colour you will see the image update. This is just core Commerce functionality using the new Ajax framework in Drupal 7. The price will also update on the screens - that's way down here in the corner! But if I upgrade my hard drive to 64GB the price is going to shoot-up and I am going to add that to my card. So we'll demonstrate how I built this using the different sizes of the jerseys that we're going to be selling.

And I also said that we can do customisable products. With Drupal Commerce it's quite easy to take an add to cart form and expose additional fields that must be filled out. [screen shows buttons and titles overlapping on big scale] Wow that looks awsome! In the add to cart form.
11
So what we have here: I'm interested in that Drupal Commerce does not force a particular type of product display on you. So we had in the one instance the iPhone where we had all the different options and you select them and it's one add to cart form . For the iPods I actually had a separate product page for each model which is what Apple does for some reason, and now this is just a View of my actual product display nodes. So I have a separate node for each of my ipod models, and this is just a view that's displayed as a grid, with some custom theming on the links and what-not.

So you pick your model and then once you go there you actually have to customise your ipod. So this is where you do things like specify your custom name of custom number or whatever.

So this is done by attaching fields to the line item that's actually going to be added to my shopping cart whenever this product is added to my cart.  So I'll demonstrate how I set that up. And then I won't bother going to checkout because I'm sure it looks horrible and it costs $600 and because Commerce Kickstart has done installing.

So has anybody here not used an installation profile before?
12
A few haven't. It's kind of like getting more and more privelidged inside of Drupal to the point where you can include not just module installation but additional steps. So you can install and configure themes during the installation process, and I guess there are probably some other things you can do with them but those are the main things you can do with them. And then Drupal.org itself will let you include a .make file with your installation profile so it can actually bundle everything into one tarball for you including Drupal Core. So this is the way that people will begin making distributions of Drupal. Is by taking an installation profile, all the modules and custom theme and basically creating a custom experience for a particular business model or type of product. Package it up into one discreet tarball that somobody that is really new to Drupal - doesn't know how to click through everything and set it up - they can go and grab and start selling immediately.

And so one of the best examples that I've seen so far for Drupal Commerce is
13
Open Deals App. It's just Opendealsapp.com. And they've actually taken Groupon and cloned it into Drupal using Drupal Commerce with their kind of straight-on rip-off Groupon theme, and you just download their app and you have a Drupal Groupon kind of site that you can start to customise and quickly deploy for your clients. This is actually a fairly common feature request in our queue at least - I don't know how many of you guys get those requests. Honestly if I got a request like that; if somebody asked them to build a Groupon clone I'd just say go use Groupon, but maybe you have a newspaper or a local organisation wants you to build something like this so you can use Opendealsapp as your launch point.

And the idea here is you're trying to give or we're just trying to give site builders and new users just a very basic starting point to customise the Groupon site so you don't have to do the same stuff over and over again for every Drupal site you're building.

Now the same holds true for Commerce: we have Commerce Kickstart which is designed to get you up and running with just the core Commerce modules as quick as possible
14
Right now we don't even have a custom theme. I'm just using Bartek. I am using the Admin menu with the Admin Menu toolbar  that it comes with, so it makes it look like the core toolbar but it's not really. I should probably disable that for the purposes of this demonstration. I'm just going to go back to the core - you know I'm scrared to go back to this because I'd have to go back to this sort of five times...

Alright so we have our Kickstart site. The project was first we were going to start off selling autographed merchandise.

So as you can see Commerce Kickstart did start off creating three basic products for me, numbered one two three with nodes displaying them. What you see here is actually a node  that's set-up by commerce Kickstart. It's a node type called Product Display. This node type has a product reference field on it.  So the actual product data if I were going to edit this node, you're not going to find a product price or SKU field or anything. What you have instead is this product reference field, where by putting in the SKU, this field associates product three with this particular node.  If you're familiar with the way that fields work either in [Drupal] six or in [Drupal] seven, you have a widget where you specify how does this field's data get entered, then you have a display formatter that detirmines how that data, once it's attached to this node, is going to be displayed in different view modes. So: how will that product reference field be displayed in a teasier versus a full node. And one of the display formatters that comes with Commerce is an add-to-cart-form display formatter. So the way this add to cart form shows up here in this node is that this node is associated with product three: the display formatter says
"hey! make me an add to cart form for product three". And it throws it in here.

So what I can do is on, I guess, the product list side , if we go to Store Menu; I have a view of products, I have products one two and three, so lets get started and edit product three and lets make this into just 
16'
an autographed football.  So I think I have a football autographed by Troy Akeman. [types TROY-AKEMAN into the SKU field of the edit view for product three] I can type quicker with two hands. [puts microphone on stand] holds it here.... Right: so we have a Troy Akeman football [types into teh Title field] I have an image here. By the way these image fields have been set-up for us by Drupal Commerce - you don't have to use that but most people when they're trying to test-out an ecommerce application they want to find that so we put them in there. And the image field is actually attached to my product.
16'39"
You can either attach the images to the product itself or the node that's displaying the product. It's really kind of up to you and the products that you're selling. In this case it probably wouldn't matter. I could have just thrown this image field on the node itself because I'm only going to have one image, or at least one set of images for the football. There aren't multiple different footballs that I'm selling. But imagine if I had different colours
17'
and different styles of football. The brown, or the blue and white, or the Dallas Cowboys celebratory whatever football, you know maybe I would have an option to choose what colour football I want , and so I would want to have a different image appear based on that. So like I showed you with the pinApple store, as I chose a black versus a white piPad or piPhone, I mean it was actually changing the image on the page, because it was pulling that data straight from the product that's actually selected on the form.
17'27" [long pause for question] Yes agreed. Yes it's very impractical huh. Yes: no no.
17'53" Just so everbody heard.

The feedback here was that the architecture makes sense. Like we know that we need like a discreet set of product data [18] that exists somewhere, that isn't tied to any particular disciplin. Like you might have multiple ways of displaying the product; multiple languages, and you might want to keep each language display associated with one discreet set of product data.

But for just the casual store owner. When they come and see this thing, like [they ask] "Wait: why am I going to  adminsiter my product data in one place and then manage how its connected to stuff in another place?"

And it is frankly, that we expected and anticipated that this would be the main negative feedback for Drupal Commerce, for [version] 1.0 and it's going to lead into infinity, so you've got to say, look, we can get the archetecture right and then lets throw usability modules on top of it that sort of give us a more expected workflow.

And so what you have is there's a module called the Product Display Manager that lets you manage your display nodes from the back end.

And then what I'm working on is called the Inline Product Form Module that can...
Instead of having two separate places [to edit product display and product data],
you would just edit the node and on your node form you'd have the product added to that as well. I think that's what people are expecting and I think it's what you'd expect.
19
And so the goal was to get [version] 1.0 out-the-door, and see these other modules, sort of get developed that can address these usability concerns.

Some people have also taken to gluing these things together using Rules. And so they've made a Rule Set that whenever you create a new product node it would create a new product in the back end. And associate that with this product reference field that they hid from their users. I'm not a huge fan of that approach because it is tying quite a bit of your logic into Rules, that doesn't really need to be [tied-in]. So my hopes are really set on the Inline Product Form Module. I think that's probably the major-use case for just setting-up a store. Any other feedback?
19'43"
Any other feedback or questions about architecture or whatever?
The question was "Is there a sandbox for that?"...[not transcribed as temporary. By the way "updation" is a good word, newly invented below]
20'
If you go to my user page, I'm https://drupal.org/user/49344. You can get the links to my sandbox from there, and I'll get it promoted as soon as it's ready. Right now - I don't want to get off the rabit trail too much. But I have a lot of fun trying to figure out how to handle the creation, updation, and deletion of entities inside of another entitie's form, without committing all those changes before the main entity's form is submitted. So my module handles that but it doesn't actually have a product display node.  So it's just ready for it, but I haven't had time to get it done. But the other stuff are done . The product display manager is available. The Rule sets are available niches [specialised options].  And then there's also a module that I was going to get to in a minute but now I've mentioned the others
20'44"
There's the bulk product creation module. That lists multiple options of products all at once. The module is [called] "commerce_bpc". So that's throw-up like all six different sizes and colour combinations instead of one product at a time.  And you know it will get to that.
21'
So we do have our one product here - the Troy Aitken Football that's good to go. We can sell that. I've just added it to my shopping cart. I can go to checkout now and I can purchase this football. Let's talk about the jerseys. Because the jerseys are going to have multiple sizes. I'm going to have my small medium large and extra large jersey. And so the way I want to accomodate that is by first of all creating a new product type, because I am going to have to add an attribute field to it. I think that if you've done ecommerce before you're familiar with product attributes?  These are the kinds of things that are basically user select-able options. So whenever they go to add to the cart , you have these groups of the different sizes or the different colours or wattages or whatever it is, you know, that you're selling (between apparrel or equipment or whatever) they can choose on the add to cart form the attribute that matches what they want.

Let me go to my product types here. It's kind of hidden here. Sorry about that. But I'm going to go to my product types tab and add a product type.
22'
The default one: well the default one that you have here [is called] product. It may be the only sort of product that you need. If you are only selling one sort of product on the site you can just go ahead and add whatever user fields you need to that;  use it, and if you don't want it at all you can just delete it and create your own product types. It's really just there for new users to use, or for you to use if you only need to use one generic product type.

In our case we're going to add a jersey product type though. And I'm going to  [presses a button marked save and add fields next to save product type and cancel under description and explanation or submission guidelines] save and add fields. And on the jersey I'm going to add a size [clicks on add new field button and fills in field marked label] size [fills-in field marked field_] size. [selects a drop down marked type of data to store an selects list]. This is going to be a list text because, you know, I am going to have a discrete  number of options available for this. [moves to the last drop down on the line called select list] And this field - I'm just going to leave it as select list.

[moves the line of data up the screen a little by clicking and draggint an x-shaped anchor]
[scrolls to an allowed values list which is the heading over a large blank box above some text saying "the possible values this field can contain"]
Right, now for my allowed values I'm just going to do my
S/Small
M/Medium
L/Large
XL/Extra Large There we go
23'
[presses save] We also have as fields attached to products we have our own custom set of setting here. So these are: this whole set of fields here is called Attribute Field Settings. And whenever I'm adding a field to a product type I can choose to have that field function on add to cart buttons as an attribute. You don't have to expose it if you don't want it to be [exposed]. But in our case I do want this size field to be available on add to cart forms as a selectable option.  And then I can choose whether I want it to be a select list or radio buttons. I'll go ahead and leave it as select list but for theming purposes you may want it to show up as radio buttons. And one example I threw-up onto this site before the session is that there is a cosmetics site that is selling lipstick. They want, for each of their options, a colour-splash to show up. Instead of the name of the colour they want people to a actually click on the colour that they want to purchase. And so they would use radio buttons. And then theme the radio buttons to use their colour swatch. And then like hide the actual radio button itself. And it all functions great.
24'
And the way they did that was that instead of using like a list text field, they used a taxonomy term reference field, and they put in their different colour options as taxonomy terms, and because terms are now entities in Drupal 7, they can add an image field to them. So they would put in the name of the colour, they would attach the image to that term, then use that as their attribute on the add to cart form,  and then just swap-in the actual colour swatch for the name of the taxonomy term. It worked great! It was great to see that happen. Nobody has made a generic module out of that yet, but in a situation where you need to do that, just know that there are one or two issues [like this] in the cue that are go through the whole process of show example code, and hopefully we'll get that boiled down into an actual helpful module or a tutorial or something.
24'47"
Here we go. I've just exposed - or:  I've just added a field to my custom product type that will be exposed to the add to cart form . Let's just create a jersey. Let's go ahead and start off with our
[SKU filed of] TONY_ROMO_S. And we'll do small. And as I mentioned, normally we wouldn't have to set here and type every single one of your different options.
[Title field of]Tony Roo Jersey, Small. I didn't have one of the most recent version of the bulk product creation module available, so I'm just going to go ahead and type a couple of them: I won't do them all.
[SIZE field: Small S]
And these things go for like rediculousness or something - like $80 or $70? And it's Tony Romo. So it's like: $65. I know, honestly I don't have much room to speak because I'm a Colts [sports team] fan.  I don't have any room to speak because I'm a Colts fan. [this is the sort of thing you say to fit-in in Texas].  They're leading right now? Oh they're playing the Redskins [team].  OK, I was totally a guess but they're playing the Redskins. I reckoned they would be leading  OK. So I'm just going to do two so I don't take a whole lot of time filling in all these different options. But I now have two different
26'
Jerseys available. I'm going to go to the front end now and create a new product display. I'm going to go through content [on the bar at the to of the admin screen] to node content [drops down]. You'll see that I have my new node type here. So lets add a new one. This will be our Tony Romo jersey. And I'm going to put the size and the title. And instead what you can see is if you enter the SKU it does the auto-complete so I'm going to choose my small. And medium in Tony Romo Jerseys. And when I click save and view the node, I should now have a select list. Oh and I forgot to upload the images. Oh well. We have a few things going-on here. One thing we're going to have to change. But first of all you can see that my attribute field is showing up here for me to select something that I can  add to the cart. And the way that this works is that the add to cart form looks at all the products that are set to display here, and it says "Hey! These are all the same type. So these should have all the same fields on them. So instead of showing a select list -
27'
instead of having just one select list that said sort of Tony Romo Jersey Small; Tony Romo Jersey Medium, it know that both of these products have a size field on them, and so it can extract from that the name of the field, and the options available, and lets you actually chose them from a select list. And it can do this for any number of attribute fields. So if you were doing this for size and colour and they were dependant, so you only had small medium and large available in red but you had small medium large and extra large available in blue, it would only show valid product combinations. It uses Drupal 7's sort of Ajax stuff to sort of select the appropriate one as you change options on the form. And then behind the scenes it knows exactly which product ID it is referencing,. So when I change this to medium there's a hidden product field or whatever. So I think the product availability was 3. It changes it to 4. And if those products had different prices, then it would re-render that [price] field. So actually I reckon it's good that [inaudible] because we can see that this [size] has been re-rendered, so it says medium instead of small. I call it product field injection. So evey time you have a product reference field, and its displaying in an add to cart form, whenever that add to cart form changes, you can tell Drupal Commerce to update any visible modules from that product on the node, so this node, whenever its content array was being rendered or whatever. I'll see if we can go to development and show you. Maybe not. I haven't looked before. Maybe. Maybe not. Maybe it's not worth looking. Right: it's not worth looking right now. But any time a node or a user or a taxonomy term or any kind of entity that has a product reference field on it is rendered, the product reference field module will also say "Hey! Do any fields from the product itself also need to rendered into this output?" And that lets you show on the page any field from the product
28'
or any attribute of it like the title of the product or the SKU. And so all that stuff is governed by the fields when you attach them to your product and by the display node. So it's honestly this is still like that this is a confusing thing because you have like two different field interfaces [UIs]. You have the field_ui for the node type and the field_ui for the product type. And knowing where to go to change a particular type of display or a particular action can be confusing. So I won't belabour it too much other than to hop-in real quick and disable the size field because you [programmer] don't really need it because I [shop customer] know which size it is because I'm selecting that in the add to cart form.

And so if I go to my content types [from admin menu, drops down from "content"] Oh, lets try the next one that's "structure> content types> product display" I'm going to go-manage my display. You can see in here all the fields that are coming from the product. So the product image, the product price,  product is the actual product reference field that shows-up as the add to cart form.
30'
And if you get-on from there you can see the product size field. I don't want it visible so I'm just going to mark it hidden. You know if I wanted to I could show the SKU, I could show the title. Those things are hidden by default. And then I need to do that for my other view node as well. So for Teaser we'll go in here and hide size.
30'30"
Yes: the question was actually how is the reference handled for prouduct data from like a node or a user or whatever? And it's actually a custom product reference field. It pre-dates both the relatation and the reference and everything else.  Maybe for [version] 2.X we're looking at depending on entity reference or something similar, but right now it's just a product reference field. The scheme has just one database column. That's product id. And then from that product ID we create the add to cart form or a list of skus or titles or whatever else. Um Yes. So there we go. Yes. Follow-up question over here: red shirt.
31'
So the question was: What exactly is happening with the image field?
And you see I actually forgot to attach an image field to my custom product type here. So lets go ahead and do that just so I can demonstrate. Will the image be spoft[?] in as well? And the answer is Yes. As long as the image is attached to your product type then any field, again, that is coming from the product , if it is visible on the page will be re-rendered whenever that default button on the add to cart form is changed.

So if I go to image and add - I'll just make sure I have an image field - and then if I go edit my jersey products. I'll just use two different jerseys: one that's blue and one that's white for obviisity. There. We have Jaon Mitten. And we do have a Tony Romo I think. Yes there we go. Alright. So if I come back to the product display that has the two different products referenced on it, we'll see the small. The jersey looks really big. And if we change to medium, the jersey looks even bigger. So it's re-rendered as well.
33'
So again this is just a demonstration of what elements Drupal Commerce lets you bring to the table to let you build your product displays. If you get Drupal Commerce out of the box; if you just grab Commerrce from Drupalcommerce.org/projects/commerce. It isn't going to set-up product node types, it isn't going to set-up product types for you. This stuff is happening because we are using Commerce Kickstart. And the idea once again is that we did not want to make any assumptions about what kind of products you are selling. But we do get a lot of tools to build very dynamic add to cart forms. In Ubercart you had to use two or three different modules to get images showing-up, or to produce option images. You couldn't really render fields from your product data into the node. You just couldn't do this. And now we can because of fields and because of entities and because of, specially, the new ajax framework baked-in to the forms api.

Lets move-on to a cusomisable jersey. We're going to go to a Store>add a product. Oh - you know: just for the sake of time I'm going to re-use my basic product type, and just show this.
admin/commerce/products
34'
So not only can we add fields to our product types in our add to cart form. We can add line item types and have those show up on the add to cart form. So let me come over here to Store>configuration>line items.  And you''ll see that I have one product line item type. And the way that the cart works and the way that the orders work in Drupal Commerce is that when you ad something to the cart, a product line item is created for it , and attached to an order. So as soon as somebody clicks add-to-cart they have a full order object. There is (like) no pseudo-cart order object thing. It is like a full order with revisions that keeps track of additions, deletions; it saves what ever data you try to add on the checkout form as soon as possible, so you're not loosing a lot of that valuable marketing data that we weren't tracking before.
34'50"
And so a line item is anything on the order that feeds into the price. It could be your products, or, once I install the shipping module, it could be a shipping line item. For certain kinds of discounts it could be a discount line item. Also for those fields - you can add fields to them and expose them to the add to cart form. So that before somebody submits add to cart they actually specify additional data to store with that product line item in the order.

I don't want to use my one basic product type and add fields to that, because then every time I add products to my web site they going to have the customisation options. It doesn't make sense to ask for somebody's last name to customise a football - their autographed football. So I want to use a different product line item type from my customisable stuff versus my basic products. I have a module that's sort of in the works. I need to finish it up (I'll install some other stuff as we go). I have a module called customisable products - if I can find it! - oh there's the inline product form module - that will let me create additional product line item types for use with different types of customisation. And other areas you might need this would be things like a donation form where you want someone to specify a custom donation amount. And use that amount they specify as the sort of unit price of that line item in the shopping cart. If you go to commerceguys.com there's a great tutorial by Randy Fey that demonstrates that right now. You might also use it for event registrations where the product is a different level of event registration, and then the different fields they have to fill-in our their name, attendee name if they're registering other people, email address, company name, or whatever else. You know - "name on the badge" versus "name on the form".

And so there are many different use cases for creating custom product line item types. We originally developed it for one of our clients that was selling customisable T shirts and lighters and whatever else. They needed to store these design tags with their line item but they had other products that didn't need that stuff. And so we needed multiple types of line items that would function as products in the cart.
37'
And you see now I have installed my shipping module so you see I have my shipping line item type. I've also installed customisable products , so I have this new "add a customisable product" link that I can use to add a customisable product line item type. Well we'll just go ahead and use custom jersey because it's available. Save that line item type. And now I have two types of product line item. So that means that when somebody clicks add-to-cart , we can use either one of these things. The customer jersey line item type or just the basic product line item type. Lets go ahead and edit this one because I am going to go and add my text field. This is for custom jerseys to capture the [add a text field] custom name. And we'll make this just a basic text field. And save. Alright So: we've got the next link [button marked "save product fields"] and so just like with the product fields we had that additional field set where you had your add to cart form settings  with fields attached to line items.
38'
You're also going to have add-to-cart form settings. And this one is just a single check box that says "include this field on Add to Cart forms for buy items of this type." So I am going to go ahead and save this and then go and view our products. Lets go back to our Troy Aikman Football. And if you look at this add-to-cart form you will notice that there is no - you know - no name field visible.  We can add this to the cart. It doesn't ask me for my name even though I made that a required field. And the reason being: this add to cart form is using the basic product line item type. It does not have any additional fields associated with it.

Let's go an refocus on Product Two. Product two is - let's see - our custom jerseys. Let's go ahead and add a product. Make this a jersey. And this is our custom jersey. Let's write that (SKU) down again. And this is a small jersey. And this is very expensive. Click image. Choose a file. Choose "custom".  Right. Now I've got a product now that I want to use my custom jerseys. Now what I want to do is figure out how I want to get this product associated with the different product line item type. Usually what you do is add another separate type of product display. One product display is for my regular product line items. The other one is going to be for my custom product line items. The reason for that is the setting that lets you specify which product line item you want to use is tied to this add to cart form. And this add to cart form is coming from a display formatter. So you have to have a separate node type to have a different set of display format settings. I know this is kind of confusing. Lets go ahead and add this. A new content type called a custom product display node. We're going to add fields to it. In this case just a single product reference field.
40'
Oh and here's the checkbox here underneath "required field" which directs you to "include some reference products". Again there are so many things that we are injecting into the field forms that I know that all of this is going to fly right over your head until you use it, but at least you are aware that this is how Commerce works. It is working through the existing field system.  And then you pull all these Commerce pieces together. But if I go to look at my display, I have my product field here. Let's go ahead and hide its label. And it is displayed as an add to cart form. You scroll over here to the right. This is new for Drupal 7 so if you haven't yet used Drupal 7 you don't know about this, but you can have settings for any sort of display formatter now. And in this case the settings for the add to cart form are: should it have a quantity of Widget? Let people say they want 1, 2, 3 of these at once? What should the default quantity be? Should like items be added to the same product that's added to the same cart? Should it show up as a separate line item or should it just increment the quantity of the existing line item? And then the very last one is the add to cart line item type. That's set to Product because that's just the default. Lets go ahead and edit this. Change it from using Product to Custom Jersey. So when I hit update. I go create products of this node type. You'll see the add to cart form with the little name text field. Lets go add one. Add content. Custom product display.

Its making me nervous having that thing next to the computer - my last mac was trashed by electronics falling on the laptop.

I'm not going to go through the full setup here because it's taking a lot more time than I anticipated. But you see now that the add to cart form has a custom text field that I didn't have to specify. And this data, because it's just field data. It's not like we're attaching it to an array and then serialising this data and adding it to the product in the cart. That's what Ubercart does with its attributes. Instead this is field data that can be attached to the line item of the product in the cart. You can get to this data using Views; you can get ot this data using Rules. Whatever you need. So if I was usingthis system for event registration, I could build a massive list of all the people registered for my event by just producing a View of this particular Field. And in this case this field maybe shows the order number that that came from,  and whatever else you need to do with it. And according to Randy's tutorial on donations (you know: custom donation products), because this is field data: Rules has access to it. And with Drupal Commerce you can add product pricing rules, that will take the price and alter the price of the product before its added to the cart based on whatever parameters you need. So that could be: you just look at the field like the custom price that somebody specifies as their donation amount would be the price of that product added to the cart.

The question at the back.
43'23"
The question was pertaining to custom pricing and discounting and what-not.
What Drupal Commerce does is that it runs every custom-pricing rule through a single event that it calls "calculating the sell-price of a product".  And so this is all done through Rules right now. There are reasons for it that I can explain afterwards. But you have under your Configuration Menu a product-pricing-rules-item, and that lets you set-up your discounts, sales-tax, fees, price lists, currency conversion: whatever, all using Rules. In this case, lets go ahead and just make this a "half off day: half off everything". Save. [curser hovers over "add an action" link] And what I am going to do is add an action  to this, called "multiply the unit price of a line item".  Because whenever you calculate the sale price of a product, it's done through a pseudo-line item. So when Commerce is about to display a product price, what it asks is "what would the price of this product be, if it were in your shopping cart, right now".  So it creates a line item that doesn't save that would reference your order and reference the product, and it passes it through Rules so that anything can operate on that to change the price, add tax, whether it's VAT or sales tax or whatever, and then spit that final price out as your purchase price for the product.

So we're going to thumb-through the line items. I am selecting a "line item action". That's going to multiply the unit action called "multiply the unit price by some amount". In my case I'm going to multiply it by 0.5. And I am going to say that this should show-up on the checkout form as a discount. And I'll choose how that should be rounded, if at all. And now if I go back and look at my product page. I had some footballs in my cart. They automatically got updated to be ½-off, so that's $30 instead of $60 (they'd be cheaper if americans didn't bother with leather, silly arses) and notice that whatever is going to be in your shopping cart is always going to show the most recent price. That's called the "shopping cart refresh". So somebody won't have stale data in their cart if they come back a month later and prices have changed: it's always going to be updated. If you go to checkout: you can actually see that this will show-up on my checkout form as my half-off discount. So all that stuff is tied together and done through Rules.

The same is true for taxes so if I go back to store>configeration>taxes , lets add a Texas sales tax. I think it's 6.25% is that right? 8.25% - oh it's changed. Move to Kentucky it's cheaper [the UK's NHS service runs for only 10% of GDP so although taxes are higher it's cheap too].  And now that I have that tax on there, of course, go-up, and it's an error! This always happens, doesn't it, on tech-demos. OK. It sill still show-up here. I'm going to have to debug that later. I haven't fully tested everything against the latest version of entity api apparently, but you can see that I have my sales tax, which if I am not mistaken is going to come-up at a discounted price but I can't do the Math that quick. So here we have my Texas sales tax. Total $34.95. And all this stuff is coming from a price field attached to the order and it just shows the breakdown. We have what we call "price components" so every price, whether it is a price on a line item or a unit price, or a product sell price, or or the order in total price or the order itself. All these prices have in themselves a change-log of how that price got to where it was. What pieces went-in to making this-price this-price. That includes the base price of the products,  discount that came off it, the sales tax that was added, and you can use that to build custom price displays to run your reports on how much tax was collected or whatever else.

Question up front?
The qustion was: Can we have a tax by product? [47.08]
Yes. You just use Rules to change the conditions for the applicatbility of that tax.
So if I went to my store menu again (and I have kind of run-out of time or I would have cruised-through a lot of this stuff) if I go to my taxes menu [bottom item] you can see my tax rates. You can see there is this ambiguous operations link here [right hand side] which is called "configured component" and in Rules-speak what that is is a kind [?] subtlety that detirmines whether this tax should apply to something. So if I go in there, you'll see the full Rules user interface where you can add conditions that detirmine whether this particular tax should be applied to the line item. So I can make this detirmined by some atrribute of the product itself: maybe food items aren't taxed and jerseys are. I can make that detirmined by the shipping or billing address of the customer. Most places it's detirmined by where you're shipping it to.  So I would want to go and check the shipping address and make sure that it was Texas before applying the Texas sales tax. So that, again, is all done through Rules. And this all comes through the product pricing system. So product pricing rules is your main point for adding discounts, and taxes, swapping-in prices and custom prices, and price-lists, and everything else.

I can't remember the other objective I set myself for showing this site. I was going to show discount shipping. I don't have time to go through this and build it. So just real quickly I can show you on realmilkcheese.com. Actually this is my first ever personal e-commerce web site. And it actually is responsive so lets see if it works for us right here. The pressure's on [typing and  waiting]. Realmilkcheese.com is just a very rushed-out website selling an Amish farmer's cheese. So it's selling raw milk goods, it's kind of yummy, but it's kind of expensive. So what we're trying to do is simplify bulk purchasing. If customers buy $100 of more of his cheese they can get free shipping. What I did was I used the shipping module and the flat rate module . This is Shipping [module version]  2.X. If you are about to use a commerce site use the 2.X branch not the 1.X.  And then another module called Flat Rate. Also confusingly, this is not the Shipping Flat Rate Module; just the Flat Rate Module. I'll have that all cleaned-up on the shipping project page soon. So what we did was use the Shipping Module and the Flat Rate Module  to  - oh! security updates! Great! I've just gone and shown everybody that I have an insecure website!  I have my Flat Rate Shipping Method and if you look at the services that I have defined for Flat Rate, I have a "Standard" and a "Free" shipping method. So my "Standard" is 16 bucks or something; free is going to be $Zero. Free is only going to be available for orders that total over $100. So that's easy enough to do.

Just like with Taxes you have a Configure Component link; you have it here for shipping as well. So I just go in here and add a simple Condition. That evaluates, or compares against the order total: "Is it greater than $99.99?" (These comparisons are done in the minor unit of the currency so comparisons are done in pennies or cents or whatever else, so just remember that when you are setting-up your pricing rules).  In this case the order is over $99.99. The free shipping should show-up. If it's under $99.99, then standard shipping should show-up. The problem that I ran into was "What if someone selects Standard Shipping and that bumps-up the total to over $100? - then suddenly free shipping becomes available". What we had to do was we added some conditions into the shipping module itself that lets you also specify: "Is the order total over $100 in itself, and the order doesn't have shipping applied to it?". So if you're setting-up rules for shipping, just remember that you have to have that exlusion, because someone could go forward and checkout, save their order, and then come-back and choose the free option and go for it. You don't want that to happen. So you have got to use both things: the data comparison,  and also the check that they don't already have shipping applied to their order.

That's how we set-up free shipping. With the Flat Rate module it's very simple to add just as many flat rates as you need. Then with the Shipping Rates again once the base rate has been calculated, coming from that flat rate, you also run that through Rules again, to manipulate the rate further. So if you do weight-based shipping where it's $5 + $3/pound [of weight]. You do the same thing by setting-up a flat rate for $5, and then you use rules to add a conditional $ to it per pound or $3 per pound. There's a lot of stuff you can do using Rules and using the Fields about those Rules that we have set-up [pointing at a part of an admin screen under config>workflow>rules>components - worth looking at at full screen mode]  headed "Conditions" and then boxes for "ELEMENTS", "OPERATIONS", repeated under another heading of "Actions".

And we are out of time here and I regret running out of time and I regret that we haven't really cracked the demo. If you have any questions, I'll stand out in the hallway and feel free to come and bug me with them
you're welcome to bug me with them about Drupal Commerce. Thanks for paying attention and for bearing with me, and I'll see you guys next time.


[answers another question - Oh yes? What's that? Sure, Sure]

Two things.
  1. There's real milk cheese here if you want it, right up here. Actually I have half a brick of smoked pepper and applejack so if you want some of that come and ask me.
  2. We're doing a full three million dollar training down in Florida next month .... go to ctraining.commerce on Drupal for that. There are also (paid for) videos on Lynda.com and (paid for) videos on Drupalise.me so there are all sorts of resources out there to teach you how to use Drupal Commerce.  [+ https://www.ostraining.com/blog/drupal/ for non-commerce text instructions]
 Alright. Thanks a lot.

Transcription: translators see this footnote
Some of the jargon is italicised, more or less at random.
Speaking style is Germanic English with maximum hyphenated-together-words.
Sentences are unstructured and meaning depends on context a lot.
Some apologetic linking words like so and and are added to the starts of sentences. I have taken a few of them off again in transcription. Translaters will have trouble.


Transcribed videos about Drupal 7 and Ubercart 3 which are meant to provide a quick way of writing an ecommerce site: - [Drupal 7 / Ubercart video tutorial 7 of 10 showed how to use the default catalog module] [Drupal 7 / Ubercart video tutorial 8 of 10 showed an alternative flexible method of showing a catalog] [Drupal 7 / Ubercart video tutorial 9 of 10 shows how to use product kits, stock, and order states] [Drupal 7 / Ubercart video tutorial 10 of 10 shows a simple checkout, reports, and suggests a theme]