Code Snippets

Instructions on how to add code snippets can be found Here

Person-entering-laptop-2_S

Order Posts Alphabetically

Modifies the main query to sort posts alphabetically by title. Must be added to functions.php file of the Theme Customisations plugin.
Person-entering-laptop-2_S

Add a surcharge to cart and checkout – uses fees API

Person-entering-laptop-2_S

Show product categories in WooFramework breadcrumbs

Person-entering-laptop-2_S

Change number of upsells output

Person-entering-laptop-2_S

Change number of related products output

Please note that it does not work for all themes because of the way they’re coded.
Person-entering-laptop-2_S

Hide loop read more buttons for out of stock items

Person-entering-laptop-2_S

Hide other shipping methods when “Free Shipping” is available

Adding code Before adding snippets, clear your WooCommerce cache. Go to WooCommerce > System Status > Tools > WC Transients > Clear transients. Snippets for WC 3.0+ Hides everything but free_shipping if it’s available and is compatible...
Person-entering-laptop-2_S

Automatically add product to cart on visit

Person-entering-laptop-2_S

Add a custom field (in an order) to the emails

You can add any custom field to your order emails by hooking in and specifying the name of the custom field. This can be useful when used in conjunction with...
Person-entering-laptop-2_S

Adjust the quantity input values

Set the starting value, maximum value, minimum value and increment amount. The WooCommerce Min/Max Quantities extension is a slightly more powerful version of this code snippet.
Person-entering-laptop-2_S

Send coupons used in an order by email

This snippet sends by email the list of coupons used in an order. You can customize the “$to” variable and define your own email address, and the “$message” to have...
Person-entering-laptop-2_S

Allow shortcodes in product excerpts

Person-entering-laptop-2_S

Minimum Order Amount

The WC Minimum Order Amount plugin is based on this snippet.
Person-entering-laptop-2_S

Customize the WooCommerce breadcrumb

Person-entering-laptop-2_S

Automatically Complete Orders

You could also change the “Completed” status to be another order status, like “Processing”
Person-entering-laptop-2_S

Hide sub-category product count in product archives

Turns this: Into this:
Person-entering-laptop-2_S

Custom sorting options (asc/desc)

This example code shows how you can add an order option for ‘random’, but this also works in similar ways for other ways to order your products on the catalog...
Person-entering-laptop-2_S

Change the default state and country on the checkout

Note that the default_checkout_billing_country filter affects both existing and non-existing users.
Person-entering-laptop-2_S

Override loop template and show quantities next to add to cart buttons

To display quantity input fields for simple products within your shop archive pages, use the following code:
Person-entering-laptop-2_S

Allow HTML in term (category, tag) descriptions

By default, WordPress strips HTML from category descriptions. This code will prevent that from happening. The first part prevents HTML from being stripped from term descriptions. The second part prevents HTML being...
Person-entering-laptop-2_S

Apply a coupon for minimum cart total

The code snippet below allows you to: Show a notice on the cart and checkout page, reminding customers that they get a discount if spending more than a minimum amount....
Person-entering-laptop-2_S

Exclude products from a particular category on the shop page

As ‘clothing’ is an example in the snippet below, be sure to use a product category slug that exists in your WooCommerce store. Note that this will only work when you...