User Tools

Site Tools


udropship:umarketplace:m2:split-rate-api

uMarketplace Split-Rate add-on API

Introduction

Split-rate add-on customizes magento native checkout API to produce data in a bit different format to match specifics of split-rate cart functionality. The add-on gives functionality to a customer to select different shipping method per vendor. Customer cart can contain products from multiple vendors. Each group of products that belongs to a different vendor can have a separate shipping method assigned that will be later used in order fulfillment. The list of customized APIs

  • /V1/carts/mine/estimate-shipping-methods
  • /V1/carts/mine/estimate-shipping-methods-by-address-id
  • /V1/guest-carts/:cartId/estimate-shipping-methods
  • /V1/guest-carts/:cartId/shipping-information
  • /V1/carts/mine/shipping-information
  • /V1/carts/:cartId/shipping-information
  • /V1/carts/:cartId/totals-information
  • /V1/guest-carts/:cartId/totals-information
  • /V1/carts/mine/totals-information

Estimate guest cart shipping

If you check results of this API call you will notice a presence of udropship_vendor, vendor_id, udropship_default fields.
vendor_id - reference id of the vendor that this item relates to.
udropship_default - indicates if this method selected by default or using previos calls to /V1/guest-carts/:cartId/shipping-information or /V1/guest-carts/:cartId/totals-information
Item needs to be treated differently depending on udropship_vendor field value:
udropship_vendor=0 - should be skipped. normaly it's a system carrier method that not used in per vendor shipping
udropship_vendor=-1 - special item that holds vendor information for the following results with udropship_vendor=“vendor_id of this item”
udropship_vendor⇒0 - reference id of the vendor that this shipping method belongs to
Example:

POST /rest/default/V1/guest-carts/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/estimate-shipping-methods
{"address":{"region_id":"12","region":"California","country_id":"US","postcode":"90210"}}

RESPONSE

[{
    "udropship_vendor": "0",
    "udropship_default": null,
    "vendor_id": null,
    "carrier_code": "udsplit",
    "method_code": "total",
    "carrier_title": "Drop Shipping (Split)",
    "method_title": "Total",
    "amount": 11.71,
    "base_amount": 11.71,
    "available": true,
    "error_message": "",
    "price_excl_tax": 11.71,
    "price_incl_tax": 11.71
}, {
    "udropship_vendor": "-1",
    "udropship_default": null,
    "vendor_id": "1",
    "carrier_code": null,
    "method_code": null,
    "carrier_title": "vendor1",
    "method_title": "los angeles, US CA",
    "amount": null,
    "base_amount": null,
    "available": null,
    "error_message": null,
    "price_excl_tax": null,
    "price_incl_tax": null
}, {
    "udropship_vendor": "1",
    "udropship_default": "1",
    "vendor_id": "1",
    "carrier_code": "fedex",
    "method_code": "FEDEX_GROUND",
    "carrier_title": "Federal Express",
    "method_title": "Ground",
    "amount": 0,
    "base_amount": 0,
    "available": true,
    "error_message": "",
    "price_excl_tax": 0,
    "price_incl_tax": 0
}, {
    "udropship_vendor": "1",
    "udropship_default": "0",
    "vendor_id": "1",
    "carrier_code": "fedex",
    "method_code": "FEDEX_2_DAY",
    "carrier_title": "Federal Express",
    "method_title": "2 Day",
    "amount": 19.59,
    "base_amount": 19.59,
    "available": true,
    "error_message": "",
    "price_excl_tax": 19.59,
    "price_incl_tax": 19.59
}, {
    "udropship_vendor": "1",
    "udropship_default": "0",
    "vendor_id": "1",
    "carrier_code": "fedex",
    "method_code": "PRIORITY_OVERNIGHT",
    "carrier_title": "Federal Express",
    "method_title": "Priority Overnight",
    "amount": 25.26,
    "base_amount": 25.26,
    "available": true,
    "error_message": "",
    "price_excl_tax": 25.26,
    "price_incl_tax": 25.26
}, {
    "udropship_vendor": "-1",
    "udropship_default": null,
    "vendor_id": "2",
    "carrier_code": null,
    "method_code": null,
    "carrier_title": "vendor2",
    "method_title": "rome, US GA",
    "amount": null,
    "base_amount": null,
    "available": null,
    "error_message": null,
    "price_excl_tax": null,
    "price_incl_tax": null
}, {
    "udropship_vendor": "2",
    "udropship_default": "1",
    "vendor_id": "2",
    "carrier_code": "ups",
    "method_code": "03",
    "carrier_title": "United Parcel Service",
    "method_title": "UPS Ground",
    "amount": 11.71,
    "base_amount": 11.71,
    "available": true,
    "error_message": "",
    "price_excl_tax": 11.71,
    "price_incl_tax": 11.71
}, {
    "udropship_vendor": "2",
    "udropship_default": "0",
    "vendor_id": "2",
    "carrier_code": "ups",
    "method_code": "02",
    "carrier_title": "United Parcel Service",
    "method_title": "UPS Second Day Air",
    "amount": 36.3,
    "base_amount": 36.3,
    "available": true,
    "error_message": "",
    "price_excl_tax": 36.3,
    "price_incl_tax": 36.3
}]

Save guest cart totals

Guest cart totals information save uses customized request.
In request we add shipping_method_all field which holds per vendor selection of shipping methods

Example:

POST /rest/default/V1/guest-carts/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/totals-information
{"addressinformation": {
    "address": {"countryid": "us", "region": "california", "regionid": "12", "postcode": "90210"},
    "shipping_method_code": "total",
    "shipping_carrier_code": "udsplit",
    "shipping_method_all": {
        "0": {
            "udropship_vendor": "0",
            "udropship_default": null,
            "vendor_id": null,
            "carrier_code": "udsplit",
            "method_code": "total",
            "carrier_title": "drop shipping (split)",
            "method_title": "total",
            "amount": 31.3,
            "base_amount": 31.3,
            "available": true,
            "error_message": "",
            "price_excl_tax": 31.3,
            "price_incl_tax": 31.3
        },
        "1": {
            "udropship_vendor": "1",
            "udropship_default": "0",
            "vendor_id": "1",
            "carrier_code": "fedex",
            "method_code": "fedex_2_day",
            "carrier_title": "federal express",
            "method_title": "2 day",
            "amount": 19.59,
            "base_amount": 19.59,
            "available": true,
            "error_message": "",
            "price_excl_tax": 19.59,
            "price_incl_tax": 19.59
        },
        "2": {
            "udropship_vendor": "2",
            "udropship_default": "1",
            "vendor_id": "2",
            "carrier_code": "ups",
            "method_code": "03",
            "carrier_title": "united parcel service",
            "method_title": "ups ground",
            "amount": 11.71,
            "base_amount": 11.71,
            "available": true,
            "error_message": "",
            "price_excl_tax": 11.71,
            "price_incl_tax": 11.71
        }
    }
}}

RESPONSE

{
    "grand_total": 133.19,
    "base_grand_total": 133.19,
    "subtotal": 101.89,
    "base_subtotal": 101.89,
    "discount_amount": 0,
    "base_discount_amount": 0,
    "subtotal_with_discount": 101.89,
    "base_subtotal_with_discount": 101.89,
    "shipping_amount": 31.3,
    "base_shipping_amount": 31.3,
    "shipping_discount_amount": 0,
    "base_shipping_discount_amount": 0,
    "tax_amount": 0,
    "base_tax_amount": 0,
    "weee_tax_applied_amount": null,
    "shipping_tax_amount": 0,
    "base_shipping_tax_amount": 0,
    "subtotal_incl_tax": 101.89,
    "base_subtotal_incl_tax": 101.89,
    "shipping_incl_tax": 31.3,
    "base_shipping_incl_tax": 31.3,
    "base_currency_code": "USD",
    "quote_currency_code": "USD",
    "items_qty": 2,
    "items": [{
        "item_id": 6,
        "price": 52.62,
        "base_price": 52.62,
        "qty": 1,
        "row_total": 52.62,
        "base_row_total": 52.62,
        "row_total_with_discount": 0,
        "tax_amount": 0,
        "base_tax_amount": 0,
        "tax_percent": 0,
        "discount_amount": 0,
        "base_discount_amount": 0,
        "discount_percent": 0,
        "price_incl_tax": 52.62,
        "base_price_incl_tax": 52.62,
        "row_total_incl_tax": 52.62,
        "base_row_total_incl_tax": 52.62,
        "options": "[{\"value\":\"vendor1\",\"label\":\"Vendor\"}]",
        "weee_tax_applied_amount": null,
        "weee_tax_applied": null,
        "name": "Overnight Duffle"
    }, {
        "item_id": 7,
        "price": 49.27,
        "base_price": 49.27,
        "qty": 1,
        "row_total": 49.27,
        "base_row_total": 49.27,
        "row_total_with_discount": 0,
        "tax_amount": 0,
        "base_tax_amount": 0,
        "tax_percent": 0,
        "discount_amount": 0,
        "base_discount_amount": 0,
        "discount_percent": 0,
        "price_incl_tax": 49.27,
        "base_price_incl_tax": 49.27,
        "row_total_incl_tax": 49.27,
        "base_row_total_incl_tax": 49.27,
        "options": "[{\"value\":\"vendor2\",\"label\":\"Vendor\"}]",
        "weee_tax_applied_amount": null,
        "weee_tax_applied": null,
        "name": "Push It Messenger Bag"
    }],
    "total_segments": [{"code": "subtotal", "title": "Subtotal", "value": 101.89}, {
        "code": "shipping",
        "title": "Shipping & Handling (Drop Shipping (Split) - Total)",
        "value": 31.3
    }, {
        "code": "tax",
        "title": "Tax",
        "value": 0,
        "extension_attributes": {"tax_grandtotal_details": []}
    }, {"code": "grand_total", "title": "Grand Total", "value": 133.19, "area": "footer"}]
}

Save guest cart shipping information

This request has a customized field shipping_method_all.

Example:

POST /rest/default/V1/guest-carts/f742mL2qWS9ksO9vyadhoLNJoA61A5GW/shipping-information
{
    "addressInformation": {
        "shipping_address": {
            "countryId": "US",
            "regionId": "12",
            "regionCode": "CA",
            "region": "California",
            "street": ["test"],
            "company": "",
            "telephone": "911",
            "postcode": "90210",
            "city": "Los Angeles",
            "firstname": "test",
            "lastname": "test"
        },
        "billing_address": {
            "countryId": "US",
            "regionId": "12",
            "regionCode": "CA",
            "region": "California",
            "street": ["test"],
            "company": "",
            "telephone": "911",
            "postcode": "90210",
            "city": "Los Angeles",
            "firstname": "test",
            "lastname": "test",
            "saveInAddressBook": null
        },
        "shipping_method_code": "total",
        "shipping_carrier_code": "udsplit",
        "shipping_method_all": {
            "0": {
                "udropship_vendor": "0",
                "udropship_default": null,
                "vendor_id": null,
                "carrier_code": "udsplit",
                "method_code": "total",
                "carrier_title": "Drop Shipping (Split)",
                "method_title": "Total",
                "amount": 31.3,
                "base_amount": 31.3,
                "available": true,
                "error_message": "",
                "price_excl_tax": 31.3,
                "price_incl_tax": 31.3
            },
            "1": {
                "udropship_vendor": "1",
                "udropship_default": "0",
                "vendor_id": "1",
                "carrier_code": "fedex",
                "method_code": "FEDEX_2_DAY",
                "carrier_title": "Federal Express",
                "method_title": "2 Day",
                "amount": 19.59,
                "base_amount": 19.59,
                "available": true,
                "error_message": "",
                "price_excl_tax": 19.59,
                "price_incl_tax": 19.59
            },
            "2": {
                "udropship_vendor": "2",
                "udropship_default": "1",
                "vendor_id": "2",
                "carrier_code": "ups",
                "method_code": "03",
                "carrier_title": "United Parcel Service",
                "method_title": "UPS Ground",
                "amount": 11.71,
                "base_amount": 11.71,
                "available": true,
                "error_message": "",
                "price_excl_tax": 11.71,
                "price_incl_tax": 11.71
            }
        }
    }
}

RESPONSE

{
    "payment_methods": [{"code": "checkmo", "title": "Check \/ Money order"}], "totals": {
        "grand_total": 133.19,
        "base_grand_total": 133.19,
        "subtotal": 101.89,
        "base_subtotal": 101.89,
        "discount_amount": 0,
        "base_discount_amount": 0,
        "subtotal_with_discount": 101.89,
        "base_subtotal_with_discount": 101.89,
        "shipping_amount": 31.3,
        "base_shipping_amount": 31.3,
        "shipping_discount_amount": 0,
        "base_shipping_discount_amount": 0,
        "tax_amount": 0,
        "base_tax_amount": 0,
        "weee_tax_applied_amount": null,
        "shipping_tax_amount": 0,
        "base_shipping_tax_amount": 0,
        "subtotal_incl_tax": 101.89,
        "base_subtotal_incl_tax": 101.89,
        "shipping_incl_tax": 31.3,
        "base_shipping_incl_tax": 31.3,
        "base_currency_code": "USD",
        "quote_currency_code": "USD",
        "items_qty": 2,
        "items": [{
            "item_id": 6,
            "price": 52.62,
            "base_price": 52.62,
            "qty": 1,
            "row_total": 52.62,
            "base_row_total": 52.62,
            "row_total_with_discount": 0,
            "tax_amount": 0,
            "base_tax_amount": 0,
            "tax_percent": 0,
            "discount_amount": 0,
            "base_discount_amount": 0,
            "discount_percent": 0,
            "price_incl_tax": 52.62,
            "base_price_incl_tax": 52.62,
            "row_total_incl_tax": 52.62,
            "base_row_total_incl_tax": 52.62,
            "options": "[{\"value\":\"vendor1\",\"label\":\"Vendor\"}]",
            "weee_tax_applied_amount": null,
            "weee_tax_applied": null,
            "name": "Overnight Duffle"
        }, {
            "item_id": 7,
            "price": 49.27,
            "base_price": 49.27,
            "qty": 1,
            "row_total": 49.27,
            "base_row_total": 49.27,
            "row_total_with_discount": 0,
            "tax_amount": 0,
            "base_tax_amount": 0,
            "tax_percent": 0,
            "discount_amount": 0,
            "base_discount_amount": 0,
            "discount_percent": 0,
            "price_incl_tax": 49.27,
            "base_price_incl_tax": 49.27,
            "row_total_incl_tax": 49.27,
            "base_row_total_incl_tax": 49.27,
            "options": "[{\"value\":\"vendor2\",\"label\":\"Vendor\"}]",
            "weee_tax_applied_amount": null,
            "weee_tax_applied": null,
            "name": "Push It Messenger Bag"
        }],
        "total_segments": [{"code": "subtotal", "title": "Subtotal", "value": 101.89}, {
            "code": "shipping",
            "title": "Shipping & Handling (Drop Shipping (Split) - Total)",
            "value": 31.3
        }, {
            "code": "tax",
            "title": "Tax",
            "value": 0,
            "extension_attributes": {"tax_grandtotal_details": []}
        }, {"code": "grand_total", "title": "Grand Total", "value": 133.19, "area": "footer"}]
    }
}

Logged in customers

Logged in customers checkout requests use the same approach just different endpoints and different original format.

udropship/umarketplace/m2/split-rate-api.txt · Last modified: 2019/10/23 22:04 by wtsergo