Saturday 26 October 2013

Drupal 7 /Ubercart video tutorial 8 of 10: Over-riding the Catalog and Creating Product Attributes


So if we go to

We are going to call this [name] "Product Type", because we are going to sell different product types on our site - we are going to sell T shirts , CDs, whatnot.[4.08"]

Now we've done that let's go ahead and add some terms. So. Name: "T shirt". We could add some meta-tags and relations [?} if we want to , but we don't really need to do that [at this stage]. We have added T-shirts.  [Name] "CDs". [save]. I guess people don't really want to sell CDs any more but we are going to go historic here. And now, I guess, books. People still sell books. And three should be enough, so that's fine. [4'48"]

Now we have taxonomy terms but we don't have them associated with our content . So if we went to...

> structure > content types > Product > Edit | Manage fields | Manage display tab | Comment fields | Comment Display


...you'll see that we don't have any fields, so we will have to add that [association].  We are going to add a new field here.


> structure > content types > Product > Edit | Manage fields tab | Manage display | Comment fields | Comment Display
Add new field

label
We are going to call this "Product Type". And [5'11"] you actually can't see what I'm doing here. But I am going to make this a term reference - that should be on your [drop down menu] list.
And let me make this a select list because I only want to be able to choose one. [5'20"]
(If you want to make this a free tagging [site], where, you know, you have thousands of different tags; you never know what you are going to have, you can make this
 
a free tagging field so that you can always type-in a new one, and it will automatically create the new term. I am sure that I am only going to be selling three different product types, so that's all that I want.)
So it is actually going to use a product type vocabulary . [scrolling down the page looking at options]

required field

It's going to be a required field.

Default value
The default value for this field, used when creating new content.
It's not going to have any default [value]. We are only going to allow one value. And it [the value] is going to be out of the product types. So I am going to go ahead and save that. Obviously you could change that if you wanted. And I'll leave that. That's fine. [05'58"]

Product Type field settings
These settings apply to the Product Type field everywhere it is used.
Number of Values

Maximum number of values


*The vocabulary which supplies the options for this field.

Now we have our actual contents. [from the admin>content menu]. When we go over to add a product ( we are going to do this afterwoulds, actually, but I just want to show you) .
?missed a bit?


Now: if we go over to Views, the Views module comes with a taxonomy over-ride.
What this will do is: -
  • The system actually has urls for taxonomies.
    They are always: taxonomy / term / termID 
  • So when we create these taxonomy terms using the url pathauto module...

    If you remember we set-up the data:
    we had url aliases and patterns set-up for taxonomy terms.
    >configuration > search and metadata > url aliases > patterns















Enter the path you wish to create the alias for, followed by the name of the new alias.

Existing system path


http://uc:8082/
Specify the existing path you wish to alias.
For example: node/28, forum/1, taxonomy/term/1.


http://uc:8082/

Specify an alternative path by which this data can be accessed.
For example, type "about" when writing an about page.
Use a relative path and don't add a trailing slash or the URL alias won't work.

So it will be the taxonomy vocabulary plus the term [that is] what we will see [in the url]. [6'40"]


What will happen here
>structure>views>taxonomy term>path  ...is

Views [module] will over-ride [urls set-up as above] using .../taxonomy term /....
and then it will take an argument [technical term from maths?], and that will be based on the default menu , so we can over-ride what our actual View will be or what our page will look like for the specific taxonomy term .

(I know that this is probably going over way your head [and I have just enabled the redirect module? Yes? No?]  I know that his is probably going way over your head and it is way beyond what this module originally envisaged, but I just want to do this because it is a great way to customize what you are doing, so: just trust me and bear with me!)

So now we have a taxonomy term over-ride. [7'16"] Let's go ahead and we will edit this.

>structure>views>view>taxonomy term>edit [on a drop-down menu at the end of a line]

We are going to take a quick look into Views.
What Views actually is, as I think I mentioned before in another video tutorial; Views is a graphic interface for creating database queries. Rather than write your constant query - like "select from  where", you can do it all through Views [module] and it will actually develop a query for you, run it,  and you can create pagers [third line from the bottom] out of that.


#overlay=admin/structure/views/view/taxonomy_term/edit
Taxonomy term (Content)
Modify the display(s) of your view below or add new displays.
Displays      Page Feed Add

Display name: Page
Title:        None
Format:       Unformatted list | Settings
Show:         Content          | Teaser
Fields:       The selected style or row format does not utilize fields.

Page settings
Path:
         /taxonomy/term/%

Menu:
         No menu

Access:
       None

Header         Add

Footer         Add

Pager
         Use pager: Full | Paged, 10 items

More link:     No


The default taxonomy over-ride, when you launch [a site] is an unformatted list of teasers. [short first parts of paragraphs encouraging a click to further reading of blog posts]. [7'42"]

Show:   Content          | Teaser
Fields: The selected style or row format does not utilize fields.
I don't want to do that; I am going to change that. So the taxonomy over-ride will use...
[clicks on Show: Content to get some options on a pop-up menu][7'46"]I want fields.

Page: How should each row in this view be styled: All displays (except overridden)
[no longer selected]


You may also adjust the settings for the currently selected row style.


I am going to apply to all displays for this taxonomy term. [pop-up closes]
And now I am using Fields [there is an Add link next to Fields: , which leads to a pop-up menu of about 20 names of fields next to tick boxes = check boxes]
Format: Unformatted list | Settings
Show:   Fields           | Teaser
Fields: Add
The selected style or row format does not utilize fields
So I am going to go ahead and I am going to add two fields. [a drop-down Filter finds them on a long list]

Add fields
[search box ]
[drop-down menu to filter results eg content or product]


Content: Title - the content title
Product: List Price - the manufacturer's suggested price
Product: SKU - the part number or bar code





This is just quickly [choosing options out of about 20] - obviously you can change it a little bit yourself.
First I want my
Content: Title - the content title
Then I want my
Product: List Price
And the
Product: SKU- so I lied: I am going to add three fields.[8'19"]

[another menu pops-up automatically labelled Configure field: Content: Title]
Right: So we will keep the title..


And I am actually going to make this a table, so we will keep all these labels that we have. [on a follow-up screen] So that actually makes sense for someone who is going to read the page. Instead of making this an unordered list we are going to make it a table.
[clicks on Format: Unformatted list |. A menu pops-up]
Page: How should this view be styled
For [dropdown menu: all pag
es]
 
Unformatted list [no longer selected]
If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.
You may also adjust the settings for the currently selected style
You have some other options here [on the "Page: how should this view be styled" pop-up box] if you want to chase those up [experiment]. So that is my View.

One thing I am going to do is that I am going to make sure that it's only products that are going to be shown on this. This is a bit of a caveat.  Bear with me for one second here, and I am going to explain this to you.

 >structure >views >view >filter criteria >add [on a drop-down menu at the end of a line]

Add filter criterea
[search box ]
[drop-down menu to filter results eg content or product]


Content: Type - the content type
(for example a "blog entry", "forum post", story", etc)







Content: Type - the content type (for example a "blog entry", "forum post", "story", etc)
[after pressing the "apply" button, a second menu pops- up][8'58"]
Configure filter critereon: Content: Type
For [dropdown: all displays]

Operator

Is one of Is not one of

Content types
Select All
Article Basic Page Product Product Kit

More

I am going to add content type.
OperatorIs one of
I am going to make sure that this is an acutal product.
Content types
Select All
Article Basic Page Product
I go-ahead and hit "display".

High Five!
We are not actually going to see a preview because we are going to need to generate some arguments . [9'18]

If you are only using one taxonomy on your site, so you are only using products and you are only using  taxonomy terms related to those products, this solution is fine. [9'39"]

If
  • you are using blog posts, and
    you are using taxonomy terms to categorise the blog posts, and
  • you are using articles and
    you are using taxonomy terms to categorise your articles,
you are going to run into a problem here. Because
this overrides all taxonomy term views
, and so all the different vocabularies and terms;

  • your other content is not necessarilly going to have these prices and SKUs, and
  • you might want to have a teaser for that specific article or blog post.
If that is the case, then you are going to have to look-into another module called the
View Field Module
. What that will actually allow you to do is create
different taxonomy overrides for different vocabularies
. I actually haven't used it, so I am sorry: I cannot go into the details about it.  But there is a great post here ... that details what you have to do in order to override this [thing]
https://drupal.org/node/424168#comment-5082962  [...]This will tell you how to go ahead and do that [other thing] . The project itself is available at https://drupal.org/project/viewfield
So this is the module. I'd advise you to go ahead and get the Drupal 7 version, so you can test that out. So that is a brief side-note. For the sake of this video tutorial that [problem and solution] is not going to be an issue because we are only going creating products on our site.[10'47"], so we can override all taxonomy term fields.

That's why we had a content type filter there.

Let me go-ahead and I am going to save this [screen of settings using a save button top right]. [10.58"]
Now we have our over-rides set-up. So that's great.


Attributes
>store >product >attributes
[11'10"]

Before we actually go ahead and create some products with tags, to look at this different view, I am going to go-on to the next part of this video tutorial and we are going to go about configuring attributes.

So to do that we are going to go to
>store >product >attributes
Attributes
home>administration>store>products
Name Label Required List position Number of options Display type Operations








color color Yes 0 4 Select box edit options delete
In the previous video tutorials in this series, we went-ahead and we created [the attribute] color. You will see that we have got grey, black, and red. And so, for the sake of users who, maybe, missed that video tutorial, I am going to create a new one. I am going to call this a "yellow" colour here. And you will see here that the default list position. This will come-up when we add our products. Don't worry about that. You can change it if you want to. [11.46"]

Default Adjustments: 

Default Adjustments
Enter a postitive or negative value for each adjustment applied for each product selected.
Any of these may be overriden at the next product level
Cost
Price
Weight
This is an interesting and helpful field. What it allows us to do is: you'll see that if you do sizing, you may want to have a 
  • default cost, and you sell an XXL, there is more material so it can then charge an extra $2 for a XXL shirt. So it will add $2 to this; every time you have a product that has an attribute of XXL, it will add $2 automatically on to that cost. And you can associate the same thing with the 
  • sale price, so that it adds $2 on. Alternatively, if you are doing something associated with a specific
  • weight: if there is a specific weight for this attribute, you can go ahead and add that in here. These are all defaults.You can also do this [adjustment] individually on
  • specific product; you can do that as well. So that is a great thing about attributes here.

So we will go ahead an we will submit this. That makes four attributes for our products.


Now let's go ahead and add some new content.[12'31"]
>content >add content >product

Just as a reminder: if you already have content then you will now be going back to it, as new taxonomy terms that we create for our product [??].

>content >add content >product So: creating a new product. Back here. So we are going to call this - I dunno


Product Name*
Summery
Description (edit summery)

[13'00"]
It's something on a CD, Right?
So now what are we going to do now? I guess we are not going to need an image, but we will add an image anyway. We don't have an image, so as always in this video tutorial I am going to upload one of our dog Baily.

Image:
Add a new file


Now, I am going to say [in the Product Type box with drop-down options: select option, books, CDs or T shirts] this is a CD.
Product Type*
So the SKU [in the SKU box] is going to be "pete's CD", right?
SKU*

product SKU / model

The sell price is a whapping...

List Price $ Cost Price $ Sell Price*$
the listed MSRP    Your store's cost  Customer purchase price

...because everyone wants to hear me sing.  And the maximum package quantity
Maximum Package Quantitiy*
Default setting. So we are going to leave everything as default , because we are just doing this to take a look at Views[module]. We are just waiting to for the image to upload: it's almost done.
There. Now, with the magic of editing, that took no time, so we are just going to [press] save and Continue.
[13'43"]

Where do we go? [to the shippable box] This is a shippable product. [clicks] It is not shippable product any more [lie], so we press save and continue.

adding an existing attribute to an existing product
>content >add content >product (using attributes configured on >store >product >attributes)

Now: the reason why we went-ahead and pressed save and continue is because I want to remain on the products page so we can go to our attributes. So: we have to add an attribute to this product. We are going to add our colour attribute. Now, once we do that...
We can go to our options, and you will see here that we can choose the options which are associated with this particular product. So every colour is going to be available for the cover of my CD, except for red. Now...
We are going to go ahead and save that.

If I wanted to adjust my cost for my price and my weight, for this specific product, rather than using a default, [in the cost boxes next to each option] I can go-ahead and do that. The default [radio button] will select which option will be selected by default when a user selects this [CD] item. It will be defaulted to black. So I will go-ahead and I will submit that. And I will save that.

If we go and look at [the] adjustments [page], we can see here that we can use alternateive SKUs. [by filling-in the  boxes]: Pete's CD black; Pete's CD grey, and Pete's CD yellow. Again we are going to go-ahead and submit. [15'07"]. And then if we go back to the product [page], we are still good: we have our product CD, we have our regular default SKU, we have our sale price. So we will go-ahead and we will save that.[15'17"]

Right. There's our list of products. So if we click on "CDs", here, it is going to show us all our product types... here is our actual View. We see title, we see list price, we see SKU. So that is defaulted, rather than the catalogue [default setting]  that we had before. You will see that we have a product type of CDs.

If we go to
>configuration >search and metadata>url aliases>
you will see that we have one [url alias] for each. Taxonomy terms 7, 6, and 5: these are the taxonomy terms that we created. Bulk CDs and T shirts. And we are good to go. [15'55"]

Screen revolves.[16'02"]

replacing the catalog

OK. So now we are actually set-up I am going to go ahead and show you how to replace the catalogue.

You will notice that we are on a different screen, because I actually screwed-up the video tutorial, so I paused it, and I am going to show you what I am doing. I have erased that part of the video tutorial, so we are starting here.

Right now what we have done is that we have over-ridden the taxonomy term pages so that we have a specific look for our product types and a we have gone and done that  with attributes. What we don't have is a list of all the different product types , that we can go into, kind-of like a kind of product catalogue , and then go-down by specific fields. And so we are going to do that. [16'31"]

Let's go-ahead. We'll go to [admin>structure.] Views. And we have to add a new View. [View Name box] "ubercart product". It's going to be actual Content [in the show box]; it is going to be of type product [in the type box], [in the sorted by box] newest first. In the Page title box: catalogue. This is going to be at [in the path box] "product type".

Let's just confirm this. [on admin>configuration>search and metadata>search settings>] because what we want this to be is the beginning of our actual [alias: product-type:books].... yup!

So what we actually did was [to make sure that] if we went to [path] product types, it would work as a url, and if we went to [path] /books, it would also work as a url. That's just good development practice.

  • We are going to create this as a table. With fields [these are the default settings] times-ed by ten. We are going to use a pager. [there is a ticked box called "use a pager" - maybe for page breaks?] And we are going to go ahead and edit it. So, now, what we want this to do is kind of create all of our products on the page, and allow users to filter them. [17'41]

So, what we are going to do is to create a similar View  to what we did on the other View.
Then when we go-over to get that View you will notice that I have changed a few things, but nothing overly crazy. [using an Add fields pop-up, working down the options]

We are going to add the add to cart form - so I can show you what that looks like.

We are going to add the display price.

We are going to add the image [ticking a box marked Content image (uc_product_image: delta) Delta: appears in - node product, node product_kit ]

I think that's it. Obviously you would want your two Views to match-up, so it look consistent between the two. It's not a huge concern, but it's just a good way of doing this.

[create a label box is ticked, followed by a "label" box]
We are going to call this [label] "image" [filling-in the box][18'32]
Ah. The Delta. We are not going to use this.
So we will use the add to cart. Wait for that to display.
Price: we will go-ahead and edit that.
Then we'll go back to add that image. Hold that window. [18'52"] [ticks a box]
We want this image. Not the Delta one. We chose the Delta before. We want the Content Image.
So it is image, then we are going to select thumbnail; link this image to content [from a dropdown box labelled "link this image to" with content as an option]
We'll add to display [clicks an accept button at the bottom of the page]

Now the cool thing about this; the thing that gives it a twist, is that, right now, this will show all of our products. So if we went-over to this, let's save it [presses a save button] and go and take a look at it.  [The screen reverts to a browser default page until the path the the site is re-typed] [19'26"]
Right: here are all of our products; we can add all of them to the cart.



But if you have, let's say, a thousand different products displayed in a haphazard way. So, what we can actually do, is a pretty cool thing with Views,  is to add an exposed filter for users to specifically choose: if they only want to see your T shirts, only show them your T shirts. [19'53"]

We are going to go-ahead and go-into content, [on the "add filter criteria" pop-up menu] and we are going to choose taxonomy terms. We are going to apply that. And now: it is going to be[from vocabulary options of "product type" or "tags"] a product type, and it is going to be a [selection type either dropdown or autocomplete] dropdown. So [press button] apply and continue. [20'04"]

[next screen is called "configure filter criterion. Content: has taxonomy term]
You are going to expose this to the users. So now they have control of this.[20'07"]
[in the "label" box types] "only show the following products" [20'13"]
[looking at an "operator" selection - "is one of", "is all of", "is none of".... ] "is one of" [20'16"]
[looking at a "select terms from the vocabulary Product Type" form including "allow multiple selections"] We are going to allow multiple. [20'16"]
["remember last selection" is a tick box] You can remember the last selection, so you show them T shirts if they have always had T shirts before. It is entirely up to you.
[presses "apply" button] press apply and it is all displayed.[20'26"]
[presses "save" button top right] Now we are going to go ahead and save this. [20'31]
[presses F5 in windows] We are going to go-ahead and re-load this page. [20'33"]
Now they can go ahead and say "I only want to see CDs"
[selects "CDs" from the new drop-down menu and presses an "apply" button.] And there you go. We only have one CD. [20'39"]
And go-in to this, [shows picture of dog Bailey],
And they want to see the other CDs.[shows summery of CD as for a list]
And you will see now [in the path] that we have "product/CDs"[20'46"]
So this is our other View that we created. And from this they can use the add to cart form, right-away, and if they decided that they wanted to see all your product types, if they removed "CDs", and then they are back to all of your products. This is why I like using Views and doing it [the catalogue] myself: just because you have complete control over this. [21'02"]

One thing I should mention again, is that if you are using multiple taxonomy terms for products , you are going to have two different exposed filters here, and you want to create another View for, you know, product types, or lets say just the licences. So: just the licences.  And then you would want to remove your and you kind of get into trying a template for that in PHP. That is a little bit beyond the scope of this video, but you can actually choose which exposed filter is shown. You know, if you are interested in that, I'm happy to do a tutorial on it, supplimentary to this video tutorial series: I just need to know that you are interested in it.[21'32"]



That's pretty-much it! [21'33"]

Just to re-cap on what we did in this video tutorial, we  just went-ahead and
-unistalled the catalogue module. When we did that we
-removed the taxonomy terms for those associated products
so if you had gone ahead and created a bunch of different products and taxonomy terms associated with the catalogue, you would have run into an issue, but, that said, we unsinstalled the module , removed all the data, went ahead and
-created a new taxonomy.
Specifically: we created the product type vocabulary.
We added some new terms to that.
-Then we created the taxonomy over-ride view.
So what this did is that it gave is something like "CDs" - right? Where we actually had control over how it was shown to users. We then
-added some attributes to different products, in a sidebar to the actual views, which enabled us to select grey, black, or yellow. You will see how these appear here when you are listing them.  Then what we did was [that] we over-rode we created a new view to replace our old catalogue, which showed all of our product types, and we
-added an exposed filter so that users have complete control over that [view].  They see what they want. If they want to see books, they can see books; if they want to see T shirts, they can see T shirts.

That's the end of this video tutorial. I hope it helped-out. We are nearing the end [of the series]. I think that in Video Tutorial 9, what we are going to cover is product kits and stock,  and then I think we are pretty-much good to go. The last video [number 10] will just be about testing: making sure that your site works properly. What you need to check; what you need to know. And then your site is ready to launch. So we are all but there. If you don't want to know about stock or product kits,  you can go ahead and launch your site now, and you have pretty much got all out of this video tutorial series that you need to know.

I hope this has helped you. I am getting some great comments. I apologize that the video tutorials in this series aren't coming faster, but it's time-consuming. So, leave a message [on you-tube]; let me know if this has helped-out.

[Drupal 7 / Ubercart video tutorial 6 of 10 showing how to set UPS, Paypal, and conditional taxes]
[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]

Transcriber's note:

Does anyone know any other transcriptions of this series? If you have any links to other Drupal Ubercart or Drupal Commerce videos for shopkeepers I'd like to have a look, but I won't be offended if anyone else does the same work better and helps me write my shopping cart and sell shoes. I might make more than one cent a day by selling another pair of shoes each year. In fact I hope someone copies this whole bit of text, puts it on Ubercart.org, fills in the gaps, links each tutorial to a forum, adds screenshots or reconstructions as I've done - that kind of thing. I'm only doing this because the slowest kid has to write the neatest notes, and I'm only doing it on my own blog because paper notes are harder to keep and online forums tend to get moderated by party loyalists.

If you come to Ubercart from a shopkeeping angle, rather than an IT developer angle, it's less intuitive and needs a transcript of text to make more sense. If anybody has done a plain text transcript, more connection between screen shots and text or reconstructions and text as I have done here are better still; just a plain text transcipt is really good to know about and helps people around the world who are using using machine translation as well.

I'm slow setting-up my next shoe shop software and any help is welcome.

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.



.