If you use CS-Cart:

You can use the CS-Cart API Add-on to synchronize orders.

To do this:

1. Install the add-on from the CS-Cart repository.

2. Set the login and Marketplace API key in the settings.

3. Make sure that the value in config.php is standard ('marketplace_url' 'https://marketplace.cs-cart.com').

4. Create a test_addon.php file in the store root with the following content:

<?php
use Tygh\Addons\MarketplaceOrderSync\Collections\ProductCollection;
use Tygh\Addons\MarketplaceOrderSync\DataTransferObjects\Customer;
use Tygh\Addons\MarketplaceOrderSync\DataTransferObjects\License;
use Tygh\Addons\MarketplaceOrderSync\DataTransferObjects\Order;
use Tygh\Addons\MarketplaceOrderSync\DataTransferObjects\Product;
use Tygh\Addons\MarketplaceOrderSync\ServiceProvider;
define('AREA', 'C');
try {
    require(dirname(__FILE__) . '/init.php');
    $service = ServiceProvider::getService();
    $order_id = $service->registerOrder(
        new Order(
            new Customer(
                '{customer's email}',
                '{customer's first name}',
                '{customer's last name}',
                '{customer's phone number}'
            ),
            new ProductCollection(
                [
                    new Product(
                        '{External ID of a product}',
                        {number of products},
                        new License(new DateTimeImmutable('{license expiration date}'))
                        ),
                ]
            )
        )
    );
    echo 'Created order ID:' . $order_id;
    die;
} catch (Exception $e) {
    \Tygh\Tools\ErrorHandler::handleException($e);
} catch (Throwable $e) {
    \Tygh\Tools\ErrorHandler::handleException($e);
}

5. Open http://your_domain/test_addon.php.

6. If the product’s External ID, login and API key are correct, you will see the order’s ID. Otherwise, the code will throw an exception: 

  • Incorrect product ID — ProductNotFoundException. 
  • Incorrect API key — NotAuthorizedException. 
  • External orders synchronization is not active — OrderPlacementNotAllowedException. 

7. Fill in the customer notes. Specify the product name, quantity and total.

8. Do not forget to check that the data in the order created on the Marketplace matches the data that was passed. 

If you use other platforms:

To add an order created outside of the Marketplace, you need to send a POST request:

POST https://marketplace.cs-cart.com/api/2.1/external_orders/
Content-Type: application/json
Authorization: Basic {vendor login} {api key}

{
"products": [
{
"external_id": "{❗️ external ID of a vendor's product}",
"license": {
"expires_on": "{❗️ license expiration date in the YYYY-MM-DD format}",
"domain": "{domain}"
}
}
],
"customer": {
"email": "{❗️ customer's email}",
"first_name": "{❗️ customer's first name}",
"last_name": "{❗️ customer's second name}",
"phone_number": "{phone number}"
},
"reset_order_total": {1 — make the order's total equal to 0, 0 — calculate the order's total}
}

❗️ — required parameters.

Please note:

  • You cannot synchronize the order if it does not have products and customer parameters.
  • An order without products[].license cannot be synchronized.
  • API returns an error report if you pass an invalid date instead of products[].licence.expires_on.
  • If reset_order_total = 0, order total is calculated correctly (if it is equal to 1, the order total is 0, and fees are not charged).
  • If the global option named BaseDomainOption is linked to a product, the passed domain is saved in the order.
  • You cannot use an external ID of other vendors.
  • If you pass a registered user's email, the order is linked to that user.
  • When passing an unregistered user's email, a new user is created.
  • Email notifications are not sent when synchronizing orders.
  • An issued license expires at the time specified in expires_on.