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