XiaoFaye / WooCommerce.NET

A .NET Wrapper for WooCommerce/WordPress REST API
MIT License
391 stars 217 forks source link

Create product with 2 attributes and variation for all combinations of them #729

Closed tiziana-git closed 1 year ago

tiziana-git commented 1 year ago

Where can i find an example of how to create 2 attributes for a product and then all the variation? I can create a product with 2 attributes but then how to reproduce the "Create variations from all attributes" button behaviour?

        Dim oProdNew As Product = New Product()
        oProdNew.name = "Product 1"
        oProdNew.price = 12.65
        oProdNew.regular_price = 12.65
        oProdNew.description = "This is product 1"
        oProdNew.type = "variable"
        oProdNew.stock_quantity = 10
        oProdNew.attributes = New List(Of ProductAttributeLine) From {
            New ProductAttributeLine With {
                .name = "Color",
                .position = 1,
                .variation = True,
                .visible = True,
                .options = New List(Of String) From {
                    "Green",
                    "Red",
                    "Blue"
            }},
                 New ProductAttributeLine With {
                .name = "Size",
                .position = 2,
                .variation = True,
                .visible = True,
                .options = New List(Of String) From {
                    "XS",
                    "S",
                    "M",
                    "L",
                    "XL"
            }}
        }