Free shipping

It is possible to activate a free shipping threshold in the Jetshop admin, under Settings>Countries>Country settings. This setting can waive shipping costs for the customer once the sum of their cart reaches a defined threshold.

The Flight framework includes a custom hook that can be used to determine whether the user's cart is above this threshold, and if not, how much more needs to be spent in order to meet it.

useFreeShippingCheck

The useFreeShippingCheck hook takes an options argument with a single key — cartTotal:

interface cartTotal {
  exVat: number;
  incVat: number;
  vat: number;
}

and returns an object:

{
    freeShippingConfigured: boolean;
    hasMetLimit: boolean;
    untilLimit: {
        incVat: number;
        exVat: number;
    }
}

freeShippingConfigured: boolean

If free shipping has not been set up for the store, this will be false, otherwise it will be true.

hasMetLimit: boolean

Whether the given cartTotal has met the limit for free shipping as defined in the admin.

untilLimit: { incVat: number; exVat: number }

An object containing the amount left until the user meets the free shipping limit including VAT and excluding VAT. Most useful in conjunction with the Price component.

Example usage

Copy
Copied
function FreeShipping({ cartTotal }) {
  const { hasMetLimit, untilLimit, freeShippingConfigured } =
    useFreeShippingCheck({
      cartTotal,
    });

  if (!freeShippingConfigured) return null;

  if (hasMetLimit) {
    return <div>You have met the limit for free shipping!</div>;
  }

  return (
    <div>
      Spend <Price price={untilLimit} /> to qualify for free shipping
    </div>
  );
}
Copyright © Norce 2023. All right reserved.