Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3616581
Add new product with api to WPC-productbundels voor WooCommerce
Open

Comments

  • paul started the conversation

    Hello,

    I want to add a new wpc bundles product with an api call. But I cannot find any information on your site or github  how to do this. 

    Do you have an example how to add a new productbundle (as extra meta data)  to woocommerce api? 


    Greetings,

    Paul

  •  1,223
    Dustin replied

    Hi Paul,

    Bundles' data were stored in extra metadata that has a key starting with 'woosb_':

    4772683142.png

    The field 'woosb_ids' stores the data of bundled sub-products:

    9876343718.png

    Creating a bundle with a WooCommerce API is over-complex, so we don't provide any document for that work.

    Best regards,
    Dustin

  • paul replied

    Hi Dustin,


    Thanks for the quick reply and extra information. I would like to have the possibility to manage my products via the woo commerce api. Saves me a lot of time in creating and updating the products. 

    For now I add the meta information to my api-call. An example is found below.  It gets the data in the correct fields. The created product gives an error but after selecting edit product in the Wordpress dashboard and clicking right away on update product it works.  

    Hope you add the future of creating and updating products via api in the future.




     "meta_data": [
        {
          "key": "woosb_ids",
          "value": "33479/1,37837/1,16507/1}"
        },
        {
          "key": "woosb_discount",
          "value": "5"
        }
      ]


  • jasaez replied

    Creating a bundle with the WooCommerce API was working perfectly for me until version 8 of the plugin.
    The structure of the "woosb_ids" metadata has changed
    Before I passed "id_produc1/amount_1, id_produc2/amount_2"
    Now the structure is:

           {
                "id": 53245,
                "key": "woosb_ids",
                "value": {
                    "660e785247d74": {
                        "id": "4241",
                        "sku": "0000000597",
                        "qty": "3",
                        "optional": "1",
                        "min": "0",
                        "max": "10"
                    },
                    "660e785248e01": {
                        "id": "4243",
                        "sku": "0000000095",
                        "qty": "3",
                        "optional": "1",
                        "min": "0",
                        "max": "10"
                    },
                    "660e78524987b": {
                        "id": "4244",
                        "sku": "0000000096",
                        "qty": "4",
                        "optional": "1",
                        "min": "0",
                        "max": "10"
                    }
                }
            },

    How can I do it now?
    Thank you



  • jasaez replied

    ??

  •  1,223
    Dustin replied

    Hi Jasaez,

    Yes, you must use the new structure:

    In your example, 660e785247d74, 660e785248e01, and 660e78524987b are random strings for each item. You can use a shorter string or characters, e.g.: a, b, c...

    Best regards,
    Dustin

  • jasaez replied

    And how can I make that call to the API? I have tried to pass the structure to it but it doesn't work

    Thanks

  •  1,223
    Dustin replied

    Besides adding this metadata, you must set the product type as "woosb".

    It's the same as when we choose the product type here:

    7984045531.png


    Best regards,
    Dustin