• Hello! I want to use the Woocommerce REST API to update the billing email address associated with an individual order. I’m able to send PATCH and PUT requests to the orders endpoint to update (non-nested) values like ‘status’, but I can’t figure out how to update the billing email address, which is within a nested object. When I try, I get the order body back successfully, but the billing email is the same as it was previously.

    Here is what my request code looks like. The body I am sending is a copy of the order object for order #7329 but with the billing email value changed.

    const headers = {
      'X-WP-Nonce': csrfToken,
      Accept: 'application.json',
      'Content-Type': 'application/json'
    }
    
    const options = {
       method: 'PUT',
       credentials: 'same-origin',
       headers,
       body: JSON.stringify(body)
    }
    
    const endpoint = 'https://my.site/wp-json/wc/v3/orders/7329'
    
    return await fetch(endpoint, options)
        .then(async (response) => {
          const json = await response.json()
          return json
        }).catch((error) => {
          console.error(error)
        })

    Thanks so much for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I update order billing email via woocommerce api?’ is closed to new replies.