@@ -17,17 +17,6 @@ module.exports = Backbone.View.extend({
1717 var currentShippingPrice = 0 ,
1818 currentShippingBTCPrice = 0 ,
1919 recipient = this . model . get ( 'page' ) . profile . handle || this . model . get ( 'page' ) . profile . guid ;
20- if ( this . model . get ( 'vendor_offer' ) . listing . shipping . free !== true ) {
21- if ( this . model . get ( 'userCountry' ) != this . model . get ( 'vendor_offer' ) . listing . shipping . shipping_origin ) {
22- currentShippingPrice = this . model . get ( 'internationalShipping' ) ;
23- currentShippingBTCPrice = this . model . get ( 'internationalShippingBTC' ) ;
24- this . model . set ( 'shippingType' , 'international' ) ;
25- } else {
26- currentShippingPrice = this . model . get ( 'domesticShipping' ) ;
27- currentShippingBTCPrice = this . model . get ( 'domesticShippingBTC' ) ;
28- this . model . set ( 'shippingType' , 'domestic' ) ;
29- }
30- }
3120
3221 this . model . set ( 'currentShippingPrice' , currentShippingPrice ) ;
3322 this . model . set ( 'currentShippingBTCPrice' , currentShippingBTCPrice ) ;
@@ -41,16 +30,47 @@ module.exports = Backbone.View.extend({
4130
4231 this . model . set ( 'recipient' , recipient ) ;
4332
44- this . listenTo ( this . model , 'change:selectedModerator change:selectedAddress' , this . render ) ;
33+ this . listenTo ( this . model , 'change:selectedModerator change:selectedAddress' , function ( ) {
34+ this . render ( ) ;
35+ } ) ;
36+
4537 this . render ( ) ;
4638 } ,
4739
40+
4841 render : function ( ) {
4942 var self = this ;
5043 loadTemplate ( './js/templates/buyDetails.html' , function ( loadedTemplate ) {
44+ var currentShippingPrice = 0 ,
45+ currentShippingBTCPrice = 0 ,
46+ shipToCountry = self . model . get ( 'selectedAddress' ) ? self . model . get ( 'selectedAddress' ) . country : "" ;
47+
48+ if ( shipToCountry && self . model . get ( 'vendor_offer' ) . listing . shipping . free !== true ) {
49+ if ( shipToCountry != self . model . get ( 'vendor_offer' ) . listing . shipping . shipping_origin ) {
50+ currentShippingPrice = self . model . get ( 'internationalShipping' ) ;
51+ currentShippingBTCPrice = self . model . get ( 'internationalShippingBTC' ) ;
52+ self . model . set ( 'shippingType' , 'international' ) ;
53+ } else {
54+ currentShippingPrice = self . model . get ( 'domesticShipping' ) ;
55+ currentShippingBTCPrice = self . model . get ( 'domesticShippingBTC' ) ;
56+ self . model . set ( 'shippingType' , 'domestic' ) ;
57+ }
58+ }
59+ self . model . set ( 'currentShippingPrice' , currentShippingPrice ) ;
60+ self . model . set ( 'currentShippingBTCPrice' , currentShippingBTCPrice ) ;
61+
62+ self . model . set ( 'currentShippingDisplayPrice' , new Intl . NumberFormat ( window . lang , {
63+ style : 'currency' ,
64+ minimumFractionDigits : 2 ,
65+ maximumFractionDigits : 2 ,
66+ currency : this . model . get ( 'userCurrencyCode' )
67+ } ) . format ( currentShippingPrice ) ) ;
68+
5169 self . $el . html ( loadedTemplate ( self . model . toJSON ( ) ) ) ;
70+
5271 //this does not add it to the DOM, that is done by the parent view
5372 self . setQuantity ( 1 ) ;
73+
5474 numberSpinners ( self . $el ) ;
5575 } ) ;
5676 return this ;
@@ -63,6 +83,7 @@ module.exports = Backbone.View.extend({
6383
6484 setQuantity : function ( quantity ) {
6585 "use strict" ;
86+ console . log ( this . model . get ( 'currentShippingBTCPrice' ) )
6687 var self = this ,
6788 newAttributes = { } ,
6889 userCurrency = this . model . get ( 'userCurrencyCode' ) ,
0 commit comments