commercetools

Why the default shipping method doesn't apply to the cart?


I have a question about shipping addresses in cart. In cart documentation describes that the shipping method is used to determine eligible shipping method. Bu when I set shipping address to cart like this:

    final CartDraft draft = CartDraftBuilder
                .of(DefaultCurrencyUnits.USD)
                .customerId(customer.getId())
//                .shippingMethod(shippingMethod)
                .shippingAddress(Address.of(CountryCode.US))
                .build();

In my order I do not have price from shipping method(default shipping method). But if I uncommented shipping method line and set to it default shipping method which I've got by this way:

return client.execute(ShippingMethodQuery.of().byIsDefault()).toCompletableFuture().get().getResults().get(0);

Here is how my default shipping method looks:

enter image description here

Is that means that I should set shipping method manually by myself? Or what is this problem? For what the default shipping method used for?


Solution

  • Based on what you've described, yes, you will still have to enter the shipping method manually. The "default" setting on a shipping method is a boolean that places a flag on the shipping method. This is helpful in the Merchant Center when you are creating an order because it will default to the chosen shipping address as you are going through the steps to place an order.

    Does this help?

    Best Regards, Michael