@wellsb1 You are submitting wrong data:
{
"product" : {
"categories" : [ "14", "124", "125", "14", "124", "126", "18", "127", "20", "128" ],
"sku" : "50384",
"title" : "Oval Opal (.23ct) & 3 Diamond (.05ct) Pendant w/ chain",
"description" : "Oval Opal and Round Diamond Pendant on 18\" Box Link Chain Gem .23cttw Diamond .05cttw",
"short_description" : "Oval Opal (.23ct) & 3 Diamond (.05ct) Pendant w/ chain",
"type" : "simple",
"attributes" : [ {
"name" : "Designer Number",
"value" : "YBC272760003014",
"slug" : "designer-number",
"variation" : false
} ]
]
}
}
See the fields for product attributes: https://woothemes.github.io/woocommerce-rest-api-docs/#products-properties
Look that we don’t have any value
in this fields… That’s the problem.
Besides you don’t need to use variation
, since is a single
product and since is a custom attribute, you don’t need to submit an slug, we use slugs only for global attributes (just a tip for you write less JSON, don’t worry about).
Here the correct JSON:
{
"product": {
"categories": [
"14",
"124",
"125",
"14",
"124",
"126",
"18",
"127",
"20",
"128"
],
"sku": "50384",
"title": "Oval Opal (.23ct) & 3 Diamond (.05ct) Pendant w/ chain",
"description": "Oval Opal and Round Diamond Pendant on 18\" Box Link Chain Gem .23cttw Diamond .05cttw",
"short_description": "Oval Opal (.23ct) & 3 Diamond (.05ct) Pendant w/ chain",
"type": "simple",
"attributes": [
{
"name": "Designer Number",
"visible": true,
"options": [
"YBC272760003014"
]
}
]
}
}
See that I included the visible
as true
, so people can see it in the “Additional Information” tab.
The API response will looks like:
"attributes": [
{
"name": "Designer Number",
"slug": "Designer Number",
"position": 0,
"visible": true,
"variation": false,
"options": [
"YBC272760003014"
]
}
],
And this is what you’ll see on the admin:
https://cloudup.com/cgo7rW6y1si
Some tips for you:
I have scoured the web for examples of uploading custom product attributes
Don’t need to search the web, you can just create a product in the admin interface and then fetch using the API.
This is a cool way to learn or reproduce some behavior that you already know how to archive only in the interface.
The /products/attributes api seems to handle what I will call “named” attributes
In this case are “global” attributes against “local” or “custom” attributes. More easy to understand in this way.