I have a tag called ‘Sold out’; the slug is ‘sold-out’. Where do I find the ID?
Tag: Product Tag
WooCommerce: Allow CSV Product Export By Tag
Ok, this is a little hacky and pretty manual, but it happened to me in the past that the inbuilt WooCommerce CSV product export was just not enough.
In other words, the default product export that you can find by clicking the “Export” button on the “Products” WordPress Dashboard screen, gives you the option to export all products to a CSV. You can also refine the list by product type and product category, so that you can export specific products only.
What’s missing there is a “product tag” filter, so this workaround will let you do just that – define a product tag slug in the snippet below, and your export list will be automatically filtered by that.
Of course, you could find a dynamic way of doing that, but for now we’ll keep this manual and hardcoded into the PHP function. Enjoy!
Continue reading WooCommerce: Allow CSV Product Export By TagWooCommerce: Get Variation IDs By Product Category or Tag
We can get products belonging to a product category or product tag very easily. What’s much more difficult is getting single variations based on a product category or product tag, as variations… don’t have a category or tag, which belong to its “parent” variable product instead.
In this post, we will define a function that you can reuse in your custom code whenever you need to get all variation IDs based on a given product category or product tag. You can then loop through the array and return whatever info you need. Enjoy!
Continue reading WooCommerce: Get Variation IDs By Product Category or TagWooCommerce: Show Related Products In a Blog Post!
Maybe because I’m Italian, but I like exclamation marks! Also, Italian gestures – of course. With that being said, today we look at an amazing WooCommerce customization.
I’ve finally gained back some free time to work on my personal projects, and one of these is an affiliate website. In order to drive traffic to this WooCommerce website, we have a major content strategy and we publish 7 relevant posts per month.
However, it’s difficult to drive blog readers to the shop page, so I came up with a great idea – why not adding a grid of relevant related products at the end of each blog post, based on the most used keywords?
The rationale behind this is quite easy:
- you have a list of product tags
- you have a blog post full of words
- you count and define the most mentioned product tag
- you show 10 products from that product tag
Cool, ha? Well, let’s take a look at my code, and feel free to use it on your install!
Continue reading WooCommerce: Show Related Products In a Blog Post!WooCommerce: Automatically Add Tag To Purchased Products
This functionality can be helpful to those who need to differentiate purchased products from non-purchased ones. Think about a way to automatically discount non-tagged products, in order to entice more sales; or a function that only shows purchased products via a custom shortcode.
No matter the application, “tagging” products upon purchase is super easy. Of course, make sure to create a custom product tag first, and get its ID, so that you can use this in the code below. Enjoy!
Continue reading WooCommerce: Automatically Add Tag To Purchased ProductsWooCommerce: Truncate Tag List @ Single Product Page
If you use WooCommerce product tags, it’s possible that a product may belong to 10 or more of them. When that happens, the single product page displays a long list of tag links, which may take too much space (see the below screenshot to visualize this).
Today’s snippet is indeed a way to truncate that list to – say – 3 tags only, and add a “+” to show the rest upon click. In this way if the customer is really interested in that they can expand the view, otherwise tags will take up a single line only. Enjoy!
Continue reading WooCommerce: Truncate Tag List @ Single Product PageWooCommerce: Get Product IDs (All, by Tag, by Category)
When you work with WooCommerce PHP snippets, you often need to “get” stuff off your WordPress database in order to make some calculations and return the result on the screen. And if there is something I often google is “How do I get all my store’s product IDs?“.
Thankfully the wc_get_products WooCommerce function gives us the answer. Enjoy ๐
Continue reading WooCommerce: Get Product IDs (All, by Tag, by Category)