Skip to content

Commit

Permalink
Merge pull request #259 from sphereio/cart-taxes
Browse files Browse the repository at this point in the history
Fix missing pre-calculated taxes in cart, closes #258
  • Loading branch information
lauraluiz committed Jan 20, 2016
2 parents d263029 + 9c0b36f commit 55e3b0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -72,11 +73,10 @@ private F.Promise<Cart> updateCart(final Cart cart, final CheckoutAddressPageCon
final Address nullableBillingAddress = content.getAddressForm().isBillingAddressDifferentToBillingAddress()
? content.getAddressForm().getBillingAddress().toAddress()
: null;
final List<UpdateAction<Cart>> updateActions = asList(
SetCountry.of(shippingAddress.getCountry()),
SetShippingAddress.of(shippingAddress),
SetBillingAddress.of(nullableBillingAddress)
);
final List<UpdateAction<Cart>> updateActions = new ArrayList<>();
updateActions.add(SetCountry.of(shippingAddress.getCountry()));
updateActions.add(SetShippingAddress.of(shippingAddress));
updateActions.add(SetBillingAddress.of(nullableBillingAddress));
Optional.ofNullable(shippingAddress.getEmail())
.ifPresent(email -> updateActions.add(SetCustomerEmail.of(email)));
return sphere().execute(CartUpdateCommand.of(cart, updateActions));
Expand Down
5 changes: 4 additions & 1 deletion shopping-cart/app/shoppingcart/common/CartController.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ protected F.Promise<Cart> getOrCreateCart(final UserContext userContext, final H
}

private F.Promise<Cart> createCart(final UserContext userContext) {
final CartDraft cartDraft = CartDraft.of(userContext.currency()).withCountry(userContext.country());
final Address address = Address.of(userContext.country());
final CartDraft cartDraft = CartDraft.of(userContext.currency())
.withCountry(address.getCountry())
.withShippingAddress(address);
return sphere().execute(CartCreateCommand.of(cartDraft));
}

Expand Down

0 comments on commit 55e3b0e

Please sign in to comment.