Step by step guide to installing Commerce from scratch

The following guide was used in a presentation at DrupalCamp Montreal 2014. The presentation focused on how to install Drupal Commerce from scratch (i.e. without the Commerce Kickstart distribution). This is an elevator guide. So get in now because we're going up!

FIRST FLOOR

  1. https://www.drupal.org/project/commerce
  2. Install & enable required modules
    • drush dl ctools views entity rules addressfield commerce
    • drush en ctools views entity rules addressfield commerce -y
  3. Installation instructions
    • https://www.drupal.org/node/1007434
    • use the provided drush commands
    • drush en commerce commerce_ui -y
    • drush en commerce_customer commerce_customer_ui -y
    • drush en commerce_price -y
    • drush en commerce_line_item commerce_line_item_ui -y
    • drush en commerce_order commerce_order_ui -y
    • drush en commerce_checkout commerce_payment commerce_product -y
    • drush en commerce_cart commerce_product_pricing -y
    • drush en commerce_product_ui -y
    • drush en commerce_tax_ui -y
  4. Add a few more useful modules
    • drush dl admin_menu module_filter zurb-foundation-7.x-4.x-dev jquery_update -y
    • drush pm-disable toolbar
    • drush en admin_menu_toolbar module_filter jquery_update -y
  5. Create a responsive Zurb subtheme
    • drush fst Your Subtheme Name your_subtheme_name 'A subtheme of ZURB Foundation.'
  6. Set jQuery update to 1.7+, required by Zurb (admin/config/development/jquery_update)
  7. Enable your new responsive subtheme (admin/appearance)

SECOND FLOOR

  1. Quick tour of what we've got soo far
    • 1 Product type named 'Product'
    • 2 tax types
    • LOTS of hidden functionnalities
    • NO visible products
    • and NO, you don't get a store out-of-the-box
    • Commerce Kickstart gives you that but you won't know how to get there if you don't try from scratch
  2. Create a new product type 'Download'
    • add file & image fields
  3. Revisit 'Product', the product type installed by Commerce
    • add an image field
  4. Let's create products
    • a physical product (Product)
    • a virtual product (Download)
  5. Now what? where's the store?

Gotcha!

THIRD FLOOR

  1. Out-of-the-box Store is for wimps! ; )
    • Commerce products only exist in the backstore
    • products are like brown boxes in a warehouse: they're only accessible to the store's employees
    • in order to make products accessible to customers, you need to put them on display in a nice and attractive way
    • how do we do that in Drupal?
    • we use nodes, of course
  2. Create a content type for displaying products - you can call it Product display if you want
    • how does Commerce differentiate & recognize product displays from regular content types?
    • a product reference field; so your Product display must have a product reference field
    • create product displays for both content types and configure them
  3. Alright, let's shop!
    • wait a minute, nothing happens when i click Add to cart!

Gotcha!

FOURTH FLOOR

  1. In case you didn't read the fine print: some assembly is required, like Ikea, but without the KISS diagrams
  2. Introducing Rules... doh! where's the Rules UI ?
    • drush en rules_admin -y
    • go to admin/config/workflow/rules and add a rule that redirects to the cart
  3. Welcome to the cart
  4. Time to checkout wouldn't you say ?
    • doh!... something isn't right
    • where are the taxes?
  5. Like I said, Out-of-the-box taxes are for wimps! ; )
  6. Commerce's tax model is simple
    • there are tax types; like there are content types
    • and then there are tax rates like there are nodes e.g. Pages and Articles
  7. Create GST & PST tax rates (note - these taxes are specific to the Province of Quebec in Canada where the camp was held)
  8. Revisit the checkout
  9. Darn, the taxes are not displayed in the expected order! (i.e. GST on the first row, PST on the second row)
  10. How do we change the order in which taxes are displayed ?
    • the hard way: by overriding theme_​commerce_​price_​formatted_​components() in the theme's template.php (see https://drupal.org/node/1095576#comment-8721217)
    • the easy way: by creating separate tax types for GST and PST and playing with their respective weight (note that at the time of this writing, the behaviour for tax weights does not follow the convention where lighter weights float to the top; see this issue)
  11. Are we in business yet? Not quite.

FITH FLOOR

  1. Setting up a payment method
    • for simple tests, use the 'Example payment' module (provided by Commerce)
  2. For serious tests and real sales, you can use Stripe or Paypal or whatever works for you. For the purpose of this presentation, I used Stripe.
    • www.stripe.com
    • setup an account
    • get the API keys (secret and publishable)
  3. Install & configure Stripe
    • drush dl commerce_stripe
    • drush en commerce_stripe -y
    • add both keys to the Stripe payment method rule (admin/​commerce/​config/​payment-methods/​manage/​commerce_payment_commerce_stripe)
    • download the latest Stripe library v1.x from GitHub and extract it to sites/all/libraries/stripe-php
    • As mentioned on the Stripe project page, NOTE: this module currently only has support for the 1.x versions of stripe-php. 2.x versions will not work.
  4. Time for some tests
  5. When you're happy that all works like it should you can replace de test API keys by the live API keys.
  6. Done!

Well, we're not really done. But now you know a bit more about the process and the various pieces of the puzzle. Now simply try a few more times. Practice makes perfect, right?

Comments

I have litterally lost my mind to figure out how work commerce module! This pompous and exhibitionists commerce guys are to concerned and anxious to show how cool they are that is really impossible to understand anything at all!!! But it is so simple!!! Thank you!!!!!!!!!!!!!

thanks, this was really useful.

One thing that tripped me up is that I had to install stripe-php, and then it took me a while to figure out that I needed to install an older version of stripe-php (c1.18.0) for it to work. I was getting "Failure to load Stripe API PHP Client Library." Then it all worked for me. Thanks again.

Hey Matt, glad it all worked out for out in the end. I've added a line to the guide to make this clear. Cheers

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.