This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 490
[Timber] add cart discounts #522
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be: discountsApplied: cartItem.line_price === cartItem.original_line_price ? 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)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,23 @@ | |
</div> | ||
</div> | ||
<div class="grid__item display-table-cell one-half text-right"> | ||
{{{price}}} | ||
{{#if discountsApplied}} | ||
<small class="ajaxcart-item__price-strikethrough"><s>{{{originalPrice}}}</s></small> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on my comments above, this can be : <small class="ajaxcart-item__price-strikethrough"><s>{{{originalLinePrice}}}</s></small> |
||
<br><span>{{{linePrice}}}</span> | ||
{{else}} | ||
<span>{{{linePrice}}}</span> | ||
{{/if}} | ||
</div> | ||
</div> | ||
{{#if discountsApplied}} | ||
<div class="grid--full display-table"> | ||
<div class="grid__item text-right"> | ||
{{#each discounts}} | ||
<small class="ajaxcart-item__discount">{{ this.title }}</small><br> | ||
{{/each}} | ||
</div> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -74,6 +90,9 @@ | |
<div class="grid__item one-third text-right"> | ||
<p>{{{totalPrice}}}</p> | ||
</div> | ||
{{#if totalCartDiscount}} | ||
<p class="ajaxcart__savings text-center"><em>{{{totalCartDiscount}}}</em></p> | ||
{{/if}} | ||
</div> | ||
<p class="text-center">{% endraw %}{{ 'cart.general.shipping_at_checkout' | t }}{% raw %}</p> | ||
<button type="submit" class="btn--secondary btn--full cart__checkout" name="checkout"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is talking about
cartItem.line_price
, this can be: