| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The Chromium Authors. All rights reserved. | 2 * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* global PaymentRequest:false */ | 7 /* global PaymentRequest:false */ |
| 8 /* global toDictionary:false */ | 8 /* global toDictionary:false */ |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 * the shipping address. | 55 * the shipping address. |
| 56 * @param {object} details - The shopping cart. | 56 * @param {object} details - The shopping cart. |
| 57 * @param {ShippingAddress} addr - The shipping address. | 57 * @param {ShippingAddress} addr - The shipping address. |
| 58 * @return {object} The updated shopping cart. | 58 * @return {object} The updated shopping cart. |
| 59 */ | 59 */ |
| 60 function updateDetails(details, addr) { | 60 function updateDetails(details, addr) { |
| 61 if (addr.regionCode === 'US') { | 61 if (addr.regionCode === 'US') { |
| 62 var shippingOption = { | 62 var shippingOption = { |
| 63 id: '', | 63 id: '', |
| 64 label: '', | 64 label: '', |
| 65 amount: {currency: 'USD', value: '0.00'} | 65 amount: {currency: 'USD', value: '0.00'}, |
| 66 selected: true |
| 66 }; | 67 }; |
| 67 if (addr.administrativeArea === 'CA') { | 68 if (addr.administrativeArea === 'CA') { |
| 68 shippingOption.id = 'ca'; | 69 shippingOption.id = 'ca'; |
| 69 shippingOption.label = 'Free shipping in California'; | 70 shippingOption.label = 'Free shipping in California'; |
| 70 details.total.amount.value = '5.00'; | 71 details.total.amount.value = '5.00'; |
| 71 } else { | 72 } else { |
| 72 shippingOption.id = 'us'; | 73 shippingOption.id = 'us'; |
| 73 shippingOption.label = 'Standard shipping in US'; | 74 shippingOption.label = 'Standard shipping in US'; |
| 74 shippingOption.amount.value = '5.00'; | 75 shippingOption.amount.value = '5.00'; |
| 75 details.total.amount.value = '10.00'; | 76 details.total.amount.value = '10.00'; |
| 76 } | 77 } |
| 77 if (details.displayItems.length === 1) { | 78 if (details.displayItems.length === 1) { |
| 78 details.displayItems.splice(0, 0, shippingOption); | 79 details.displayItems.splice(0, 0, shippingOption); |
| 79 } else { | 80 } else { |
| 80 details.displayItems.splice(0, 1, shippingOption); | 81 details.displayItems.splice(0, 1, shippingOption); |
| 81 } | 82 } |
| 82 details.shippingOptions = [shippingOption]; | 83 details.shippingOptions = [shippingOption]; |
| 83 } else { | 84 } else { |
| 84 delete details.shippingOptions; | 85 delete details.shippingOptions; |
| 85 } | 86 } |
| 86 return details; | 87 return details; |
| 87 } | 88 } |
| OLD | NEW |