AOEpeople/Aoe_CartApi

Name: Aoe_CartApi

Owner: AOE

Description: More resources for Magento's Api2 (REST)

Created: 2015-06-18 05:23:01.0

Updated: 2017-09-18 01:41:29.0

Pushed: 2017-07-10 21:33:41.0

Homepage: null

Size: 230

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

AOE

Aoe_CartApi Magento Module Build Status

NOTE: This module is NOT ready for public consuption. Once it is ready we will tag a 1.0.0 version.

NOTE: Following “documentation” is just a dump of some notes while planning this API.

Primary cart API endpoints
GET /api/rest/cart

Return the cart (quote) for the current frontend Magento session

{
    "email": "fake@example.com",
    "coupon_code": "",
    "shipping_method": "flatrate_flatrate",
    "qty": 5,
    "totals": {
        "subtotal": {
            "title": "Subtotal",
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "shipping": {
            "title": "Shipping",
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "discount": {
            "title": "Discount"
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "tax": {
            "title": "Tax",
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "grand_total": {
            "title": "Grand Total",
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        }
    },
    "messages": {
        "error": [
            "error message #1",
            "error message #2"
        ]
        "notice": [
            "notice message #1",
            "notice message #2"
        ]
        "success": [
            "success message #1",
            "success message #2"
        ]
    },
    "has_error": false
}

Supported query parameters

POST /api/rest/cart

Update attributes of the cart resource. Using the 'embed' query parameter will allow updating of a limited subset of sub-resources as well.

{
    "coupon_code": "FREESTUFF"
}

Supported query parameters

DELETE /api/rest/cart

Reset the cart and all sub-resources

GET /api/rest/cart/items

Get collection of cart items. This will always return a JS object as result, even if the collection is empty.

{
    "139303": {
        "item_id": 139303,
        "sku": "ABC123",
        "name": "Thing #1",
        "images": {
            "normal": "<url>",
            "small": "<url>",
            "thumbnail": "<url>",
        },
        "children": []
        "qty": 5,
        "backorder_qty": 5,
        "original_price": {
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "price": {
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "row_total": {
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "error_info": {},
        "is_saleable": true
    }
}

Supported query parameters

POST /api/rest/cart/items

Add an product to the cart. This will re-use existing items in the cart if possible. The qty attribute is optional and will default to a single unit.

{
    "sku": "ABC123"
    "qty": 1
}

You can also post multiple items at once using the items parameter. If you are using items then sku and qty will not have any effect.

{
     "items": [
       {sku:"ABC123", qty:"2"}, 
       {sku:"ABC456", qty:"4"}
     }
}

Supported query parameters

DELETE /api/rest/cart/items

Remove all items from the cart

GET /api/rest/cart/items/:item_id

Get a specific cart item

{
    "item_id": 139303,
    "sku": "ABC123",
    "name": "Thing #1",
    "images": {
        "normal": "<url>",
        "small": "<url>",
        "thumbnail": "<url>",
    },
    "children": []
    "qty": 5,
    "backorder_qty": 5,
    "original_price": {
        "formatted": "$0.00",
        "amount": 0,
        "currency": "USD"
    },
    "price": {
        "formatted": "$0.00",
        "amount": 0,
        "currency": "USD"
    },
    "row_total": {
        "formatted": "$0.00",
        "amount": 0,
        "currency": "USD"
    },
    "error_info": {},
    "is_saleable": true
}

Supported query parameters

PUT/POST /api/rest/cart/items/:item_id

Update the quantity for an item in the cart

{
    "qty": 4
}

Supported query parameters

DELETE /api/rest/cart/items/:item_id

Remove an item from the cart

GET /api/rest/cart/billing_address

Return the billing address linked to the cart

{
    "firstname": "John",
    "middlename": "Quincy",
    "lastname": "Public",
    "prefix": "Mr.",
    "suffix": "Jr.",
    "company": "Acme Inc.",
    "street":[
        "Street 1",
        "Street 2"
    ],
    "city": "Burlingame",
    "region": "California",
    "postcode": "00000",
    "country_id": "US",
    "telephone": "000-000-0000",
    "validation_errors":[
        "Error Text",
        "Error Text"
    ]
}

Supported query parameters

PUT/POST /api/rest/cart/billing_address

Update the billing address. All attributes are optional.

Regions are a bit of 'magic'. You can send the Mage_Directory DB ID, The region 'code', or the region 'name'. The code and name are looked up in relation to the currently selected country. The stored region is either the valid region name (looked up by ID/Code/Name) or the value sent as-is.

{
    "region": "FL"
}

Supported query parameters

DELETE /api/rest/cart/billing_address

Reset the billing address

GET /api/rest/cart/shipping_address

Return the shipping address linked to the cart

{
    "firstname": "John",
    "middlename": "Quincy",
    "lastname": "Public",
    "prefix": "Mr.",
    "suffix": "Jr.",
    "company": "Acme Inc.",
    "street":[
        "Street 1",
        "Street 2"
    ],
    "city": "Burlingame",
    "region": "California",
    "postcode": "00000",
    "country_id": "US",
    "telephone": "000-000-0000",
    "validation_errors":[
        "Error Text",
        "Error Text"
    ]
}

Supported query parameters

PUT/POST /api/rest/cart/shipping_address

Update the shipping address All attributes are optional.

Regions are a bit of 'magic'. You can send the Mage_Directory DB ID, The region 'code', or the region 'name'. The code and name are looked up in relation to the currently selected country. The stored region is either the valid region name (looked up by ID/Code/Name) or the value sent as-is.

{
    "region": "FL"
}

Supported query parameters

DELETE /api/rest/cart/shipping_address

Reset the shipping address

Additional cart related resources
GET /api/rest/cart/crosssells

Return a collection of crosssell products. NOTE: This collection changes as the cart data changes.

{
    "000-000": {
        "sku": "000-000"
        "name": "Dummy Product",
        "description": "Dummy Product",
        "short_description": "Dummy Product",
        "url": "<url>",
        "images": {
            "normal": "<url>",
            "small": "<url>",
            "thumbnail": "<url>",
        },
        "is_in_stock": true,
        "price": {
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "final_price": {
            "formatted": "$0.00",
            "amount": 0,
            "currency": "USD"
        },
        "is_saleable": true,
        "qty": 10000,
        "min_sale_qty": null,
        "max_sale_qty": 100
    }
}

Supported query parameters

GET /api/rest/cart/shipping_methods

Return a collection of available shipping methods. NOTE: This collection changes as the cart data changes.

[
    {
        "code": "flaterate_flaterate"
        "carrier": "flaterate"
        "carrier_title": "Flat Rate"
        "method": "flaterate"
        "method_title": "Flat Rate"
        "description": "Flat rate shipping"
        "price": {
            "formatted": "$0.00"
            "currency": "USD",
            "amount": 0,
        }
    }
]

Supported query parameters

GET /api/rest/cart/payment_methods

Return a collection of available payment methods. NOTE: This collection changes as the cart data changes and depends on the store configuration.

[
    {
        "code": "braintree",
        "title": "Credit Card ",
        "cc_types": {
            "AE": "American Express",
            "VI": "Visa",
            "MC": "MasterCard"
           }
    },
    {
        "code": "checkmo",
        "title": "Check / Money order",
        "cc_types": null
    }

]

NOTES

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.