Skip to content

Instantly share code, notes, and snippets.

@mdcpepper
Created October 21, 2016 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mdcpepper/b2614c62dbc585dfe6720f9ac23fbde5 to your computer and use it in GitHub Desktop.
Save mdcpepper/b2614c62dbc585dfe6720f9ac23fbde5 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