> To build a Wix site agentically, or add Wix features like bookings or a store to a site you already have, follow https://www.wix.com/headless/skill.md
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# UpdateOrdersSettings

# Package: settings

# Namespace: OrdersSettingsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/settings/orders-settings/update-orders-settings.md

## Permission Scopes:
Manage Orders: SCOPE.DC-STORES.MANAGE-ORDERS

## Introduction

Updates the site's orders settings.

---

## REST API

### Schema

```
 Method: updateOrdersSettings
 Description: Updates the site's orders settings.
 URL: https://www.wixapis.com/ecom/v1/orders-settings
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ordersSettings
 Method parameters: 
   param name: ordersSettings | type: OrdersSettings | description: Site-level settings that control order behavior, such as when inventory is decremented and whether invoices are automatically generated. | required: true 
        - name: inventoryUpdateTrigger | type: InventoryUpdateTrigger | description: Defines when to update the store inventory. Default: `ON_ORDER_PLACED`  
             - enum:
             -     ON_ORDER_PAID: Stock quantities will update only after the payment is approved.
             -     ON_ORDER_PLACED: Stock quantities will update while the payment is being processed. If the payment did not go through, items will restock.
        - name: createInvoice | type: boolean | description: Whether to automatically create invoices for every new order paid online. <br> Default: `false` <br> **Note**: The issued invoice for an order is not a tax invoice and doesn't reflect refunds. You are responsible for ensuring that invoices you issue conform to any relevant legal requirements.  
 Return type: UpdateOrdersSettingsResponse
  - name: ordersSettings | type: OrdersSettings | description: The updated orders settings.  
     - name: inventoryUpdateTrigger | type: InventoryUpdateTrigger | description: Defines when to update the store inventory. Default: `ON_ORDER_PLACED`  
         - enum:
         -     ON_ORDER_PAID: Stock quantities will update only after the payment is approved.
         -     ON_ORDER_PLACED: Stock quantities will update while the payment is being processed. If the payment did not go through, items will restock.
     - name: createInvoice | type: boolean | description: Whether to automatically create invoices for every new order paid online. <br> Default: `false` <br> **Note**: The issued invoice for an order is not a tax invoice and doesn't reflect refunds. You are responsible for ensuring that invoices you issue conform to any relevant legal requirements.  
     - name: createdDate | type: string | description: Date and time the orders settings were created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the orders settings were updated.  | read-only: true | validation: format date-time


```

### Examples

### Update orders settings
Updates the site's orders settings to automatically create an invoice for each new order.

```curl
curl -X PATCH \
  'https://www.wixapis.com/ecom/v1/orders-settings' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
   "ordersSettings": {
     "createInvoice": true
   }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.ordersSettings.updateOrdersSettings(ordersSettings)
 Description: Updates the site's orders settings.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ordersSettings
 Method parameters: 
   param name: ordersSettings | type: OrdersSettings | description: Site-level settings that control order behavior, such as when inventory is decremented and whether invoices are automatically generated. | required: true 
        - name: inventoryUpdateTrigger | type: InventoryUpdateTrigger | description: Defines when to update the store inventory. Default: `ON_ORDER_PLACED`  
             - enum:
             -     ON_ORDER_PAID: Stock quantities will update only after the payment is approved.
             -     ON_ORDER_PLACED: Stock quantities will update while the payment is being processed. If the payment did not go through, items will restock.
        - name: createInvoice | type: boolean | description: Whether to automatically create invoices for every new order paid online. <br> Default: `false` <br> **Note**: The issued invoice for an order is not a tax invoice and doesn't reflect refunds. You are responsible for ensuring that invoices you issue conform to any relevant legal requirements.  
 Return type: PROMISE<UpdateOrdersSettingsResponse>
  - name: ordersSettings | type: OrdersSettings | description: The updated orders settings.  
     - name: inventoryUpdateTrigger | type: InventoryUpdateTrigger | description: Defines when to update the store inventory. Default: `ON_ORDER_PLACED`  
         - enum:
         -     ON_ORDER_PAID: Stock quantities will update only after the payment is approved.
         -     ON_ORDER_PLACED: Stock quantities will update while the payment is being processed. If the payment did not go through, items will restock.
     - name: createInvoice | type: boolean | description: Whether to automatically create invoices for every new order paid online. <br> Default: `false` <br> **Note**: The issued invoice for an order is not a tax invoice and doesn't reflect refunds. You are responsible for ensuring that invoices you issue conform to any relevant legal requirements.  
     - name: _createdDate | type: Date | description: Date and time the orders settings were created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the orders settings were updated.  | read-only: true 


```

### Examples

### Update orders settings (with elevated permissions)
```javascript
import { ordersSettings } from '@wix/ecom';
import { auth } from '@wix/essentials';

/* Sample update value:
{
  "ordersSettingsInfo": {
    "createInvoice": true
  }
}
*/

const elevatedUpdateOrdersSettings = auth.elevate(ordersSettings.updateOrdersSettings);

export async function myUpdateOrdersSettingsFunction(ordersSettingsInfo) {
  try {
    const settings = await elevatedUpdateOrdersSettings(ordersSettingsInfo);
    console.log('Success! Updated orders settings:', settings);
    return settings;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "ordersSettings": {
 *     "inventoryUpdateTrigger": "ON_ORDER_PLACED",
 *     "createInvoice": true,
 *     "createdDate": "2024-07-04T15:10:46.070Z",
 *     "updatedDate": "2024-07-04T15:10:46.070Z"
 *   }
 * }
 */
```

### Update orders settings
```javascript
import { ordersSettings } from '@wix/ecom';

/* Sample update value:
{
  "ordersSettingsInfo": {
    "createInvoice": true
  }
}
*/

export async function myUpdateOrdersSettingsFunction(ordersSettingsInfo) {
  try {
    const settings = await ordersSettings.updateOrdersSettings(ordersSettingsInfo);
    console.log('Success! Updated orders settings:', settings);
    return settings;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "ordersSettings": {
 *     "inventoryUpdateTrigger": "ON_ORDER_PLACED",
 *     "createInvoice": true,
 *     "createdDate": "2024-07-04T15:10:46.070Z",
 *     "updatedDate": "2024-07-04T15:10:46.070Z"
 *   }
 * }
 */
```

### updateOrdersSettings (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { ordersSettings } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { ordersSettings },
  // Include the auth strategy and host as relevant
});


async function updateOrdersSettings(ordersSettings) {
  const response = await myWixClient.ordersSettings.updateOrdersSettings(ordersSettings);
};
```

---