Skip to content
Advertisement

Add Product Attributes with values to a product in Woocommerce

I am using this code to add custom attributes

JavaScript

The result of this code I got added just product attribute Name without term values…

See the picture enter image description here

I searched about that very much but did not got any answer.

Advertisement

Answer

There is some mistakes in your code. Your main mistake: The attribute terms to save as product meta data (at the end) need to be an array of term IDs (instead of term names).

Try the following revisited code:

JavaScript

Tested and works.

Note: All product attributes and their values need to be defined (with your actual code)

Related: Create new product attribute programmatically in Woocommerce

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement