Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong example data being used for Batch update setting optionsin Woo Rest API docs #222

Open
nigeljamesstevenson opened this issue Oct 20, 2022 · 0 comments

Comments

@nigeljamesstevenson
Copy link

The example data is not related to the batch call being made.

It appears to be a copy paste from the data used for Batch update product variations

The cURL example is good but the Node.js, PHP, Python and Ruby calls need updating.

The same data example could be applied to Node.js as follows:

const data = {
  update: [
    {
      id: "woocommerce_allowed_countries",
      value: "all"
    },
    {
      id: "woocommerce_demo_store",
      value: "yes"
    },
    {
      id: "woocommerce_currency",
      value: "GBP"
    }
  ]
};

WooCommerce.post("settings/general/batch", data)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.log(error.response.data);
  });

with similar updates for PHP:

<?php
$data = [
  'update' => [
    [
      'id': => 'woocommerce_allowed_countries',
      'value' => 'all'
    ],
    [
      'id' => 'woocommerce_demo_store',
      'value' => 'yes'
    ],
    [
      'id' => 'woocommerce_currency',
      'value' => 'GBP'
    ]
  ]
];

print_r($woocommerce->post('settings/general/batch', $data));
?>

Python:

data = {
  "update": [
    {
      "id": "woocommerce_allowed_countries",
      "value": "all"
    },
    {
      "id": "woocommerce_demo_store",
      "value": "yes"
    },
    {
      "id": "woocommerce_currency",
      "value": "GBP"
    }
  ]
}

print(wcapi.post("settings/general/batch", data).json())

and Ruby:

data = {
  update: [
    {
      id: "woocommerce_allowed_countries",
      value: "all"
    },
    {
      id: "woocommerce_demo_store",
      value: "yes"
    },
    {
      id: "woocommerce_currency",
      value: "GBP"
    }
  ]
}

woocommerce.post("settings/general/batch", data).parsed_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant