public final class SetCustomShippingMethod extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
withTaxCategory(client(), taxCategory -> {
final Cart cart = createCartWithShippingAddress(client());
assertThat(cart.getShippingInfo()).isNull();
final MonetaryAmount price = MoneyImpl.of(new BigDecimal("23.50"), EUR);
final ShippingRate shippingRate = ShippingRate.of(price, null, Collections.emptyList());
final String shippingMethodName = "custom-shipping";
final SetCustomShippingMethod action = SetCustomShippingMethod.of(shippingMethodName, shippingRate, taxCategory);
final Cart cartWithShippingMethod = client().executeBlocking(CartUpdateCommand.of(cart, action));
final CartShippingInfo shippingInfo = cartWithShippingMethod.getShippingInfo();
assertThat(shippingInfo.getPrice()).isEqualTo(price);
assertThat(shippingInfo.getShippingMethod()).isNull();
assertThat(shippingInfo.getShippingMethodName()).isEqualTo(shippingMethodName);
assertThat(shippingInfo.getShippingRate()).isEqualTo(shippingRate);
assertThat(shippingInfo.getTaxCategory()).isEqualTo(taxCategory.toReference());
assertThat(shippingInfo.getTaxRate()).isNotNull();
});
See the test code.
Modifier and Type | Method and Description |
---|---|
ExternalTaxRateDraft |
getExternalTaxRate() |
String |
getShippingMethodName() |
ShippingRate |
getShippingRate() |
ResourceIdentifier<TaxCategory> |
getTaxCategory() |
static SetCustomShippingMethod |
of(String shippingMethodName,
ShippingRate shippingRate,
Referenceable<TaxCategory> taxCategory) |
static SetCustomShippingMethod |
of(String shippingMethodName,
ShippingRate shippingRate,
ResourceIdentifier<TaxCategory> taxCategory) |
static SetCustomShippingMethod |
ofExternalTaxCalculation(String shippingMethodName,
ShippingRate shippingRate) |
static SetCustomShippingMethod |
ofExternalTaxCalculation(String shippingMethodName,
ShippingRate shippingRate,
ExternalTaxRateDraft externalTaxRate) |
getAction
public static SetCustomShippingMethod of(String shippingMethodName, ShippingRate shippingRate, ResourceIdentifier<TaxCategory> taxCategory)
public static SetCustomShippingMethod of(String shippingMethodName, ShippingRate shippingRate, Referenceable<TaxCategory> taxCategory)
public static SetCustomShippingMethod ofExternalTaxCalculation(String shippingMethodName, ShippingRate shippingRate, ExternalTaxRateDraft externalTaxRate)
public static SetCustomShippingMethod ofExternalTaxCalculation(String shippingMethodName, ShippingRate shippingRate)
public String getShippingMethodName()
public ShippingRate getShippingRate()
@Nullable public ResourceIdentifier<TaxCategory> getTaxCategory()
@Nullable public ExternalTaxRateDraft getExternalTaxRate()