Monday 12 August 2013

Home > Administration > Site settings Advanced settings > Structure > Menus Main menu


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.


Monday 10 June 2013

Why is this difficult / expectations for minimum basic shipping

Transcribing a video about Drupal Commerce shipping options, I thought I might be on to something.
A couple of days later I tried to follow the instructions myself and soon discovered that the video describes a simple case, but that other modules exist on the Drupal.org site and here:


The trouble is that the ones for a shipping matrix by weight and destination or perhaps courier are not finished.
One has a dozen or so users.
One has sixty but writes that the project was halted; there is no user interface, bugs are acknowledged but it is for another maintainer to sort them.
Those of us who are not in the states obviously need this module more than shopping cart authors need to get them written. To me, a shopping cart is not past alpha release unless it can ship to the home country, part of the world, and the rest of the world on three different weight scales alongside a few more for different kinds of delivery. This is what I already have on my simple entry-level shopping cart from mals-e commerce which allows 5 types of delivery that can be subdivided according to price or a value that you add to each order form link for weight. Paypal's free shopping cart links probably offers something similar. If you pay a small subscription to mal's you get more options, but most settle for this entry level.

Obviously, to open source software developers in the states, it is OK to release something and watch people write additional modules that they explain as being un-finished because a project fell-though and they are short of time.

So: back to watching this video about how to sell things for $0 shipping in Colorado and $10 shipping in the rest of the world, which happens to be the USA. Until I can find an open source shopping cart system that started in Europe.

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.



.

Monday 27 May 2013

Space Hog

http://www.freelock.com/blog/john-locke/2011-10/top-6-reasons-drupal-really-sucks-developer-edition

...teaches me that I'm not alone in finding Drupal a space hog for space cadets who do not pay for their own server space. Apparently this is a bad side to its good side - enough hooks for a knitting machine, each of which can open some memory-based function or other. I also read about its history. Recently a collection of modules which were sometimes supported or sometimes released as a favour to other savvy coders, then transforming into a platform for using Rules and Views modules. I was going to add a picture of a space hog, but that's a distraction and anyway it was mocked-up: the pig did not suffer. Do not send pigs into space.

Space Hog
By the way, why to americans say "sucks" for "bad"? Is this a macho thing? There's a strange convention that you search for X+sucks to find what's wrong with something.

On the same page I discover that a system called Code Igniter with a flexicart add-on is designed for cheapskate shopkeepers who play on their computers. Maybe in a week or two I will find another web page called "why code igniter is bad" (or kicks ass for bums or whatever americans say). Meanwhile there is a Bitnami windows stack of programs to run it so here goes: it should have downloaded by now.

http://bitnami.com/download/files/stacks/wampstack/5.4.15-0/bitnami-wampstack-5.4.15-0-windows-installer.exe?with_popup_signin=1

Oh: an hour later I am still making sense of Bitnami instructions. Apparently Code Igniter is not pre-installed in the same way as Wordpress or Drupal. There is some requirement to understand how these stacks of programs work in order to start it and see what it is, in order to understand how it works. Learning about software by trial and error is slow, sometimes.




Friday 17 May 2013

Why is this difficult / videos v. forums v. blogs

A paid video about wordpress ecommerce mentions "so many people banging their heads against the wall in the forums" on some tricky point.

Free videos, made more quickly, do not even mention forums.

Forum posts cannot easily describe free videos either; they cannot write "the part about X at 6'32" doesn't make sense to me" because not many people would reply unless there is a transcript, and for some reason the videos such as Commerce Guy's videos on Vimeo do not have transcripts. This is a pity for
  • non-english speakers, who have trouble translating the less clear parts, and for
  • english speakers like me who have trouble asking for help in a forum and saying where stuck.
I have tried posting in Drupal Commerce forums and got no response. If I transcribe a video there, it looks a bit weird and out of place and probably gets deleted; if I post it here on a blog and link, it looks like an attempt at self publicity and gets ignored (or deleted). So the two ways of learning about Drupal Commerce do not interact; makers of videos do not know where their explanations are tricky, and writers on forums cannot help each other by referring to the right parts of videos.




 






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.