# ngauge-cart

NGauge Cart Extension — adds API-based cart and EDI order creation to NGauge.

## Installation

Add to your project's `composer.json`:

```json
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://dev.azure.com/PortalPeopleUK/NGauge_Modules/_git/ngauge-cart"
        }
    ],
    "require": {
        "portalpeople/ngauge-cart": "^1.0"
    }
}
```

## Configuration

In your Yii2 app config:

```php
'bootstrap' => ['cart'],
'modules' => [
    'cart' => [
        'class' => \PortalPeople\cart\Module::class,
    ],
],
```

## API

### POST `/api/cart/order/create`

Creates a cart and order from an EDI/API payload.

**Single order:**
```json
{
    "deliveryCustomerCode": "CUST001",
    "orderNumber": "EDI-001",
    "deliveryDate": "2026-06-01",
    "contactName": "John Doe",
    "contactEmail": "john@example.com",
    "lines": [
        { "stockCode": "PROD001", "qty": 5, "price": 10.00, "product": "Product Name" }
    ]
}
```

**Multiple orders:** wrap in a JSON array `[{...}, {...}]`.

## Usage in PHP

```php
use PortalPeople\cart\models\Cart;

$result = Cart::fromApi($orderData);
```
