Skip to content

Commit

Permalink
update example templates when no card exists
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Sep 13, 2023
1 parent fec0cbe commit 8d33a0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example-templates/dist/shop/plans/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@

<div class="flex flex-wrap -mx-2">
{% for plan in plans %}
{% set paymentSources = craft.commerce.paymentSources.getAllPaymentSourcesByCustomerId(currentUser.id, plan.gateway.id) %}

<div class="px-2 w-full sm:w-1/2 lg:w-1/3">
<div class="bg-gray-100 border-blue-300 border-b-2 p-6 mt-3">
<form method="post" action="">
Expand All @@ -104,6 +106,7 @@
<h4 class="font-semibold">
{{- plan.name -}}
</h4>
{% if paymentSources|length %}
<div class="mt-3">
{% tag 'select' with {
name: 'trialDays',
Expand Down Expand Up @@ -131,6 +134,12 @@
text: 'Subscribe'|t
}) }}
</div>
{% else %}
<p class="py-4">
{{- 'You do not have any payment sources set up for {gateway}.'|t({ gateway: plan.gateway.name }) -}}
</p>
<a href="/shop/customer/cards" class="cursor-pointer rounded px-4 py-2 inline-block bg-blue-500 hover:bg-blue-600 text-white hover:text-white">Add Card</a>
{% endif %}
</div>
</form>
</div>
Expand Down
9 changes: 9 additions & 0 deletions example-templates/src/shop/plans/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@

<div class="flex flex-wrap -mx-2">
{% for plan in plans %}
{% set paymentSources = craft.commerce.paymentSources.getAllPaymentSourcesByCustomerId(currentUser.id, plan.gateway.id) %}

<div class="px-2 w-full sm:w-1/2 lg:w-1/3">
<div class="[[classes.box.base]] mt-3">
<form method="post" action="">
Expand All @@ -104,6 +106,7 @@
<h4 class="font-semibold">
{{- plan.name -}}
</h4>
{% if paymentSources|length %}
<div class="mt-3">
{% tag 'select' with {
name: 'trialDays',
Expand Down Expand Up @@ -131,6 +134,12 @@
text: 'Subscribe'|t
}) }}
</div>
{% else %}
<p class="py-4">
{{- 'You do not have any payment sources set up for {gateway}.'|t({ gateway: plan.gateway.name }) -}}
</p>
<a href="/[[folderName]]/customer/cards" class="[[classes.btn.base]] [[classes.btn.mainColor]]">Add Card</a>
{% endif %}
</div>
</form>
</div>
Expand Down

0 comments on commit 8d33a0a

Please sign in to comment.