Contents
On this page

Create Bundle - Plugixa POS for WooCommerce

POST /plugixa-pos/v1/bundles

Make a bundle. Without product_id, a new published simple product is created.

Needs a user with the plugixa_pos_manage_settings capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; other roles only when you grant it.

Request

POST https://your-site.example/wp-json/plugixa-pos/v1/bundles

Request body

Content type: application/json

Field Type Required Description
product_id integer No An existing simple product to turn into a bundle.
name string No Up to 200 characters. Needed when the product has none.
price string No Regular price, decimal. Needed when the product has none.
sku string No SKU, unique in WooCommerce.
components object[] Yes 1 to 50 rows of id (a simple product or a variation, not a bundle) and qty (1 to 999). The same product twice is merged.
{
  "name": "Coffee lover set",
  "price": "39.00",
  "sku": "SET-COFFEE",
  "components": [
    {
      "id": 3720,
      "qty": 1
    },
    {
      "id": 3728,
      "qty": 1
    }
  ]
}

Responses

201 Created.

{
  "success": true,
  "data": {
    "id": 4470,
    "name": "Coffee lover set",
    "sku": "SET-COFFEE",
    "price": "39.00",
    "status": "publish",
    "edit_url": "https://your-site.example/wp-admin/post.php?post=4470&action=edit",
    "own_stock": false,
    "components": [
      {
        "id": 3720,
        "qty": 1,
        "name": "House espresso beans 250 g",
        "sku": "COF-HOUSE",
        "stock": 38,
        "cost": "3.8000",
        "price": "9.90"
      },
      {
        "id": 3728,
        "qty": 1,
        "name": "French press 1 L",
        "sku": "COF-PRESS",
        "stock": 3,
        "cost": "13.0000",
        "price": "27.00"
      }
    ],
    "available": 3,
    "parts_value": "36.90",
    "cost": "16.8000",
    "margin": "48.3"
  }
}

Errors

Status Code When
404 plugixa_pos_not_found product_id does not exist.
422 plugixa_pos_bundle_type The product is not a simple product.
422 plugixa_pos_bundle_part A component is missing, not a simple product or variation, or the count is outside 1 to 50.
422 plugixa_pos_bundle_nested A component is a bundle, or the bundle itself.
422 plugixa_pos_bundle_sku WooCommerce refused the SKU.
422 plugixa_pos_invalid The bundle has no name or no price.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/bundles" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Coffee lover set","price":"39.00","sku":"SET-COFFEE","components":[{"id":3720,"qty":1},{"id":3728,"qty":1}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/bundles');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'name'       => 'Coffee lover set',
        'price'      => '39.00',
        'sku'        => 'SET-COFFEE',
        'components' => [
            [
                'id'  => 3720,
                'qty' => 1,
            ],
            [
                'id'  => 3728,
                'qty' => 1,
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/bundles', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Coffee lover set', price: '39.00', sku: 'SET-COFFEE', components: [{ id: 3720, qty: 1 }, { id: 3728, qty: 1 }] }),
});
const { data } = await response.json();

Quick Links

Share