Skip to main content

Box Now

Integrate Box Now for Custom Integrations

If you are using one of our officially supported plugins in tandem with the official Box Now plugin for your platform, the Box Now shipping method will be auto-discovered and you don't need to do anything on your side to support it.

If, on the other hand, you are implementing the Simpler API for an unsupported platform, or you are on a supported platform but you are not using a supported Box Now plugin, you will need to slightly extend your integration to take Box Now into account.

The Box Now integration is handled in two parts :

  • Retrieving the Box Now shipping method as a Box Now quote.
  • Retrieving the selected locker once the order has been submitted.

Retrieving the Box Now shipping method

When iterating the quotes for each shipping method, you will need to intercept the Box Now shipping method quote and change the shipping.type field to BOX_NOW so that the Checkout Window will be able to render the Locker selection widget.

function buildQuote($cart, $shipping_method) {
$quote = buildQuoteFromCart($cart) // build the base quote (cart contents, prices etc)
$quote['shipping_option'] = [
'id' => $shipping_method->getId(),
'name' => $shipping_method->getTitle(),
'total_cents' => $shipping_method->getCostCents(),
'type' => $shipping_method->isBoxNow() ? 'BOX_NOW' : 'DELIVERY'
];
return $quote;
}

Retrieving the selected locker once the order has been submitted

When the user has selected a locker, you will find all relevant information in the box_now field of the order payload.

function saveOrder($request) {
$order = buildOrderFromPayload($request);
if (isset($request['box_now'])) {
$order->setBoxNowLockerId($request['box_now']['locker_id']);
}
}