WordPress development tutorials

How to Generate a Post Excerpt Outside the Loop

When you work with WordPress, you become pretty familiar with using the WP_Post object or objects for custom post types. For example, while working with WooCommerce, products use the WC_Product post object (or the object for a class that inherits this, such as WC_Product_Variation). If you’re in the loop while working with posts or custom post types, get_the_excerpt() is a beautiful function, as it returns the excerpt if it’s set by the user, and automatically…

Read More

SkyVerge WooCommerce Extensions

WooCommerce Memberships: Renew with a Different Plan

By default, WooCommerce Memberships includes a “Renew” link for an expired membership. This allows the member to renew the membership by repurchasing the product (if available and at its current price) to resume the membership. This lets your member continue with any dripped content s/he already has access to once a set-length membership had expired if the member chooses to re-purchase. However, we had a very interesting question recently: can you use this to provide…

Read More

Prevent Repeat Purchase with WooCommerce

Depending on what kind of products you sell, you may want to prevent customers from purchasing a WooCommerce product more than once from your store. For some shops, you may want to disable any repeat purchases at all, or you may want to prevent repeat purchase only for a specific product. We’ve seen this most commonly with WooCommerce Memberships, as shops may want to restrict a free trial membership from being “purchased” again, or restrict…

Read More

WooCommerce reviews + tutorials

Widgets, Part Deux: Create a Smart WooCommerce Widget

This is post 4 of 8 in the series “Build a WooCommerce Extension” We’ve covered how to create a WooCommerce widget in a very basic sense in an earlier post in this series. However, there are some more advanced steps we can take to create “smart” WooCommerce widgets for your store. Creating a “Smart Widget” If you frequently use WooCommerce widgets, you’ll notice that some of them are displayed only on certain pages. For example,…

Read More

WooCommerce reviews + tutorials

How to Create a WooCommerce Widget

This is post 3 of 8 in the series “Build a WooCommerce Extension” Today we’re continuing our series on building your first WooCommerce plugin with an article on how to create a WooCommerce widget for your store. Widgets and shortcodes are great tools to let users output some information on the frontend of their eCommerce site, and they’re fairly easy to build and include as part of your plugin. We’ve already written about creating a…

Read More

Get All WooCommerce Orders for a Customer

There are several reasons you might want to get all WooCommerce orders for a customer in your shop. For example, you may want to find out if they’ve ever purchased a product, or do something as simple as count the number of orders they’ve placed with you. Since orders are a custom post type, you can use get_posts to query orders, which is a pretty standard WP query that most developers are familiar with and…

Read More

How to Simplify Free WooCommerce Checkout

For most WooCommerce checkouts, customers will be purchasing products and remitting payment to your store. They may also be selecting shipping methods or entering coupon codes. However, when customers purchase a free item, you may not need all of the fields at checkout if you’re not collecting any payment for shipping. As a result, you may require almost none of the checkout fields. While WooCommerce will helpfully remove payment method selection for free checkouts, the…

Read More

Add Actions to WooCommerce My Orders Table

You can easily add action buttons to the WooCommerce My Orders table in the customer’s My Account section of your site. The default buttons include actions like “Pay”, “Cancel”, and “View”, but you can add your own actions for each order. The woocommerce_my_account_my_orders_actions filter makes it very simple to add our actions. Actions are an array, so you add your own action into the array and then give them back to WooCommerce. The filter gives…

Read More

Get a list of WooCommerce sale products

You can get lists of all simple products, variable products, or featured products easily with WooCommerce. It’s also easy to get things like “in-stock” products or “out of stock” products. However, getting a list of WooCommerce sale products can be a bit tougher because sale products use different meta keys to determine sale status depending on the product type. Let’s take a look at a couple of ways you can get sale products. Check sale…

Read More

Pagely staging site

How to create a Pagely staging site (for the non-developer)

Chances are that you’ve heard of Pagely, as they were the first company to offer managed WordPress hosting. They’re one of two hosts we recommend, and we migrated all of our own sites to Pagely early this year. One feature that many eCommerce sites need as part of their managed hosting services are staging sites, as these help you test updates and debug issues so you don’t have to deactivate plugins or try out new…

Read More