Develop WooCommerce

The official WooCommerce development blog

WooCommerce 3.2.6 fix release notes — December 13, 2017

WooCommerce 3.2.6 fix release notes

WooCommerce 3.2.6 is now available. This fixes various minor issues, and includes some more improvements to cart rounding.

~50 commits made it into this release. The full changelog is below.

* Fix - CSV Importer - Fix ID mapping to existing IDs.
* Fix - CSV Importer - Unslash header fields to avoid extra slashes.
* Fix - CSV Importer - Allow import and export of draft products.
* Fix - CSV Importer - Get global attribute ID only when is a global attribute.
* Fix - Remove URL fragment when appending geolocation hash.
* Fix - Additional cart rounding fixes so rounding before subtotal works again. Added more unit tests.
* Fix - Add BOM to exported report CSVs.
* Fix - is_visible should ensure product is is not trashed before returning true.
* Fix - Return packages with no rates back to the cart so the shipping calculator is displayed even when the current country is not shippable.
* Fix - Merge session and persistent carts when both exists after login.
* Fix - Remove "wc_error" query string after login. 
* Fix - Allow woocommerce_form_field() have 'custom_attributes' equal 0.
* Fix - Bulk actions in status logs table.
* Fix - Exclude add-to-cart from pagination links.
* Fix - Updated $GLOBALS['post'] data in products shortcode to prevent theme conflicts.
* Fix - Only remove base taxes in cart totals class if item is taxable.
* Fix - REST API - Fixed date format in reports schema.
* Fix - REST API - Updated product categories image schema.
* Fix - REST API - UUse KSES for purchase_note like in admin.
* Fix - REST API - Filter passed images before processing so they can be unset via querystring.
* Tweak - Use protected instead of private methods to allow easy override in session handler.
* Tweak - wc_lostpassword_url should not be used before init - added warning.
* Localization - Update Japanese prefectures to include prefecture type.

Download the latest release of WooCommerce here or venture over to Dashboard → Updates to update your plugins from WordPress.

As usual, if you spot any other issues in WooCommerce core please log them in detail on Github, and to disclose a security issue to our team, please submit a report via HackerOne here. Comments on this post are closed.

WooCommerce 3.3 Beta is here! — December 12, 2017

WooCommerce 3.3 Beta is here!

Today we’re pleased to announce that WooCommerce 3.3 is available for beta testing!

You can download it here.

Release highlights

3.3 is a minor release and will be launching near the beginning of next year. There should be no breaking changes, new functionality should exist in a backwards-compatible manner, and updating from any release since 3.0 should be hassle free! Here is what to look out for in the update.

Better support for non-WooCommerce themes

WooCommerce doesn’t require a WooCommerce-compatible theme any more! You can now run WooCommerce with any theme and it should look great. Read more about this here.

Revamped Orders screen

We’ve made a lot of improvements to the Orders screen. The design has been overhauled and we’ve added the ability to quickly view and manage orders on the Orders screen. Read more about this here.

Image sizing improvements

You can now select the aspect ratio of images in your store. We’ve also automated thumbnail resizing and image regeneration. Read more about this here.

Stock management improvements

We’ve made stock management simpler and more intuitive. Read more about this here.

Download logging

Product downloads are now logged. You can view and analyze information about products that are downloaded from your store. Read more about this here.

Webhooks CRUD

We’ve applied the CRUD software design pattern used throughout WooCommerce to webhooks and migrated them to their own custom table. Read more about this here.

Everything else…

Other features include:

  • We’ve replaced all of the old dummy data and placeholders with new, fresh dummy data!
  • We’ve moved some settings into the Customizer so that you can preview changes while managing those settings.
  • If you’re using the database logger, we’ve added the ability to search in the logs.
  • You can now search for extensions right on the Extensions screen.

On top of the new features, there are a variety of minor tweaks, new hooks, and fixes in this minor release. We won’t go into detail here, but you can see the full list of changes in the readme if you’re interested!

Template file changes

When editing core template files we bump the version so themes know they need to update custom versions. The following files were updated in 3.3:

  • auth/form-login.php – Converted submit inputs to buttons.
  • cart/cart.php – Decoupled cart templating methods from WC_Cart class and converted submit inputs to buttons.
  • cart/mini-cart.php – Decoupled cart templating methods from WC_Cart class and converted submit inputs to buttons.
  • cart/shipping-calculator.php – Included city field by default.
  • checkout/form-coupon.php – Converted submit inputs to buttons.
  • checkout/form-pay.php – Converted submit inputs to buttons.
  • checkout/payment.php – Converted submit inputs to buttons.
  • checkout/review-order.php – Decoupled cart templating methods from WC_Cart class.
  • emails/customer-invoice.php – Improved default test for checkout page link.
  • global/form-login.php – Converted submit inputs to buttons.
  • global/quantity-input.php – Added aria-labelledby to quantity field.
  • global/wrapper-end.php – Made the Underscores theme wrappers the default.
  • global/wrapper-start.php – Made the Underscores theme wrappers the default.
  • loop/add-to-cart.php – Added add_to_cart_description method and aria-labels to cart buttons.
  • loop/loop-start.php – Use new loop functions.
  • loop/orderby.php – Refactored to work well on unsupported themes.
  • loop/pagination.php – Refactored a little to work well on unsupported themes.
  • loop/result-count.php – Refactored a little to work well on unsupported themes.
  • myaccount/form-add-payment-method.php – Improved wording and converted submit inputs to buttons.
  • myaccount/form-edit-address.php – Converted submit inputs to buttons.
  • myaccount/form-login.php – Converted submit inputs to buttons.
  • myaccount/form-lost-password.php – Converted submit inputs to buttons.
  • myaccount/payment-methods.php – Removed a message about new payment methods.
  • notices/error.php – Added role=alert for improved accessibility.
  • notices/success.php – Added role=alert for improved accessibility.
  • order/form-tracking.php – Converted submit inputs to buttons.
  • order/order-details-customer.php – Cleaned up and updated as part of Orders UI revamp.
  • order/order-details.php – New actions and a little refactoring.
  • order/order-downloads.php – Made the downloads table responsive.
  • single-product/add-to-cart/grouped.php – New hooks and added form action.
  • archive-product.php – Use new loop functions.
  • content-widget-product.php – Better action names.
  • product-searchform.php – Converted submit inputs to buttons.

Deprecated functions and methods

  • wc_get_core_supported_themes has been deprecated since core now supports all themes.
  • WC_Product_Download::set_previous_hash has been deprecated since core is no longer using filename-based hashing to keep track of files.
  • WC_Product_Download::get_previous_hash has been deprecated since core is no longer using filename-based hashing to keep track of files.
  • WC_Admin_Webhooks::logs_output has been deprecated since logging is no longer done on the Edit Webhook screen.
  • WC_Admin_Webhooks::get_logs_navigation has been deprecated since logging is no longer done on the Edit Webhook screen.
  • WC_Customer_Download_Data_Store::update_download_id has been deprecated because download_id is now a static UUID and should not be changed based on file hash.
  • WC_Cart::get_item_data has been deprecated in favor of wc_get_formatted_cart_item_data.
  • WC_Cart::get_remove_url has been deprecated in favor of wc_get_cart_remove_url.
  • WC_Cart::get_undo_url has been deprecated in favor of wc_get_cart_undo_url.
  • WC_Post_Data::process_product_file_download_paths has been deprecated because no action is necessary on changes to download paths since download_id is no longer based on file hash.
  • WC_Webhook::get_delivery_log has been deprecated since webhook logs are stored using the logger.

Release schedule and testing

We’re hoping to keep WooCommerce 3.3 in beta for the next 4 weeks. If you’re a developer please check extensions and themes are compatible to be safe.

Release Candidate 1 will be tagged on January 11th and will remain in RC for a further 3 weeks until January 30th which is our target launch date.

If you’d like to help us test, you can download the release from Github. We posted a nice little write-up on beta testing here which should get you started. Please read that and jump right in!

If you’d like to help translate 3.3, you’ll find it on the development branch on translate.wordpress.org.

Thanks to all of our testers and contributors!

WC 3.3 Image size improvements — December 11, 2017

WC 3.3 Image size improvements

Let’s face it, product images are a vital driving force behind sales. Combine that with thousands of WooCommerce-enabled themes out there and it can become difficult to have product images that look good out-of-the-box on all of them. WooCommerce 3.3 aims to improve that with some changes to image size settings and the rendering of images.

WooCommerce 3.3 introduces new image cropping settings. Store owners can now control the width and height of their main images, as well as the cropping with visual cues as to what the images might look like on the frontend. Apart from that we are also giving themes with explicit WooCommerce support more control over image settings to ensure that product images look good out of the box.

Theme Support

In the past, theme authors had to make updates to settings directly via update_option calls to change the settings in the DB. This resulted in store owners experiencing issues where they would change image settings in the admin area just to have it revert back to what the theme updates it to on each page load. With WooCommerce 3.3 theme authors can now declare image sizes via the add_theme_support function. Declaring image sizes this way will take priority over any other settings and also hide the image settings section in the admin area.

add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 150,
'single_image_width' => 322,
) );

Thumbnail Cropping

A new thumbnail cropping section in the customizer will allow store owners to select one of three cropping ration settings with visual cues:

  • 1:1 (Square scropping)
  • Custom (Store owner can enter a custom aspect ratio)
  • Uncropped (Preserve single image aspect ratio)

Image sizes are then calculated based on the cropping option selected and the image width. It is important to note that Single Product Images are uncropped and not affected by the cropping settings.

Automatic Thumbnail Resizing

Apart from the new theme support and cropping settings, we have also introduced automatic thumbnail resizing. In the past when you changed a product image WordPress would not actually resize the image and you had to install a plugin like Regenerate Thumbnails in order to have WordPress resize the images for you. In WooCommerce 3.3 we have now added on-the-fly thumbnail resizing as well as background thumbnail resizing.

How this works is when you change your image settings WooCommerce will kick off a background process that automatically resizes all your images for you to the correct new sizes. While the images are being resized or if for some reason the resizing did not run or complete, we’ve added on-the-fly resizing to the frontend, ensuring that your images will always look great to your customers.

The on-the-fly resizing also plays an important part in ensuring that you have a great experience when visually editing your site through the customizer. If your theme adds support for it you can play around with different image sizes and cropping settings from within the customizer and see the results instantly.

These changes are already in the master branch and will be going out with the WooCommerce 3.3 release in January 2018.

If you have any thoughts or feedback you would like to share, feel free to leave them in the comments.

WC 3.3 will look great on all the themes! — December 9, 2017

WC 3.3 will look great on all the themes!

It used to be that you had to find specific WooCommerce-compatible themes for your store. In the upcoming release we have made big improvements in how WooCommerce handles themes that were previously unsupported, so now you can run WooCommerce with any theme!

On themes that don’t formally declare WooCommerce support the templates will render inside the content. This keeps everything looking natural on the site while ensuring everything still works great. Here are some before and after examples using themes that do not formally declare WooCommerce compatibility:

In order to make sure everything looks as nice as possible and so customers can see products well on themes with narrow content areas, lightbox and zoom will automatically be enabled for themes that don’t formally support WooCommerce. If your theme currently declares WooCommerce support the theme will still have full control over whether lightbox and zoom are enabled on products.

One thing that you will notice is that the product reviews area is not present on these themes. In our testing the CSS used by most themes that do not support WooCommerce did not work well with WooCommerce’s CSS for review styles. These themes will use the regular comments form. Themes that declare WooCommerce support will still use the review template.

Column and row settings

We’ve also added the ability to select the number of rows and columns displayed in the shop to the customizer. Everything updates dynamically so you can preview how your shop will look while changing the settings. The width of the columns will automatically increase or decrease depending on your settings, so everything should look nice and fill the available area. This feature is available on all themes.

Theme developers can set the minimum, maximum, and default settings for the columns and rows when declaring WooCommerce support:

add_theme_support( 'woocommerce', array(
    // . . .
    // thumbnail_image_width, single_image_width, etc.

    // Product grid theme settings
    'product_grid'          => array(
        'default_rows'    => 3,
        'min_rows'        => 2,
        'max_rows'        => 8,
        
        'default_columns' => 4,
        'min_columns'     => 2,
        'max_columns'     => 5,
    ),
) );

Testing and feedback

These changes are merged into our master branch on GitHub if you want to try things out. If all goes well, they will be part of 3.3 release in January.

Thoughts and feedback welcome in the comments.

WC 3.3 New Webhooks CRUD — December 8, 2017

WC 3.3 New Webhooks CRUD

We have been talking a lot about CRUD since 3.0.0, and the reason is because we want move certain features from the WordPress post database table to new database tables. This improves the performance and scalability of those features. Starting with 3.3.0, our webhooks will not use the posts and comments database tables anymore, and we finally have our first feature migrated to custom tables!

New Webhooks CRUD

Webhooks are a feature that 3rd party developers do not use often or heavily customize, so this make it easy to start moving all of the necessary data for webhooks to a new table.

With CRUD it is now easier to manipulate webhooks too:

// Creating a new webhook.
$webhook = new WC_Webhook();
$webhook->set_user_id( 1 ); // User ID used while generating the webhook payload.
$webhook->set_topic( 'order.created' ); // Event used to trigger a webhook.
$webhook->set_secret( 'secret' ); // Secret to validate webhook when received.
$webhook->set_delivery_url( 'https://webhook-handler.com' ); // URL where webhook should be sent.
$webhook->set_status( 'active' ); // Webhook status.
$webhook->save();

// Updating webhook:
$webhook = wc_get_webhook( $webhook_id );
$webhook->set_status( 'disabled' );
$webhook->save();

// Deleting webhook:
$webhook = wc_get_webhook( $webhook_id );
$webhook->delete( true );

Webhook delivery logs

Delivery logs have been moved from the WordPress comments table to our logging system, which allows more options for handling them instead of having to access the webhook logs in the admin interface.

Note: Because of this change all REST API endpoints for webhook delivery logs are now deprecated and will always return as empty. This is because logs now can be saved in the database, as files, or anything else.

Use your favorite message queue tool to process webhooks

It is now possible to write custom code to process webhooks. We used to only have options to deliver a webhook as soon as it is triggered or by WP CRON, but that may not be good for everyone. Until we have a third option with our “event queue” you may want to use Redis, Amazon SQS or something else.

It’s possible to override the delivery like so:

remove_action( 'woocommerce_webhook_process_delivery', 'wc_webhook_process_delivery', 10 );

/**
 * Custom process webhook delivery.
 *
 * @param WC_Webhook $webhook Webhook instance.
 * @param array      $arg     Delivery arguments.
 */
function my_custom_wc_webhook_process_delivery( $webhook, $arg ) {
	// Your custom code here.
	// Just do not forget to trigger webhook with later:
	// $webhook->deliver( $arg )
	// Or get the webhook payload as JSON and send with your own delivery method:
	// wp_json_encode( $webhook->build_payload( $arg ) )
	// Note that custom delivery methods will require extra code to log deliveries with $webhook->log_delivery( $delivery_id, $request, $response, $duration )
}
add_action( 'woocommerce_webhook_process_delivery', 'my_custom_wc_webhook_process_delivery', 10, 2 );

And that’s all folks 👋.