Retrieve shipping price
Use getShippingPrice to retrieve the shipping method and price available, based on a current cart configuration. This API call returns the available shipping methods defined in your Control Panel, together with the fees you configured based on order total amount/ weight/ country.
Requirements
It's mandatory to have tangible products defined in your Control Panel, to retrieve shipping method and price information.
Request parameters
Items
Required (object)
Contains information on the tangible product added in cart.
Items.Code
Required (string)
Product code defined in the Information tab from the Product level, in the Control Panel.
Items.Quantity
Optional (integer)
Quantity of the product that is being purchased. Default value is 1.
BillingDetails
Required (object)
Contains customer billing information.
BillingDetails.CountryCode
Required (string)
Two-digits code of customer billing country. Example: 'US'.
DeliveryDetails
Required (object)
Contains customer delivery information.
DeliveryDetails.CountryCode
Required (string)
Two-digits code of customer delivery country. Example: 'US'.
Currency
Optional (string)
Three-digits code of purchase currency. Example: 'USD'.
CouponCodes
Optional (array of strings)
Discount codes that can be applied to the purchase.
Sample request
<?php
require ('PATH_TO_AUTH'); // authentication call
$cartItems = [];
$cartItem = new stdClass();
$cartItem->Code = 'my_product_code_1'; // product code defined in the Information tab, at product level
$cartItem->Quantity = 2; // quantity that is being purchased
$cartItems[0] = $cartItem;
$billingDetails = new stdClass();
$billingDetails->CountryCode = 'US'; // billing country
$deliveryDetails = new stdClass();
$deliveryDetails->CountryCode = 'AU'; // delivery country
$currency = 'USD'; // purchase currency
$couponCode = ['TANGIBLEPROMO']; // apply discount to promotion
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getShippingPrice';
$jsonRpcRequest->params = array($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
$jsonRpcRequest->id = $i++;
$getShippingPrice = callRPC($jsonRpcRequest, $host);Response parameters
Object
This method returns an object, containing the shipping price available for a certain cart configuration.
Last updated
Was this helpful?