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

Parameter
Type / Description

Items

Object / Required Contains information on the tangible product added in cart.

Items.Code

String / Required

Product code defined in the Information tab from the Product level, in the Control Panel.

Items.Quantity

Integer / Optional

Quantity of the product that is being purchased.

Default value is 1.

BillingDetails

Object / Required Contains customer billing information.

BillingDetails.CountryCode

CoString / Required

Two-digits code of customer billing country. Example: 'US'.untryCode

DeliveryDetails

Object / Required Contains customer delivery information.

DeliveryDetails.CountryCode

String / Required

Two-digits code of customer delivery country. Example: 'US'.

Currency

String / Optional Three-digits code of purchase currency. Example: 'USD'.

CouponCodes

Array of strings / Optional 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

try {
    $shippingPrice = $client->getShippingPrice($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
}
catch (SoapFault $e) {
    echo "ShippingPrice: " . $e->getMessage();
    exit;
}
var_dump("ShippingPrice", $shippingPrice);

Response parameters

Parameter
Type / Description

Object This method returns an object containing the shipping price available for a certain cart configuration.

Last updated

Was this helpful?