Skip to content

Commit

Permalink
feat(GCOM-1538): add StoreCredit placeholder component, allow checkou…
Browse files Browse the repository at this point in the history
…t when total of the cart is 0
  • Loading branch information
Giovanni-Schroevers authored and paales committed Jan 16, 2025
1 parent ca72332 commit 3e91863
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .changeset/smooth-dolls-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphcommerce/magento-graphcms': minor
'@graphcommerce/magento-open-source': minor
'@graphcommerce/magento-cart': minor
'@graphcommerce/magento-customer': minor
---

add StoreCredit placeholder component, allow checkout when total of the cart is 0
2 changes: 2 additions & 0 deletions examples/magento-graphcms/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getCustomerAccountIsDisabled,
OrderStateLabelInline,
SignOutForm,
StoreCreditAccountMenuItem,
useCustomerQuery,
WaitForCustomer,
} from '@graphcommerce/magento-customer'
Expand Down Expand Up @@ -126,6 +127,7 @@ function AccountIndexPage() {
'&:hover': { background: theme.palette.background.paper },
})}
/>
<StoreCreditAccountMenuItem customer={customer} />
{import.meta.graphCommerce.magentoVersion >= 246 &&
import.meta.graphCommerce.customerDeleteEnabled && (
<AccountMenuItem
Expand Down
7 changes: 5 additions & 2 deletions examples/magento-graphcms/pages/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ function CartPage() {
{hasItems ? (
<>
<Container maxWidth='md'>
<CartItemsActionCards cart={data.cart} sx={{ position: 'relative', zIndex: 1 }} />
<CouponAccordion key='couponform' sx={(theme) => ({ mt: theme.spacings.md })} />
<CartItemsActionCards
cart={data.cart}
sx={(theme) => ({ position: 'relative', zIndex: 1, mb: theme.spacings.md })}
/>
<CouponAccordion key='couponform' />
<CartTotals containerMargin sx={{ typography: 'body1' }} />
<ApolloCartErrorAlert error={error} />
</Container>
Expand Down
1 change: 1 addition & 0 deletions examples/magento-open-source/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ yarn-error.log*

# managed by: graphcommerce
pages/.well-known/assetlinks.json.tsx
pages/account/store-credit.tsx
# end managed by: graphcommerce
7 changes: 5 additions & 2 deletions examples/magento-open-source/pages/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ function CartPage() {
{hasItems ? (
<>
<Container maxWidth='md'>
<CartItemsActionCards cart={data.cart} sx={{ position: 'relative', zIndex: 1 }} />
<CouponAccordion key='couponform' sx={(theme) => ({ mt: theme.spacings.md })} />
<CartItemsActionCards
cart={data.cart}
sx={(theme) => ({ position: 'relative', zIndex: 1, mb: theme.spacings.md })}
/>
<CouponAccordion key='couponform' />
<CartTotals containerMargin sx={{ typography: 'body1' }} />
<ApolloCartErrorAlert error={error} />
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) {
} = props

const shouldLoginToContinue = useCheckoutShouldLoginToContinue()
const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0
const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 || !!cart?.items?.length
const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt

const shouldLoginToContinue = useCheckoutShouldLoginToContinue()

const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0
const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 || !!cart?.items?.length
const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0)

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { AccountDashboardQuery } from '../../graphql/AccountDashboard.gql'

export type StoreCreditAccountMenuItemProps = AccountDashboardQuery

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function StoreCreditAccountMenuItem(props: StoreCreditAccountMenuItemProps) {
return null
}
1 change: 1 addition & 0 deletions packages/magento-customer/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export * from './SignOutForm/SignOutForm'
export * from './SignUpForm/SignUp.gql'
export * from './SignUpForm/SignUpForm'
export * from './SignUpForm/SignUpFormInline'
export * from './StoreCreditAccountMenuItem/StoreCreditAccountMenuItem'
export * from './UpdateCustomerEmailForm/UpdateCustomerEmailForm'
export * from './UpdateDefaultAddressForm/UpdateDefaultAddressForm'
export * from './WaitForCustomer/WaitForCustomer'

0 comments on commit 3e91863

Please sign in to comment.