Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 43f404a

Browse files
committed
Merge pull request #1404 from OpenBazaar/TruncateZerosInPurchaseFlow
truncate zeros on numbers
2 parents 37f7859 + d4b5bcf commit 43f404a

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

js/languages/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"Tags": "Tags",
132132
"Keywords": "Keywords",
133133
"ShipsFrom": "Ships From",
134+
"ShipsFrom2": "Ships From %{country}",
134135
"ShipsTo": "Ships To",
135136
"AddShipToRegion": "Shipping Region",
136137
"AddShipToRegionNote": "Adds All Nations in a Region",

js/templates/buyAddresses.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<% } else { %>
3131
<%= ob.displayDomesticShipping %>
3232
<% if(ob.userCurrencyCode != 'BTC'){ %>
33-
<div class="textOpacity75 textSize12px letterSpacing02">(<%= ob.domesticShippingBTC.toFixed(4) %> BTC)</div>
33+
<div class="textOpacity75 textSize12px letterSpacing02">(<%= Number(ob.domesticShippingBTC.toFixed(4)) %> BTC)</div>
3434
<% } %>
3535
<% } %>
3636
<% } else { %>
@@ -39,7 +39,7 @@
3939
<% } else { %>
4040
<%= ob.displayInternationalShipping %>
4141
<% if(ob.userCurrencyCode != 'BTC'){ %>
42-
<div class="textOpacity75 textSize12px letterSpacing02">(<%= ob.internationalShippingBTC.toFixed(4) %> BTC)</div>
42+
<div class="textOpacity75 textSize12px letterSpacing02">(<%= Number(ob.internationalShippingBTC.toFixed(4)) %> BTC)</div>
4343
<% } %>
4444
<% } %>
4545
<% } %>

js/templates/buyDetails.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
</div>
4141
<div class="flexCol-4">
4242
<div class="rowItem padding2015 alignRight marginTop20">
43-
<span class="noOverflow fontSize13 js-buyWizardBTCPrice">
44-
<%= ob.vendorBTCPrice.toFixed(4) %> BTC
45-
</span>
43+
<span class="noOverflow fontSize13 js-buyWizardBTCPrice"></span>
4644
<span class="noOverflow textOpacity75 fontSize13 js-buyWizardPrice">
4745
<% if(ob.userCurrencyCode != 'BTC'){ %>
4846
(<%= ob.displayPrice %>)

js/templates/item.html

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ <h4><%= polyglot.t('CanBeShippedTo') %></h4>
188188
<% if(ob.vendor_offer.listing.shipping.shipping_regions.length || ob.vendor_offer.listing.policy.returns || ob.vendor_offer.listing.policy.terms_conditions) { %>
189189
<div class="flexCol-6">
190190
<div class="rowItem fontSize16 padding30 lineHeight24 fontWeight400">
191-
<h3><%= polyglot.t('Domestic') %> <%= ob.displayShippingOrigin || ob.userCountry %></h3>
191+
<h3><%= polyglot.t('ShipsFrom2', {country: ob.displayShippingOrigin || ob.userCountry}) %></h3>
192+
<h3><%= polyglot.t('Local') %></h3>
192193
<div>
193194
<% if(ob.userCurrencyCode != "BTC"){ %>
194195
<%= polyglot.t('Shipping2') %> <%= ob.displayDomesticShipping %> (<%= Number(ob.domesticShippingBTC.toFixed(8)) %> BTC)
@@ -197,25 +198,27 @@ <h3><%= polyglot.t('Domestic') %> <%= ob.displayShippingOrigin || ob.userCountry
197198
<% } %>
198199
</div>
199200
<p><%= polyglot.t('transactions.EstimatedDelivery') %> <%= ob.vendor_offer.listing.shipping.est_delivery.domestic %></p>
200-
<hr/>
201-
<h3><%= polyglot.t('International') %></h3>
202-
<div>
203-
<% if(ob.userCurrencyCode != "BTC"){ %>
204-
<%= polyglot.t('Shipping2') %> <%= ob.displayInternationalShipping %> (<%= Number(ob.internationalShippingBTC.toFixed(8)) %> BTC)
205-
<% } else { %>
206-
<%= polyglot.t('Shipping2') %> <%= Number(ob.internationalShippingBTC.toFixed(8)) %> BTC
201+
<% if(ob.internationalShippingBTC){ %>
202+
<hr/>
203+
<h3><%= polyglot.t('International') %></h3>
204+
<div>
205+
<% if(ob.userCurrencyCode != "BTC"){ %>
206+
<%= polyglot.t('Shipping2') %> <%= ob.displayInternationalShipping %> (<%= Number(ob.internationalShippingBTC.toFixed(8)) %> BTC)
207+
<% } else { %>
208+
<%= polyglot.t('Shipping2') %> <%= Number(ob.internationalShippingBTC.toFixed(8)) %> BTC
209+
<% } %>
210+
</div>
211+
<p><%= polyglot.t('transactions.EstimatedDelivery') %> <%= ob.vendor_offer.listing.shipping.est_delivery.international %></p>
207212
<% } %>
208-
</div>
209-
<p><%= polyglot.t('transactions.EstimatedDelivery') %> <%= ob.vendor_offer.listing.shipping.est_delivery.international %></p>
210213
<hr/>
211-
<% if(ob.vendor_offer.listing.policy.returns) { %>
212-
<h3><%= polyglot.t('ReturnsPolicy') %></h3>
213-
<p><%= ob.vendor_offer.listing.policy.returns %></p>
214-
<% } %>
215-
<% if(ob.vendor_offer.listing.policy.terms_conditions) { %>
216-
<h3><%= polyglot.t('TermsAndConditions') %></h3>
217-
<p><%= ob.vendor_offer.listing.policy.terms_conditions %></p>
218-
<% } %>
214+
<% if(ob.vendor_offer.listing.policy.returns) { %>
215+
<h3><%= polyglot.t('ReturnsPolicy') %></h3>
216+
<p><%= ob.vendor_offer.listing.policy.returns %></p>
217+
<% } %>
218+
<% if(ob.vendor_offer.listing.policy.terms_conditions) { %>
219+
<h3><%= polyglot.t('TermsAndConditions') %></h3>
220+
<p><%= ob.vendor_offer.listing.policy.terms_conditions %></p>
221+
<% } %>
219222
</div>
220223
</div>
221224
<div class="flexCol-6">

js/views/buyDetailsVw.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ module.exports = Backbone.View.extend({
7272
moderatorPrice = moderatorPercentage ? totalItemPrice * moderatorPercentage : 0,
7373
moderatorTotal = moderatorPrice * quantity,
7474
totalPrice = totalItemPrice + totalShipping,
75-
newBTCDisplayPrice = (this.model.get('vendorBTCPrice') * quantity).toFixed(8),
76-
newBTCShippingDisplayPrice = (this.model.get('currentShippingBTCPrice') * quantity).toFixed(8),
77-
newDisplayPrice = (userCurrency == "BTC") ? totalItemPrice.toFixed(8) + " BTC" : new Intl.NumberFormat(window.lang, {
75+
newBTCDisplayPrice = Number((this.model.get('vendorBTCPrice') * quantity).toFixed(8)),
76+
newBTCShippingDisplayPrice = Number((this.model.get('currentShippingBTCPrice') * quantity).toFixed(8)),
77+
newDisplayPrice = (userCurrency == "BTC") ? Number(totalItemPrice.toFixed(8)) + " BTC" : new Intl.NumberFormat(window.lang, {
7878
style: 'currency',
7979
minimumFractionDigits: 2,
8080
maximumFractionDigits: 2,
8181
currency: userCurrency
8282
}).format(totalItemPrice),
83-
newDisplayShippingPrice = (userCurrency == "BTC") ? totalShipping.toFixed(8) + " BTC" : new Intl.NumberFormat(window.lang, {
83+
newDisplayShippingPrice = (userCurrency == "BTC") ? Number(totalShipping.toFixed(8)) + " BTC" : new Intl.NumberFormat(window.lang, {
8484
style: 'currency',
8585
minimumFractionDigits: 2,
8686
maximumFractionDigits: 2,
8787
currency: userCurrency
8888
}).format(totalShipping),
89-
newDisplayModeratorPrice = (userCurrency == "BTC") ? moderatorTotal.toFixed(8) + " BTC" : new Intl.NumberFormat(window.lang, {
89+
newDisplayModeratorPrice = (userCurrency == "BTC") ? Number(moderatorTotal.toFixed(8)) + " BTC" : new Intl.NumberFormat(window.lang, {
9090
style: 'currency',
9191
minimumFractionDigits: 2,
9292
maximumFractionDigits: 2,

js/views/buyWizardVw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,14 @@ module.exports = baseVw.extend({
556556
var totalPrice = this.model.get('totalPrice'),
557557
totalBTCPrice = this.model.get('totalBTCDisplayPrice'),
558558
userCurrency = this.model.get('userCurrencyCode'),
559-
totalDisplayPrice = (userCurrency == "BTC") ? totalPrice.toFixed(8) + " BTC" : new Intl.NumberFormat(window.lang, {
559+
totalDisplayPrice = (userCurrency == "BTC") ? Number(totalPrice.toFixed(8)) + " BTC" : new Intl.NumberFormat(window.lang, {
560560
style: 'currency',
561561
minimumFractionDigits: 2,
562562
maximumFractionDigits: 2,
563563
currency: userCurrency
564564
}).format(totalPrice);
565565
this.$el.find('.js-buyWizardDetailsTotal').text(totalDisplayPrice);
566-
this.$el.find('.js-buyWizardDetailsBTCTotal').text(totalBTCPrice.toFixed(8));
566+
this.$el.find('.js-buyWizardDetailsBTCTotal').text(Number(totalBTCPrice.toFixed(8)));
567567
},
568568

569569
copyPayAddress: function(){

0 commit comments

Comments
 (0)