• Resolved arjunmurali1993

    (@arjunmurali1993)


    Hi,

    We use the marketplace plugin to integrate designers to our store. They send us designs, we manufacture products and sell them to customers. We use your marketplace plugin to provide the designers a nice dashboard to view the sales that their designs have generated, view their commissions, payments, etc.

    We create the products ourselves from our Admin account. To do this in bulk we have a custom software which uses the Woocommerce API. Is it possible to assign a Vendor to the product using the Woocommerce API when creating the product?

    I know it’ll get auto assigned if we create the product using the vendor login details in the API, but we won’t be having their login details and we create it from our account. I see that we can do this manually from the Vendor menu when editing the product in the WordPress Dashboard, but it would be better if we could do it automatically using the API.

    Could you please help us out here?

    Regards,
    Arjun

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter arjunmurali1993

    (@arjunmurali1993)

    Hi,

    Could you help us out with this?

    Regards,
    Arjun

    Plugin Author WC Lovers

    (@wclovers)

    Hi,

    You have to pass vendor/artist user id as “post author” over API call.

    Thank You

    Thread Starter arjunmurali1993

    (@arjunmurali1993)

    Hi,

    I tried doing this, but the Woocommerce API doesn’t have a Post Author product property to update this.

    Do we use the WordPress REST API for this? If so, could you help me with the correct property to update?

    I’ve tried the following two but it doesn’t seem to work.

    data = {
        'post_author': 181
        }
    
    resp = requests.request('put', 'https://mywebsite.com/wp-json/wc/v3/products/200424', json=data, auth=HTTPBasicAuth(userid, passwd))

    I’ve also tried 'author' = 181 and passing id of 181 as a text field '181', but none of those work as well.

    Regards,
    Arjun

    Plugin Author WC Lovers

    (@wclovers)

    Hello,
    The WooCommerce rest API doesn’t allow you to edit the product author as the WooCommerce rest API only creates/updates products for the logged-in users so you need to update the post of the product with the WordPress Rest API https://developer.www.ads-software.com/rest-api/reference/posts/#update-a-post and pass the author ID in the “author” field.

    Thank You.

    Thread Starter arjunmurali1993

    (@arjunmurali1993)

    Hi,

    I’ve set the ‘author’ field using the WordPress REST API but it doesn’t seem to assign the user as a Vendor though. Here’s the code I used to check and it works on Posts/Articles but not on Products.

    data = {
        'author': 181
        }
    
    resp = requests.request('put', 'https://mywebsite.com/wp-json/wc/v3/products/200424', json=data, auth=HTTPBasicAuth(userid, passwd))

    Using the same code, when I change things like slug, title, etc., it works fine. However, when I pass the author field and set it to the Vendor ID, it returns a Success 200 code. So I think the author field is getting set, but the Vendor isn’t getting assigned for the product.

    Could you please help me out with this?

    Regards,
    Arjun

    Plugin Author WC Lovers

    (@wclovers)

    Hello,
    The route URL you are using is WooCommerce route. ( https://mywebsite.com/wp-json/wc/v3/products/200424 )
    Use the default WordPress route as you cannot change the author with WooCommerce routes.

    Please find details of WordPress routes from the link: https://developer.www.ads-software.com/rest-api/reference/posts/#update-a-post

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Assign product to Artist when creating using Wcoocommerce API’ is closed to new replies.