public final class SetShippingAddress extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
final Cart cart = createCartWithCountry(client());
assertThat(cart.getShippingAddress()).isNull();
final Address address = AddressBuilder.of(DE).build();
final Cart cartWithAddress = client().executeBlocking(CartUpdateCommand.of(cart, SetShippingAddress.of(address)));
assertThat(cartWithAddress.getShippingAddress()).isEqualTo(address);
//you can query by shippingAddress fields
final CartQuery query = CartQuery.of()
.withPredicates(m -> m.shippingAddress().country().is(DE).and(m.id().is(cart.getId())));
assertThat(client().executeBlocking(query).head()).contains(cartWithAddress);
final Cart cartWithoutAddress = client().executeBlocking(CartUpdateCommand.of(cartWithAddress, SetShippingAddress.of(null)));
assertThat(cartWithoutAddress.getShippingAddress()).isNull();
See the test code.
Modifier and Type | Method and Description |
---|---|
Address |
getAddress() |
static SetShippingAddress |
of(Address address) |
getAction
public static SetShippingAddress of(@Nullable Address address)