Skip to content

Commit

Permalink
feat: #49 (*) update totals in cartPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Aug 22, 2021
1 parent c03bf85 commit 70d9e29
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const params: UseShippingProviderParams<ShippingProvider, ShippingMethod> = {
console.log('Mocked: saveShippingProvider');
return {};
}

set: async (context: Context) => {
// Set Cart value to a new returned from setShippingMethod
}
};

export const useShippingProvider = useShippingProviderFactory<ShippingProvider, ShippingMethod>(params);
2 changes: 1 addition & 1 deletion packages/composables/src/getters/cartGetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getItemSku = (item: OrderLine): string => {

const getTotals = (cart: Order): AgnosticTotals => {
return {
total: createPrice(cart?.subTotal),
total: createPrice(cart?.totalWithTax),
subtotal: createPrice(cart?.subTotalWithTax)
};
};
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/components/Checkout/CartPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/>
<SfProperty
:name="$t('Total')"
:value="$n(totals.subtotal, 'currency')"
:value="$n(totals.total, 'currency')"
class="sf-property--full-width sf-property--large property-total"
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/theme/components/Checkout/VsfShippingProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
setup (props, { emit }) {
const shippingMethods = ref([]);
const { $vendure } = useVSFContext();
const { cart } = useCart();
const { cart, setCart } = useCart();
const {
state,
load,
Expand All @@ -116,7 +116,8 @@ export default {
});
const selectShippingMethod = async shippingMethod => {
await $vendure.api.setShippingMethod({ shippingMethodId: shippingMethod.id })
const newOrder = await $vendure.api.setShippingMethod({ shippingMethodId: shippingMethod.id })
setCart(newOrder.data.setOrderShippingMethod);
selectedShippingMethod.value = shippingMethod;
emit('shippingMethodSelected', shippingMethod);
};
Expand Down

0 comments on commit 70d9e29

Please sign in to comment.