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
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]). A rare issue, but once again a quick fix! Here’s how you do it. Continue reading WooCommerce: Hide a Category from Shortcode