2020-03-12 09:41:35 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
SubtotalsItem,
|
|
|
|
TotalsFeesItem,
|
|
|
|
TotalsCouponCodeInput,
|
|
|
|
TotalsDiscountItem,
|
|
|
|
TotalsFooterItem,
|
|
|
|
TotalsShippingItem,
|
|
|
|
TotalsTaxesItem,
|
2020-03-30 13:04:27 +00:00
|
|
|
} from '@woocommerce/base-components/cart-checkout';
|
2020-03-12 09:41:35 +00:00
|
|
|
import { getCurrencyFromPriceResponse } from '@woocommerce/base-utils';
|
|
|
|
import {
|
|
|
|
COUPONS_ENABLED,
|
|
|
|
DISPLAY_CART_PRICES_INCLUDING_TAX,
|
|
|
|
} from '@woocommerce/block-settings';
|
|
|
|
import { useStoreCartCoupons } from '@woocommerce/base-hooks';
|
|
|
|
|
2020-03-13 15:49:33 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import OrderSummary from './order-summary.js';
|
|
|
|
|
2020-03-12 09:41:35 +00:00
|
|
|
const CheckoutSidebar = ( {
|
|
|
|
cartCoupons = [],
|
2020-03-13 15:49:33 +00:00
|
|
|
cartItems = [],
|
2020-03-12 09:41:35 +00:00
|
|
|
cartTotals = {},
|
|
|
|
} ) => {
|
|
|
|
const {
|
|
|
|
applyCoupon,
|
|
|
|
removeCoupon,
|
|
|
|
isApplyingCoupon,
|
|
|
|
isRemovingCoupon,
|
|
|
|
} = useStoreCartCoupons();
|
|
|
|
const totalsCurrency = getCurrencyFromPriceResponse( cartTotals );
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2020-03-13 15:49:33 +00:00
|
|
|
<OrderSummary cartItems={ cartItems } />
|
2020-03-12 09:41:35 +00:00
|
|
|
<SubtotalsItem currency={ totalsCurrency } values={ cartTotals } />
|
|
|
|
<TotalsFeesItem currency={ totalsCurrency } values={ cartTotals } />
|
|
|
|
<TotalsDiscountItem
|
|
|
|
cartCoupons={ cartCoupons }
|
|
|
|
currency={ totalsCurrency }
|
|
|
|
isRemovingCoupon={ isRemovingCoupon }
|
|
|
|
removeCoupon={ removeCoupon }
|
|
|
|
values={ cartTotals }
|
|
|
|
/>
|
|
|
|
<TotalsShippingItem
|
|
|
|
currency={ totalsCurrency }
|
2020-03-16 13:13:04 +00:00
|
|
|
noResultsMessage={ null }
|
|
|
|
isCheckout={ true }
|
|
|
|
showCalculator={ false }
|
2020-03-12 09:41:35 +00:00
|
|
|
values={ cartTotals }
|
|
|
|
/>
|
|
|
|
{ ! DISPLAY_CART_PRICES_INCLUDING_TAX && (
|
|
|
|
<TotalsTaxesItem
|
|
|
|
currency={ totalsCurrency }
|
|
|
|
values={ cartTotals }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
{ COUPONS_ENABLED && (
|
|
|
|
<TotalsCouponCodeInput
|
|
|
|
onSubmit={ applyCoupon }
|
|
|
|
initialOpen={ false }
|
|
|
|
isLoading={ isApplyingCoupon }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
<TotalsFooterItem
|
|
|
|
currency={ totalsCurrency }
|
|
|
|
values={ cartTotals }
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CheckoutSidebar;
|