Divi WordPress Theme

Welcome to Our Wordpress Help Forum Community & Wordpress Site Maintenance Services!

  1. Welcome to the WPHelpForum.com - The WordPress Help Forums & WordPress Support Services

    Please Take a Moment to Sign up and To Gain Unlimited Access to The WordPress Help Forums and Extra Privileges That Guests Don't Have Access To.
    Having an Account Gives you Additional Privileges, Such As:

    • Access Exclusive WordPress Help Video Forums.
    • Get Support Regarding WordPress Themes, Plugins as well as General Questions and discussions.
    • Learn New Ways of Securing, Installing and Running Your WordPress Website.
    • All that and Much More! Registration is Quick, Simple and Totally Free. Join our community today!
    • Get expert help for Wordpress Site Maintenance Services & WordPress Support Services Wordpress Site Maintenance Services

Join Us!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WooCommerce: Add products with attribute in REST API

Discussion in 'Plugins and Hacks' started by mr_ocean, Feb 17, 2017 at 6:44 AM.

  1. mr_ocean

    mr_ocean Thread Starter New Member

    Likes Received:
    Hi all!

    I've a problem with the REST API. I installed this class (automattic/woocommerce) for WooCommerce API.
    I can to insert a new product but i found difficulty to add a product's attributes.

    I want to create a new product in my website with attribute (color).

    This is the code that i use:
    $data = [
    'name' => 'Microsoft Surface',
    'type' => 'simple',
    'regular_price' => '1100',
    'description' => 'Il tablet AiO di Microsoft',
    'short_description' => 'Tablet surface',
    'categories' => [
    'id' => 20
    'images' => [
    'src' => 'images/pic.jpg',
    'position' => 0
    'attributes' => [
    'id' => 'colore',
    'position' => 1,
    'visible' => true,
    'variation' => [
    '0' => 'argento',
    '1' => 'nero',
    '2' => 'oro'

    This code works, the product was added into WooCommerce but it don’t have any attribute.
    Can you help me to solve the problem? I read the docs but i don’t understand how can i do to solve..

Share This Page