@@ -14,18 +14,34 @@ module.exports = Backbone.View.extend({
1414
1515 initialize : function ( ) {
1616 "use strict" ;
17- var currentShippingPrice = 0 ,
17+ var recipient = this . model . get ( 'page' ) . profile . handle || this . model . get ( 'page' ) . profile . guid ;
18+
19+ this . model . set ( 'recipient' , recipient ) ;
20+
21+ this . listenTo ( this . model , 'change:selectedModerator change:selectedAddress' , this . render ) ;
22+ this . render ( ) ;
23+ } ,
24+
25+ render : function ( ) {
26+ var self = this ,
27+ currentShippingPrice = 0 ,
1828 currentShippingBTCPrice = 0 ,
19- 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 ) {
29+ shippingType = "" ,
30+ templJSON = { } ;
31+ console . log ( this . model )
32+
33+ //set prices before each render
34+ if ( this . model . get ( 'vendor_offer' ) . listing . shipping . free !== true && this . model . get ( 'selectedAddress' ) ) {
35+ if ( this . model . get ( 'selectedAddress' ) . country != this . model . get ( 'vendor_offer' ) . listing . shipping . shipping_origin ) {
2236 currentShippingPrice = this . model . get ( 'internationalShipping' ) ;
2337 currentShippingBTCPrice = this . model . get ( 'internationalShippingBTC' ) ;
2438 this . model . set ( 'shippingType' , 'international' ) ;
39+ shippingType = 'international' ;
2540 } else {
2641 currentShippingPrice = this . model . get ( 'domesticShipping' ) ;
2742 currentShippingBTCPrice = this . model . get ( 'domesticShippingBTC' ) ;
2843 this . model . set ( 'shippingType' , 'domestic' ) ;
44+ shippingType = 'domestic' ;
2945 }
3046 }
3147
@@ -39,14 +55,6 @@ module.exports = Backbone.View.extend({
3955 currency : this . model . get ( 'userCurrencyCode' )
4056 } ) . format ( currentShippingPrice ) ) ;
4157
42- this . model . set ( 'recipient' , recipient ) ;
43-
44- this . listenTo ( this . model , 'change:selectedModerator change:selectedAddress' , this . render ) ;
45- this . render ( ) ;
46- } ,
47-
48- render : function ( ) {
49- var self = this ;
5058 loadTemplate ( './js/templates/buyDetails.html' , function ( loadedTemplate ) {
5159 self . $el . html ( loadedTemplate ( self . model . toJSON ( ) ) ) ;
5260 //this does not add it to the DOM, that is done by the parent view
0 commit comments