From 15fdc677beeafa15f47ce50aefdf2b10bffdf864 Mon Sep 17 00:00:00 2001 From: Mat Caissy Date: Tue, 8 Mar 2016 15:50:38 -0800 Subject: [PATCH] [Timber] add page cart discounts update --- assets/ajax-cart.js.liquid | 10 ++++++++-- assets/timber.scss.liquid | 4 ++++ locales/de.json | 3 ++- locales/en.default.json | 3 ++- locales/es.json | 3 ++- locales/fr.json | 3 ++- locales/pt-BR.json | 3 ++- locales/pt-PT.json | 3 ++- snippets/ajax-cart-template.liquid | 21 ++++++++++++++++++++- templates/cart.liquid | 12 ++++++++++++ 10 files changed, 56 insertions(+), 9 deletions(-) diff --git a/assets/ajax-cart.js.liquid b/assets/ajax-cart.js.liquid index 875f94065..c003ae000 100644 --- a/assets/ajax-cart.js.liquid +++ b/assets/ajax-cart.js.liquid @@ -299,7 +299,11 @@ var ajaxCart = (function(module, $) { itemMinus: cartItem.quantity - 1, itemQty: cartItem.quantity, price: Shopify.formatMoney(cartItem.price, settings.moneyFormat), - vendor: cartItem.vendor + vendor: cartItem.vendor, + linePrice: Shopify.formatMoney(cartItem.line_price, settings.moneyFormat), + originalPrice: Shopify.formatMoney((cartItem.line_price + cartItem.total_discount), settings.moneyFormat), + discounts: cartItem.discounts, + discountsApplied: cartItem.line_price === (cartItem.line_price - cartItem.total_discount) ? false : true }; items.push(item); @@ -309,7 +313,9 @@ var ajaxCart = (function(module, $) { data = { items: items, note: cart.note, - totalPrice: Shopify.formatMoney(cart.total_price, settings.moneyFormat) + totalPrice: Shopify.formatMoney(cart.total_price, settings.moneyFormat), + totalCartDiscount: cart.total_discount === 0 ? 0 : {{ 'cart.general.savings_html' | t: price: '[savings]' | json }}.replace('[savings]', Shopify.formatMoney(cart.total_discount, settings.moneyFormat)), + totalCartDiscountApplied: cart.total_discount === 0 ? false : true } $cartContainer.append(template(data)); diff --git a/assets/timber.scss.liquid b/assets/timber.scss.liquid index e89d7ea40..3cc0d21cb 100755 --- a/assets/timber.scss.liquid +++ b/assets/timber.scss.liquid @@ -2539,4 +2539,8 @@ label.error { border-color: $colorDrawerBorder; } +.ajaxcart-item__price-strikethrough { + float: right; +} + {% endif %} // settings.ajax_cart_method diff --git a/locales/de.json b/locales/de.json index 45df03e9e..bcf7ec7f9 100644 --- a/locales/de.json +++ b/locales/de.json @@ -64,7 +64,8 @@ "checkout": "Zur Kasse", "empty": "Ihr Einkaufswagen ist im Moment leer.", "continue_browsing_html": "Mit der Suche hier fortfahren.", - "close_cart": "Einkaufswagen schließen" + "close_cart": "Einkaufswagen schließen", + "savings_html": "Sie sparen {{ price }}" }, "label": { "product": "Artikel", diff --git a/locales/en.default.json b/locales/en.default.json index d82944a5b..3f765d262 100644 --- a/locales/en.default.json +++ b/locales/en.default.json @@ -64,7 +64,8 @@ "checkout": "Check Out", "empty": "Your cart is currently empty.", "continue_browsing_html": "Continue browsing here.", - "close_cart": "Close Cart" + "close_cart": "Close Cart", + "savings_html": "You're saving {{ price }}" }, "label": { "product": "Product", diff --git a/locales/es.json b/locales/es.json index b06355f2a..8c6be51fd 100644 --- a/locales/es.json +++ b/locales/es.json @@ -64,7 +64,8 @@ "checkout": "Finalizar pedido", "empty": "Su carrito actualmente está vacío.", "continue_browsing_html": "Continúe explorando aquí.", - "close_cart": "Cerrar carrito" + "close_cart": "Cerrar carrito", + "savings_html": "Está ahorrando {{ price }}" }, "label": { "product": "Producto", diff --git a/locales/fr.json b/locales/fr.json index 4e564190a..0071e26cd 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -64,7 +64,8 @@ "checkout": "Procéder au paiement", "empty": "Votre panier est vide.", "continue_browsing_html": "Retourner au magasinage.", - "close_cart": "Fermer le panier" + "close_cart": "Fermer le panier", + "savings_html": "Vous économisez {{ price }}" }, "label": { "product": "Produit", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 148babb28..4916e71c7 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -64,7 +64,8 @@ "checkout": "Fechar pedido", "empty": "Seu carrinho está vazio no momento.", "continue_browsing_html": "Continue navegando aqui.", - "close_cart": "Fechar carrinho" + "close_cart": "Fechar carrinho", + "savings_html": "Você está economizando {{ price }}" }, "label": { "product": "Produto", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 9603b9866..fa5a4e0d5 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -64,7 +64,8 @@ "checkout": "Check-Out", "empty": "O seu carrinho de compras está neste momento vazio.", "continue_browsing_html": "Continue a ver aqui.", - "close_cart": "Fechar Carrinho de Compras" + "close_cart": "Fechar Carrinho de Compras", + "savings_html": "Está a poupar {{ price }}" }, "label": { "product": "Produto", diff --git a/snippets/ajax-cart-template.liquid b/snippets/ajax-cart-template.liquid index 3ebbaac5e..38bf08156 100755 --- a/snippets/ajax-cart-template.liquid +++ b/snippets/ajax-cart-template.liquid @@ -50,7 +50,23 @@
- {{{price}}} + {{#if discountsApplied}} + {{{originalPrice}}} +
{{{linePrice}}} + {{else}} + {{{linePrice}}} + {{/if}} +
+ + {{#if discountsApplied}} +
+
+ {{#each discounts}} + {{ this.title }}
+ {{/each}} +
+
+ {{/if}} @@ -74,6 +90,9 @@ + {{#if totalCartDiscount}} +

{{{totalCartDiscount}}}

+ {{/if}}

{% endraw %}{{ 'cart.general.shipping_at_checkout' | t }}{% raw %}