Tag your bestsellers automatically

WooCommerceIntermediate~10 minUpdated

Before you start

WooCommerce enabled, with the top-sellers report, the term read ability and the product update ability turned on. The product tag you want must already exist in WooCommerce. Add post terms is refused on products unless the site owner has exposed the Product content type, so tags are set with Update product, which takes tag IDs and replaces the product's whole tag list. The agent reads each product's current tags first and sends the full list.

A “Bestsellers” tag is only useful if it actually holds your bestsellers, and keeping it current by hand means re-checking the sales report every month and editing each product. The agent reads the top sellers and adds your tag to exactly those products, without touching anything else on them.

The prompt
I want to tag my best-selling products. First, change nothing: pull the top
sellers for [this month] (the report only takes a week, a month or a year), and look up my existing product tag named
[Bestsellers] so we are pointing at the right one.
Show me the match: the products that will get the tag, with their sales
counts, so I can confirm the list. Do not tag anything yet.
Once I approve it, add the [Bestsellers] tag to those products in small
batches. Setting tags on a product replaces its whole tag list and takes tag
IDs, so read each product's current tags first and send every existing tag ID
plus the new one. Do not use the post-terms tool, it is refused on products unless the Product
content type is exposed.
Show me each batch with each product's before and after tags. At the end, list
every product you tagged.

Why this is safe to run

The reads come first and carry no risk: pulling the top-sellers report and looking up the tag change nothing, so you approve the exact match list before any product is touched.

The write is small. Update product only changes the fields you send, and the only field sent here is the tag list, with every existing tag kept and yours added, so the product’s name, price, stock and description are not part of the call. Because the call replaces the list, the plan shows each product’s before and after tags so a dropped tag is caught before it saves. It works in batches you watch, only on the products you approved, and every change is checked against the capability of the user you bound the agent to and recorded in the Activity Log. If a product was tagged by mistake, you remove the tag from it in WooCommerce and the rest stand.

Already connected? Skip the paste. Ask your agent for the “tag your bestsellers automatically” recipe, or just tell it which tag and which period, and it runs the same reads-first flow on your own store.

How it works

  1. Read the best-selling products for the period you name.
  2. Look up the existing product tag you want to apply and confirm it is the right one.
  3. Show the match list (which products get the tag) and wait for your approval.
  4. Read each approved product's current tags, then set its tag list to those plus the new one, in small batches.
  5. Return the list of every product it tagged.

Questions

Will this remove the tags a product already has?
Not when the agent follows this recipe. Update product replaces the whole tag list, so the agent reads each product's current tags and sends them all back with the new tag added. You see the final list for each product before anything saves.
Can it create a new tag if the one I want does not exist yet?
No. This recipe only applies a tag that already exists. If you need a fresh Bestsellers tag, create it once in WooCommerce first, then run this to fill it.