WooCommerce: Programmatically Rename Variable Product Attribute Options

I think the easiest way to explain this customization is with a case study. Go to this variable product page, that I use to sell sponsorship packages on the WooWeekly newsletter: https://www.businessbloomer.com/shop/newsletters/wooweekly-sponsorship/

Now, take a look at the “Start in” attribute dropdown. That’s where a company picks the month for when the sponsorship starts. You will notice that this always displays the next 3 months based on today’s date!

And that’s exactly what I’ve done with the code below. Instead of manually changing the attribute names to “Nov 2023”, “Dec 2023”, “Jan 2024” in October 2023, then changing them again in November, and so on – I’ve come up with a way to rename attribute options dynamically, so that I don’t need to do this every month.

Which means, enjoy, and hope you can make the most of this snippet in case you need it too!

Continue reading WooCommerce: Programmatically Rename Variable Product Attribute Options

WooCommerce: Products Attributes in a Shortcode

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