Bad news first – we’ve seen how to add content to any WooCommerce order email, however I did not specify that if you use the [products] shortcode that’s not going to work unfortunately. The reason behind this, in plain English, is that… it just doesn’t work, and it outputs a weird list of “Sale!” list items (see screenshot below)!
So, I want to fix this, and find a WooCommerce email-compatible way to show a grid of products based on a list of product IDs (for example, the list of related products based on the ordered items), and make sure I can actually see product images, titles, prices and a link. Enjoy!
Continue reading WooCommerce: Display Product Grid @ Order Emails e.g. Related Products
Products attributes display on the single product page whenever attribute terms are assigned to a given WooCommerce product. This is the default behaviour.
However, what if you want to show the product attribute table somewhere else? For example, in a blog post, or in a custom pricing table?
Well, we can build a shortcode for that – simply specify a product ID and the shortcode will magically output its attributes. Enjoy!
Continue reading WooCommerce: Products Attributes in a Shortcode
By default, the WooCommerce Shop page displays simple, variable, grouped, bundle and other product types. As you know, each variable product is made of one or more “single variations”, and these are only visible in the single product page.
Now, what if you want to display a grid of all “single variations” in a custom page / post? Well, a shortcode can be coded so that you can achieve just that. Enjoy!
Continue reading WooCommerce: Display All Single Variations (Shortcode)
It’s great that WooCommerce products clearly display their stock status and quantity on the single product page (and on the shop page, with this simple customization).
However, WooCommerce store owners often need to display the stock quantity in other sections of the website, such as the homepage, a blog post, a custom pricing table, and keep the quantity dynamic so that the text changes when there is a stock change.
We can therefore build a simple shortcode, that can automatically update the output, so that you never need to worry about changing that piece of content ever again. Enjoy!
Continue reading WooCommerce: Stock Quantity in a Shortcode
We’ve already coded a solution to display WooCommerce out of stock products only via a custom shortcode – today we’ll do the opposite: how can we display in stock products only via a handy shortcode?
Once again, the solution “gets” the list of products IDs that are in stock, and then passes the result to the official [products] WooCommerce shortcode, so that we don’t reinvent the wheel.
You can then use the [in_stock_products] shortcode anywhere you wish – on a blog post, in a custom page, in a widget, and so on. You can even customize the output with the official WooCommerce [products] shortcode parameters such as columns, orderby, limit, etc. Enjoy!
Continue reading WooCommerce: In Stock Products Shortcode
One of the most important WooCommerce pages, conversion-wise, is the Thank You page. That’s your chance to offer something special to a user that has just turned into a customer and is therefore more likely to purchase again.
We’ve seen how to include a whole WordPress page inside the Thank You page, how to redirect customers to a different Thank You page URL, how to display a custom social media share box on the Thank You page, but in this article I want to expand a little more on the topic and show a list of purchasable products via a shortcode.
The thing is that the Thank You page “does not exist” inside the WordPress pages, so you can’t just add a shortcode in a page. We must do that via a PHP action hook and the do_shortcode() WordPress function. Enjoy!
Continue reading WooCommerce: Display Product Up-sells @ Thank You Page
WooCommerce product reviews shows by default in the “Reviews” tab in the single product page. But what if, like me, you’re using custom sales pages and need to show such reviews elsewhere – by using a shortcode?
I’ve spent some time doing this for two Business Bloomer pages, the contact page (beside the request a quote form) and the Bloomer Armada sales page (just above the pricing table), so I thought it would have been great sharing the snippet with you. Enjoy!
Continue reading WooCommerce: Display Product Reviews @ Custom Page (Shortcode)
Currently, you can use a widget to have the user see the list of products they recently viewed. This is great and sooner or later it will also become a Gutenberg block I believe.
But for now, let’s create our own shortcode… and let’s take advantage of the existing [products] shortcode and learn how we can “pass” product IDs to it without the need of reinventing the wheel.
This snippet teaches you where recently viewed products are stored (spoiler: in a cookie) and also how to use an existing shortcode… inside a new shortcode. Enjoy!
Continue reading WooCommerce: Recently Viewed Products (Shortcode)
If you’re developing custom landing pages or sections dedicated to logged in customers, knowing the quantity purchased of a certain product ID might come useful.
We already saw how to detect whether a logged in customer has purchased a given product, as well as a snippet to return all products purchased by a specific user – but this time I want to “count” how many times a current user has purchased a product ID, and return this on the screen via a shortcode.
From this snippet you can learn lots of things, for example how to create custom shortcodes, how to get customer orders, and how to set up a foreach loop in PHP. Either way, enjoy!
Continue reading WooCommerce: Count User Purchases By Product ID (Shortcode)
When I write tutorials like WooCommerce Separate Login & Registration Pages I often need to “write” on the screen the actual shortcode – but I don’t want the shortcode to output content!
For example, if I write [woocommerce_my_account] it’s guaranteed you won’t see “[woocommerce_my_account]“… you will see Business Bloomer’s My Account page content instead!
So there is a great workaround for those of you who write tutorials, snippets and WordPress articles and need to print the actual shortcode on the screen, without making it “process” its content and outputting it.
Enjoy! Continue reading WooCommerce: How to Write Shortcodes Without Outputting Content?
A client of mine wanted to show out of stock products on a separate page – so I coded a simple shortcode for you all!
You can use this shortcode for different goals. For example, you might want to display what products you’ve sold to enhance customer trust / social proof.
So let’s see (1) how to create a shortcode and (2) how to take advantage of the existing [products] WooCommerce shortcode and its “ids” parameter to pass just those product IDs that are out of stock!
Continue reading WooCommerce: Display Out of Stock Products (Shortcode)
When a WooCommerce customer is logged in, you might want to show the list of purchased products, for example in a custom “My Account” tab.
I decided to code this as a shortcode, so that you can use the snippet anywhere in your WooCommerce templates, as long as the user is logged in and as long as it has processing or completed orders. Enjoy!
Continue reading WooCommerce: Display All Products Purchased by User
The WooCommerce “products” shortcode displays all products in your shop. There is even an attribute called “category” where you can specify comma-separated list of category slugs in order to further filter the output.
What you can’t do is define a list of unwanted categories (think of “uncategorized” for example) i.e. a list of categories you want to exclude from the products shortcode output.
So, here’s the fix, enjoy!
Continue reading WooCommerce: Exclude Category from Shortcode
Sometimes solutions are very simple, and you don’t need rocket science to fix your issue!
A client of mine needed to hide a category from the Product Categories Shortcode (“product_categories”); in fact, there is no parameter that allows you to “exclude” a given product category such as “uncategorized” or whatever category you wish.
A rare issue, but once again a quick fix! Here’s how you do it.
Continue reading WooCommerce: Exclude Category from Shortcode