Develop WooCommerce

The official WooCommerce development blog

How to Test Your Extensions the WooThemes Way — March 5, 2015

How to Test Your Extensions the WooThemes Way

There seems to be a bit of confusion in our community about how and when you should test your extensions against a new version of WooCommerce. There is no right or wrong way to test extensions so I’ll tell you what we do here at WooThemes.

  1. Subscribe to this blog and pay attention to the big changes as they come out. Ex. in 2.3 the coupon system was refactored. If you have an extension that deals with coupons then it’s advisable to test right then and make any updates you have to make.
  2. When the first beta is announced on the develop blog it’s time to test your extension. Betas are usually very similar to the final release. In rare exceptions features are added or deleted here but usually after the first beta there are only bug fixes.
  3. When the first release candidate is announced do another quick test to make sure your extension works. If something did make it into the beta to affect your plugin this is where you catch it. The release candidate is strictly bug fixes. If it works during the release candidate phase it should work when the new version of WooCommerce is released.

We do all of our development on the master branch so whenever you want to test WooCommerce it’s best to use the master branch.

There are a couple of our extensions that are quite large and extra testing goes into these plugins. Plugins like Subscriptions for example usually has several weeks or months of testing to make sure that everything will work against the newest version of WooCommerce. If you have a very large or complex extension then it’s worth testing as we add features into WooCommerce before we release the first beta.

I hope this clears up how we do our own testing and hopefully it should help you do yours. 🙂

WC 2.3 Email Class Refactor and Enhancements — October 23, 2014

WC 2.3 Email Class Refactor and Enhancements

WooCommerce 2.3 is still a ways out, but one of the things we’ve been working on is a better email class system in core. Primarily, we’ve refactored how emails are sent through WooCommerce. Any extension can send a WC branded email by loading the mailer and calling the send method. Like so:

// set subject
$subject = 'WC Send Mail Test';

// load the mailer
$mailer = WC()->mailer();
$mailer->send( get_option( 'admin_email' ), $subject, $mailer->wrap_message( $subject, 'a test message' ), '', '' );

 

WooCommerce Test Email
An email sent via the refactored send() method

The wrap_message() function wraps the email in the WooCommerce branding. If you want to send an email without any WooCommerce branding you can do so by not using the wrap_message() function.

WooCommerce Email Without Branding
An email without any WooCommerce branding

A CSS Inliner for Prettier Email

If you’ve ever spent time customizing an email template you know how awful it is to work with different email clients and how none of them support regular CSS. This is a pain for developers and really confusing for end users. After refactoring the send methods we were able to add a CSS inliner. This will take regular CSS and rewrite it so that each element has the styles written inline. This prevents a lot of problems with email clients.

A New Way to Customize Email CSS

We used to have all of the CSS in the email-header.php template which was convenient programmatically but a bit confusing for users. We took all of this CSS and put it into it’s own template. An end user can now override the email-styles.php template.

A New Way to Customize Email CSS for Developers

Overriding templates is great for end users but it’s not great for developers. If you want to write a plugin that changes the email styles you can use the new woocommerce_email_styles filter. I’ve made an example plugin that shows how to use this filter.

If you want to test this new functionality yourself it’s merged into the master branch of WooCommerce on GitHub.

Happy emailing!