Project

General

Profile

API - Shopping - Cart

Add products to cart

URL: /shopping/add-to-cart/
Method: POST

Code sample:

$api_id = 1;
$api_key = 'testpass';
$hostname = 'https://example.com'; // no trailing slash

# fetch data
$url = '/shopping/add-to-cart/';
$post_data = array(
    'products' => array(
        array(
            'id' => 95449,
            'qty' => 1,
            'gchars' => array(17, 499)
        )
    )
);
$user_token = 'xxx'; // is required here. Get it from Your DB after Token generation
$extra_headers = array(
    'X-API-ID: ' . $api_id,
    'X-API-Hash: ' . md5($api_key . $url. http_build_query($post_data)),
    'X-User-Token: ' . $user_token
);

header('Content-Type: application/json; charset=utf-8');
echo sendRequest($hostname . $url, $post_data, $extra_headers);

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {
        products: {
            95449: [
                {
                    id: "2261442",
                    qty: "2",
                    gchars: [
                        "499",
                        "17" 
                    ],
                    warranty_id: null,
                    resealed_id: null,
                    bundle_for: null,
                    configurator_data: [ ],
                    parts_data: [ ]
                }
            ]
        },
        info: {
            created: "2021-03-08 16:45:59",
            last_updated: "2021-03-08 16:46:36",
            notify_time: null,
            diff_updated: "0" 
        },
        id: 762260,
        productcount: 1,
        total: "121,58",
        total_notax_unformatted: "127.72",
        total_unformatted: "121.58" 
    }
}

Delete products from cart

URL: /shopping/delete-from-cart/2261442/
Method: GET

Code sample:

...
$url = '/shopping/delete-from-cart/2261442/';
$post_data = array();
...

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {
        products: [ ],
        info: {
            created: "2021-03-08 16:45:59",
            last_updated: "2021-03-08 16:50:52",
            notify_time: null,
            diff_updated: "2" 
        },
        id: null,
        productcount: 0,
        total: "0,00",
        total_notax_unformatted: "0.00",
        total_unformatted: "0.00" 
    }
}

Error message:

{
    has_error: true,
    messages: [
        "Product not found" 
    ],
    results: [ ]
}

Get cart info

URL: /shopping/cart/
Method: GET

Code sample:

...
$url = '/shopping/cart/';
$post_data = array();
...

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {}
}

Update cart

URL: /shopping/cart/
Method: POST

products is a multi-dimensional array with cart product ID as a key, and product ID as value

Code sample:

...
$url = '/shopping/cart/';
$post_data = array(
    'products' => array(
        '2261443' => array(
            'id' => 95449,
            'qty' => 3,
            'gchars' => array(17, 499),
            'warranty_extension' => 1234
        )
    ),
    'voucher' => '',
    'confirm_use_points' => 0,
    'used_points' => 10
);
...

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {}
}

Error message:

{
    has_error: true,
    messages: [
        "Voucher-ul a fost valabil valabil pana la data de 25.09.2014 23:59" 
    ],
    results: [ ]
}

Delete points

URL: /shopping/cart/?delete-points
Method: GET

Code sample:

...
$url = '/shopping/cart/?delete-points';
$post_data = array();
...

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {
        request_status: "ok",
        request_message: "" 
    }
}

Delete voucher

URL: /shopping/cart/?delete-voucher
Method: GET

Code sample:

...
$url = '/shopping/cart/?delete-voucher';
$post_data = array();
...

Succes message:

{
    has_error: false,
    messages: [ ],
    results: {
        request_status: "ok",
        request_message: "" 
    }
}

Go to top