mirror of
https://github.com/vercel/commerce.git
synced 2025-04-28 13:57:50 +00:00
Replace button custom checkout enabled on /cart (#535)
Co-authored-by: Gonzalo Pozzo <gonzalo.pozzo4@gmail.com>
This commit is contained in:
parent
94c2d2d6d4
commit
d4d22a3ce7
@ -6,6 +6,7 @@ import { Layout } from '@components/common'
|
|||||||
import { Button, Text } from '@components/ui'
|
import { Button, Text } from '@components/ui'
|
||||||
import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons'
|
import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons'
|
||||||
import { CartItem } from '@components/cart'
|
import { CartItem } from '@components/cart'
|
||||||
|
import { useUI } from '@components/ui/context'
|
||||||
|
|
||||||
export async function getStaticProps({
|
export async function getStaticProps({
|
||||||
preview,
|
preview,
|
||||||
@ -26,6 +27,7 @@ export default function Cart() {
|
|||||||
const error = null
|
const error = null
|
||||||
const success = null
|
const success = null
|
||||||
const { data, isLoading, isEmpty } = useCart()
|
const { data, isLoading, isEmpty } = useCart()
|
||||||
|
const { openSidebar, setSidebarView } = useUI()
|
||||||
|
|
||||||
const { price: subTotal } = usePrice(
|
const { price: subTotal } = usePrice(
|
||||||
data && {
|
data && {
|
||||||
@ -40,6 +42,11 @@ export default function Cart() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const goToCheckout = () => {
|
||||||
|
openSidebar()
|
||||||
|
setSidebarView('CHECKOUT_VIEW')
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid lg:grid-cols-12 w-full max-w-7xl mx-auto">
|
<div className="grid lg:grid-cols-12 w-full max-w-7xl mx-auto">
|
||||||
<div className="lg:col-span-8">
|
<div className="lg:col-span-8">
|
||||||
@ -161,11 +168,19 @@ export default function Cart() {
|
|||||||
<Button href="/" Component="a" width="100%">
|
<Button href="/" Component="a" width="100%">
|
||||||
Continue Shopping
|
Continue Shopping
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED ? (
|
||||||
|
<Button Component="a" width="100%" onClick={goToCheckout}>
|
||||||
|
Proceed to Checkout ({total})
|
||||||
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button href="/checkout" Component="a" width="100%">
|
<Button href="/checkout" Component="a" width="100%">
|
||||||
Proceed to Checkout
|
Proceed to Checkout
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user