public final class AddDiscountCode extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
withCartAndDiscountCode(client(), (cart, discountCode) -> { //addDiscountCode final Cart cartWithCode = client().executeBlocking(CartUpdateCommand.of(cart, AddDiscountCode.of(discountCode))); final DiscountCodeInfo discountCodeInfo = cartWithCode.getDiscountCodes().get(0); assertThat(discountCodeInfo.getDiscountCode()).isEqualTo(discountCode.toReference()); //removeDiscountCode final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cartWithCode, RemoveDiscountCode.of(discountCode))); assertThat(updatedCart.getDiscountCodes()).isEmpty(); return updatedCart; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getCode() |
static AddDiscountCode |
of(DiscountCode code) |
static AddDiscountCode |
of(String code) |
getAction
public static AddDiscountCode of(DiscountCode code)
public static AddDiscountCode of(String code)
public String getCode()