jasonknight/woocommerce-json-api

Issue With Variations

Closed this issue · 2 comments

[attributes] => Array
(
    [size] => Array
        (
            [name] => Size
            [value] => Array
                (
                    [0] => Small
                    [1] => Medium
                    [2] => Large
                )

            [position] => 1
            [is_visible] => no
            [is_variation] => yes
            [is_taxonomy] => no
        )

)

A variation is usually attached to a attributes.
How can I link a variation to its attribute.

Would really appreciate if you can add a field to link a variation to a attribute.

In the code above I have an attribute called Size, in the code below this are variation that are attached to the Size attribute, but there is no way to link the variation to its attributes.

[variations] => Array
(
    [0] => Array
        (
            [id] => 123
            [name] => Variation #123 of Shoeee
            [slug] => product-26-variation
            [type] => product_variation
            [description] => 
            [short_description] => 
            [parent_id] => 26
            [publishing] => publish
            [sku] => SZ345
            [downloadable] => no
            [visibility] => visible
            [virtual] => no
            [manage_stock] => no
            [sold_individually] => no
            [featured] => no
            [allow_backorders] => no
            [quantity] => 45
            [height] => 
            [weight] => 5
            [length] => 
            [price] => 4800
            [regular_price] => 5000
            [sale_price] => 4800
            [sale_from] => 
            [sale_to] => 
            [status] => instock
            [attributes] => Array
                (
                )

            [tax_class] => 
            [tax_status] => none
            [product_type] => product
            [categories] => Array
                (
                )

            [tags] => Array
                (
                )

            [reviews] => Array
                (
                )

            [variations] => Array
                (
                )

            [images] => Array
                (
                )

            [featured_image] => Array
                (
                )

        )
)

In the app we are building that is leveraging the Woocommerce JSON API, when creating a variation for a product we want to send the following things title of the variation, name of the variation, sku of the variation, price of the product variation and the stock quantity. Because following the example in set_product_variation the attribute isn't passed, but in our case we want to pass an attribute like Size and pass some values along like Small, Medium and Large. The variation that we create we want to link each of them to an attribute value. Like linking a variation to a attribute called Size with a value of Small.

Is there need for us to send an attribute for example size along with the payload data.

You know better, would appreciate if you can explain this clearly.

This feature is being added in, editing dynamic attributes is not possible, but fetching them is.

Will keep you up to date on the product.

Though not: When creating a variation, you should duplicate the product fields and change what you need to.

This has been fixed.