WooCommerce Cookbook

WooCommerce Cookbook

Create, design, and manage your own personalized online store with WooCommerce, the fastest growing e-commerce platform

Patrick Rauland

BIRMINGHAM – MUMBAI

WooCommerce Cookbook

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: March 2015

Production reference: 1240315

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78439-405-9 www.packtpub.com

Credits

Author

Patrick Rauland

Reviewers

Matthew Allan

Matt Cohen

Nicola Mustone

Commissioning Editor

Amit Ghodke

Acquisition Editor

Neha Nagwekar

Content Development Editor

Project Coordinator Neha Bhatnagar

Proofreaders

Simran Bhogal

Stephen Copestake

Indexer

Rekha Nair

Production Coordinator

Alwin Roy

Cover Work

Alwin Roy

Merwyn D’souza

Technical Editor Rahul C. Shah

Copy Editors Aditya Nair

Deepa Nambiar

Rashmi Sawant

About the Author

Patrick Rauland has built custom e-commerce solutions as well as high-end WooCommerce sites while working for advertising agencies. He joined the support team at WooThemes and answered thousands of support tickets. He later joined the WooThemes development team and started writing the underlying code for WooCommerce. After several months on the development team, he took on the role of product manager, and interacts with customers and the development team to help plan the future of WooCommerce.

Patrick loves going to conferences to talk about e-commerce, software development, productivity, happiness, and creating your online presence.

Patrick lives in Denver, Colorado, and loves running, yoga, and hiking.

You can reach Patrick through his programming blog at http://speakinginbytes.com.

I couldn’t have done anything worthwhile in my life, let alone write a book, without being inspired by so many people. The first person I have to mention is my friend Gerry Hazen. He spent hours listening to me blather about the latest book or blog post I just read. When I actually stumbled onto a good idea, he helped me refine the idea and follow through.

I also had a lot of inspiration from several people in the web industry. I look up to Brent Shepherd because he produces some of the highest quality software on the market. I look up to Daniel Espinoza because of his amazing grit when it comes to running his business to provide for his family; Matt Cohen for being able to refine any idea into its core components; and Michael Krapf for his big picture thinking and for taking a chance on me.

I want to thank my family for trusting that I’d find my way and for giving me the financial freedom to try all of these crazy ideas. Lastly, I want to thank Kristie Wirth, my partner, who hears all of the crazy ideas and helps me focus on one idea at a time.

About the Reviewers

Matthew Allan has exhibited a keen interest in business and e-commerce ever since he can remember. Over the past 3 years, he has been developing new software for entrepreneurs, wanting to jump into the e-commerce world and start selling online. Matthew’s main focus since completing his degree in information technology has been on WordPress and WooCommerce extension development and support.

Matthew works with a small team of developers at Prospress Inc. to bring top-notch plugins and extensions to the WordPress and WooCommerce platforms. Some of Prospress’ most wellknown extensions are WooCommerce Subscriptions and WooCommerce One Page Checkout— both mentioned in the book and available from WooThemes.com.

Matthew’s background in developing and supporting premium extensions for WooCommerce helped his technical review for this book.

Matt Cohen is the Chief Product Officer at WooThemes, a market leader in premium WordPress products, and the creators of WooCommerce. He spends his day managing his engineering team and a growing team of product managers.

With a deep love of web development, Matt began tinkering with HTML4 during high school (before CSS existed), which formed a strong bond with early web development languages and principles. Continuing his career, he worked as a senior developer at a handful of agencies prior to joining WooThemes as a senior web developer in late 2010. A love of product creation, customer experience, and well-architected products lead him to move into the Chief Product Officer role, where he oversees the design and creation of all products developed within WooThemes.

He has deep love for WordPress and is an engineer at his core, with a strong love of creating amazing customer experiences. In his personal time, he enjoys nature, punk rock, and forgotten 90s television.

Nicola Mustone is a web developer based in Italy, where he studied economics and programming. He developed his first website at the age of 15. From then, he fell in love with programming and web development, so he started studying it in depth, improving his skillset.

He started working as a freelancer at the age of 19. In 2011, he accepted his first job at a local web agency.

In 2012, Nicola moved from his birth city, Lucera, to Acireale in Sicily, to work with Your Inspiration where he learned about WordPress in its entirety, from end user usage to theme and plugin development. While working at Your Inspiration, he specialized in WordPress development and customer support.

In October 2014, he started working for WooThemes where he works and rocks out as a WooCommerce Support Ninja. Nicola also regularly writes articles and tutorials to help customers better understand WooCommerce and WordPress. You can reach him through his blog at http://nicolamustone.it.

 

Preface

Up until just a few years ago, building your own e-commerce site was remarkably difficult. You had to install complex software, host it yourself, and hope that, whenever you made a change, nothing broke. That’s very different from where we are now.

WooCommerce was released in September 2011 and, since then, it’s taken the e-commerce world by storm. As of 2015, there are nearly 400,000 sites that run WooCommerce; that is approximately 18 percent of all e-commerce sites on the Internet and bigger than every other competitor by a wide margin (source: BuiltWith.com).

Part of the success of WooCommerce is because it’s built on top of the incredibly popular WordPress platform. With just a few clicks, you can install the WooCommerce plugin and turn your WordPress site into an online store. With over 300 official extensions to customize your store, you no longer need a developer. You can add thousands of free plugins and themes to customize the rest of your WordPress site and the options are nearly limitless.

There are hosting companies that only host WordPress sites, services that maintain your WordPress sites for you, and professional products that handle every aspect of your site from creating contact forms to image optimization. The list goes on. What you need to know is that WordPress is huge and still growing. As WordPress grows, so will WooCommerce.

WooCommerce isn’t only built on top of WordPress. It’s also built on top of the WooThemes brand. WooThemes was one of the first companies to start building commercial themes and plugins for WordPress, and over the years they’ve perfected their techniques and poured it all into WooCommerce. Having to swap your e-commerce software would be a nightmare. That’s part of the reason that WooCommerce has taken off so fast. It’s backed by one of the biggest brands in the entire WordPress space. People know that they won’t disappear any time soon.

In short, you can rest easy. WooCommerce is built on top of both a growing platform and a trusted brand.

Let’s get started building your e-commerce site.

 

What you need for this book

WooCommerce is a plugin for WordPress. This means you already need to have your own self-hosted WordPress site. You cannot use a service such as WordPress.com that hosts the site for you.

Preface

Many of the recipes in this book require only WooCommerce itself. Some of them ask you to download a plugin from WordPress.org. Anything on WordPress.org will be completely free. Some recipes will require premium WooCommerce extensions. The vast majority of these are available on WooThemes.com. These extensions may be necessary for something such as, billing someone on a monthly basis, but they are not necessary for the core functionality. You can build a store without any extensions. If you don’t wish to purchase any, you can skip the recipes that require these.

If you are a developer and you wish to use a test site, that will be fine. There are only a couple of recipes in this book that need an actual live site, and this requirement is clearly flagged in the introduction to the recipe.

 

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There’s more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There’s more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: “We can include other contexts through the use of the include directive.”

A block of code is set as follows:

function woocommerce_cookbook_subscription_intervals( $intervals )

{

$intervals[10] = sprintf( __( ‘every %s’, ‘my-text-domain’ ),

WC_Subscriptions::append_numeral_suffix( 10 ) ); return $intervals; }

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: “clicking the Next button moves you to the next screen”.

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Preface

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book— what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to [email protected], and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at [email protected] if you are having a problem with any aspect of the book, and we will do our best to address it.

Cart