Skip to content

Instantly share code, notes, and snippets.

@peteeveleigh
Forked from mdcpepper/_cart-debug.twig
Created February 23, 2019 15:25
Show Gist options
  • Save peteeveleigh/de6d0930851ef6c66cee125220460b3a to your computer and use it in GitHub Desktop.
Save peteeveleigh/de6d0930851ef6c66cee125220460b3a to your computer and use it in GitHub Desktop.
Craft Commerce debugging template
{% if craft.config.get('devMode') %}
{% set size = 30 %}
<pre style="width:80%;margin:0 auto">
Line Items:
---------------------------------------------------
{% for lineItem in cart.lineItems %}
{{ lineItem.purchasable.title }} x {{ lineItem.qty }} {{ dump(lineItem.options) }}
{% endfor %}
Adjustments:
---------------------------------------------------
{% for adjustment in cart.adjustments %}
{{ "%#{size}s"|format("#{adjustment.name} (#{adjustment.description}):") }} {{ adjustment.amount|currency(cart.currency) }}
{% endfor %}
Cart:
---------------------------------------------------
{{ "%#{size}s"|format("Total Discount:") }} {{ cart.totalDiscount|currency(cart.currency) }}
{{ "%#{size}s"|format("Total Shipping:") }} {{ cart.totalShippingCost|currency(cart.currency) }}
{{ "%#{size}s"|format("Total Tax:") }} {{ cart.totalTax|currency(cart.currency) }}
{{ "%#{size}s"|format("Total Tax (inc):") }} {{ cart.totalTaxIncluded|currency(cart.currency) }}
{{ "%#{size}s"|format("Item Subtotal:") }} {{ cart.itemSubtotal|currency(cart.currency) }}
{{ "%#{size}s"|format("Item Total:") }} {{ cart.itemTotal|currency(cart.currency) }}
{{ "%#{size}s"|format("Base Discount:") }} {{ cart.baseDiscount|currency(cart.currency) }}
{{ "%#{size}s"|format("Base Shipping Cost:") }} {{ cart.baseShippingCost|currency(cart.currency) }}
===================================================
{{ "%#{size}s"|format("Total Price:") }} {{ cart.totalPrice|currency(cart.currency) }}
</pre>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment