Gerhard Potgieter

WordPress / WooCommerce Engineer at Automattic

WooCommerce Add Shipping Method to Emails — December 5, 2013

WooCommerce Add Shipping Method to Emails

Following up on the post about adding the Payment Type to your WooCommerce emails, a reader asked how they would be able to also add the Shipping Method to the WooCommerce emails.

Again WooCommerce does add a lot of information to the emails that goes out to the customers and admin but there are some things that are not part of the emails and another one of those things are the Shipping Method.

The shipping method could useful to display in emails to let shop admin knows how to ship the order if these emails are being used as packaging slips, or to let the customer know what type of shipping they selected at checkout.

To add the shipping method to all WooCommerce emails or just add it to the admin emails add the following code to your theme’s functions.php file.

Advertisements
WooCommerce Add Payment Type to Emails — November 14, 2013

WooCommerce Add Payment Type to Emails

WooCommerce send customers and store admins emails when new orders are placed, these emails contains all sorts of info relating to the order, however it is missing a couple of things that can be useful to customers or store admins.

One of the fields that is not present in the WooCommerce order emails are the payment type, some WooCommerce store admins would perhaps want to know this data in emails for decisions on whether to ship items immediately or to hold off for a while for money to clear.

To add the payment type to all WooCommerce emails or just admin email add the following code to your theme’s functions.php file, this is upgrade safe and the changes will stay in place after WooCommerce updates.

Controlling WordPress Auto Updates — October 25, 2013

Controlling WordPress Auto Updates

WordPress 3.7 was just released and one major feature that it includes is the ability have WordPress automatically updated to new versions without you having to log in and click a button.

I think it is absolutely great feature and can save you so much time in having to not log into all your site and clicking buttons, however it may not to appeal to everyone.

Reliability wise the auto update feature has been tested to death in beta and release candidates and the team working on this has ensured to cover all failure points to ensure that should something go wrong it will roll back to your previous version of WordPress. Even after 25000 auto updates in the RC releases there was not one single failure.

The WordPress team has catered for controlling auto updates via an array of filters and constants, the main constant being WP_AUTO_UPDATE_CORE. With the WP_AUTO_UPDATE_CORE constant you can control to allow disabling of auto updates, only allowing minor updates to occur automatically or allowing all updates to be done automatically.

The code below shows you how to control the automatic updates for different scenarios, you will place the code in your wp-config.php file.

If you want more control of specific features such as allowing auto updates of development releases such as beta and alpha releases, or want to only enable just major or just minor updates you can do that with the use of some filters. The following code shows examples of how to control specific WordPress auto update features, this code needs to be placed in your theme’s functions.php file.

If you have any questions or suggestions please feel free to leave them in the comments.

WooCommerce Number Of Products Sold — October 14, 2013

WooCommerce Number Of Products Sold

A question that has been popping up quite a lot lately in the WooCommerce support forums is how do I display the total amount of units sold for a product on the product page. In this WooCommerce tutorial I will be showing you how to display this on the product page.

Luckily WooCommerce already takes care of the majority of work for us to do this as it automatically keeps track of the number of units sold for each product for reporting purpose, all we have to do it do retrieve the value and display it on the product page.

To display the number of units sold for a product add the following snippet of code to your theme’s functions.php file

This will result in the Units Sold text to display underneath the product title and price

WooCommerce number of units sold

WordCamp Cape Town 2013 — September 23, 2013

WordCamp Cape Town 2013

WordCamp Cape Town 2013

At the beginning of the year our team at WooThemes HQ down here in Cape Town decided to approach previous organisers of the WordCamp Cape Town event to hear what their plans was for this year and if they would be willing to give over reigns of the event to us. Without any hassle or negativity from their side they agreed and we immediately set out to start promoting WordPress in South Africa more.

We started the WPCapeTown site, which is our main site and body under which we promote WordPress. The thing to note here is that even though it is a Cape Town community it is not limited to Cape Town and we welcome any WordPress user/creator from all over South Africa.

After two very successful events during the year we are pleased to announce that this year’s WordCamp Cape Town conference is a go. WordCamp Cape Town 2013 will take place at the beautiful Cape Town Stadium on 7 November 2013 and will cater for 400 of South Africa’s WordPress small business owners, non-profit agencies, realtors, photographers, designers, bloggers, journalists and web developers

Tickets for the event went on sale Friday 20 September and all discounted early bird tickets sold out in a matter of a couple of hours, with only general tickets left at R350 each.

If you are unfamiliar with WordCamps, they are community-organised events, championed by WordPress users, for WordPress users. The non-profit event will bring together WordPress enthusiasts from across South Africa to share best practices and strategies for WordPress development. Attendees range from casual users to advanced development professionals. All attendees will have the opportunity to attend a variety of sessions, presented by industry professionals, to share ideas and get to know each other.

The speaker list for this year’s WordCamp Cape Town are still in the finalisation stages but you can be assured that it will include top local and international WordPress professionals. This years theme for WordCamp Cape Town is “The Business Of WordPress”.

A WordCamp Cape Town 2013 ticket will give you access to 8 or more sessions as well as lunch, coffee, snacks, secure parking in the stadium, a free WordCamp Cape Town T-shirt and entry to the after party. Additional activities, workshops and networking events will be announced in the weeks leading up to the event.

So what are you waiting for, grab your WordCamp Cape Town 2013 Tickets before they are sold out as this a WordPress event you cannot afford to miss out on.

WooCommerce Custom Product Fields — September 17, 2013

WooCommerce Custom Product Fields

In this WooCommerce tutorial I will be showing you how to add a custom field to a WooCommerce product.

I will go through adding a custom field on the general tab section of the WooCommerce edit product page underneath the price fields where you can enter a value in to be saved, go through saving and validating the data and then displaying the data that was saved on the product page on the front-end of your shop.

As an example I will be showing you how to add a Recommended Retail Price (RRP) to a WooCommerce product and display this on the front-end, so lets get starting.

First step would be to define the field on the edit product page, luckily WooCommerce makes this very easy due to the large array of hooks available for use as well as the built in functions to generate HTML input fields. Place the following code inside your theme’s functions.php file to define a new text field on the product edit page.

You will now have a field on your product edit page called RRP, however if you enter something into the field and save the product, the data will not be save as we need to actually still save the data when the product gets updated, to save it and also check that a numeric value is entered add the following code to your theme’s functions.php file

Now when you enter a value in the RRP field and update the product the field should be saved and loaded in the RRP field you defined when the page loads. The final step would be to actually display the value saved on the product page on the front-end for customers to view, to do this add the following code to your theme’s functions.php file

Your end result will look like the image below when you add or edit a product

WooCommerce Custom Product Field Backend

And will look like this on the front-end when a customer views the product

WooCommerce Custom Product Field Front-End

Just a note that this tutorial does not cover adding custom fields to variable product, that process is covered in this tutorial by my fellow team member at WooThemes, Remi Corson.

WooCommerce Product Quantity Dropdown — September 9, 2013

WooCommerce Product Quantity Dropdown

WooCommerce Quantity Dropdowns

WooCommerce by default adds a quantity input box to your product pages where customers can enter quantities, but a lot of times you want to have more control over the quantities and make it more idiot proof on your site for customers by allowing them to select the quantities instead of entering it themselves.

The following snippet of code I wrote will replace the default WooCommerce quantity input box and replace it with a dropdown select option of quantities. It is fully compatible with the Min/Max Quantities extension which allows you to display quantities in the dropdown based on the minimum, maximum and group values so the customer can only select values in which the product can be bought instead of having to use plus and minus buttons or entering a value manually.

To turn your WooCommerce quantity input boxes into dropdown select options simply copy the following code to your theme’s functions.php file

WooCommerce Product Image Slideshow Using WooSlider —

WooCommerce Product Image Slideshow Using WooSlider

WooSlider Product Image Slideshow

At WooThemes we have this cool plugin called WooSlider which basically allows you to create awesome sliders just about anywhere on your site, it is a powerful WordPress slideshow plugin yet simple to use.

One of the questions that has been popping up a lot lately in support is, how can I turn my WooCommerce product images on the single product page into a slideshow instead of displaying a normal image, well luckily with WooSlider this is a breeze to do.

You simply need to purchase and install WooSlider, then you need to place the code below into your theme’s functions.php file

Deploy From Github To WordPress.org Plugin Repo — September 8, 2013

Deploy From Github To WordPress.org Plugin Repo

Deploy straight from Github to WordPress Plugin SVN Repository

Lately I have been working on quite a few WordPress plugins that are hosted in the WordPress.org plugin repository, and since Github is my go to version control system, I like it a lot and we use at WooThemes as well, I got a bit fed up with having to keep a local SVN copy and doing things manually.

After some googling I eventually found a bash script that enables you to deploy directly from your Github repository without the need to keep a local copy of the SVN repository, it is as simple as adding the script below to your Github repo, changing a few lines in the script and then executing it when you want to deploy to the WordPress.org plugin repository/

I take no credit for this script, in fact it was created by a fellow WooCommerce plugin developer, Brent Shepherd, he developed and maintains the awesome WooCommerce Subscriptions extension.

To deploy straight from your Github repository to your WordPress.org Plugins SVN repository, simply copy the bash script below and place it in a new file in your Github repository, I use deploy.sh, once the file is there you can commit it to Github so it is always part of your plugin, then open up the file and edit the following parameters.

PLUGINSLUG – Change this to the slug of the plugin on WordPress.org
MAINFILE – Change this to the main PHP file that contains the WordPress version number of the plugin
SVNUSER – Change this to the WordPress.org username of the user who owns the plugin, it will be commit under this user.

And that is it, once you have modified the file, you will have to make it executable by (chmod u+x deploy.sh) it via terminal, then when you are ready to deploy it, go to your Github repository where you stored the deploy.sh file and run the following command via terminal ./deploy.sh

It will ask you a few questions along the way and do some checks as well as tag the version on Github for you.

WooCommerce Percentage Saved Sale Price — September 6, 2013

WooCommerce Percentage Saved Sale Price

WooCommerce Percentage SavedWhen you have items on sale in WooCommerce, by default WooCommerce will display the regular price striked out with the sale price next to it.

Why not take it a step further and show your customers the savings they are getting on the sale price, with this snippet of code you can easily display the percentage saved next to the price of items on sale in WooCommerce.

Place the code below in your theme’s functions.php file

%d bloggers like this: