Skip to content

Commit

Permalink
Add check for empty cart an redirect to cart page when accessing chec…
Browse files Browse the repository at this point in the history
…kout pages
  • Loading branch information
peteeveleigh committed Sep 17, 2024
1 parent 75812f5 commit 92d7bd3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/templates/_layouts/default.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="robots" content="noindex, nofollow" />

{% if cart is not defined %}
{% set cart = craft.commerce.carts.cart %}
{% endif %}

{% if craft.app.request.getSegment(1) != craft.fostercheckout.getPath('cart')
and cart.lineItems|length == 0 %}
{% redirect craft.fostercheckout.getPath('cart') %}
{% endif %}

{% if seomatic|default %}
{% do seomatic.config.renderEnabled(false) %}
{% endif %}
Expand Down Expand Up @@ -124,10 +133,6 @@

<body style="--brandColor: {{ craft.checkout.branding.color ?? '#1F2937' }};">

{% if cart is not defined %}
{% set cart = craft.commerce.carts.cart %}
{% endif %}

<div v-scope="App" @vue:mounted="App.init">

{# Main header #}
Expand Down

0 comments on commit 92d7bd3

Please sign in to comment.