Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1896 from OpenBazaar/brian.originLocation
Browse files Browse the repository at this point in the history
Only show shipping from on physical goods sales
  • Loading branch information
hoffmabc authored Jun 3, 2020
2 parents 34d2783 + be3cf5a commit fa98ecb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion js/models/listing/Listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,9 @@ export default class extends BaseModel {
if (parsedResponse.metadata.shippingFromCountryCode !== '') {
const countries = getIndexedCountries();
const countryCode = parsedResponse.metadata.shippingFromCountryCode;
parsedResponse.metadata.shippingFromCountryName = countries[countryCode].name;
if (countryCode !== undefined) {
parsedResponse.metadata.shippingFromCountryName = countries[countryCode].name;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion js/templates/modals/editListing/editListing.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ <h2 class="h4 clrT"><%= ob.polyT('editListing.sectionNames.tagsDetailed') %></h2
<div class="clrT2 txSm helper"><%= ob.polyT('editListing.helperTags') %></div>
</section>

<section class="js-scrollToSection categorySection contentBox padMd clrP clrBr clrSh3 tx3">
<section class="js-scrollToSection contentBox padMd clrP clrBr clrSh3 tx3 js-sectionShippingFrom shippingFromSection">
<h2 class="h4 clrT"><%= ob.polyT('editListing.sectionNames.sendLocation') %></h2>
<hr class="clrBr rowMd" />
<% if (ob.errors['item.sendLocation']) print(ob.formErrorTmpl({ errors: ob.errors['item.sendLocation'] })) %>
Expand Down
5 changes: 3 additions & 2 deletions js/templates/modals/listingDetail/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ <h2 class="flexExpand js-cryptoTitle cryptoTitle"></h2>
<% } %>
</div>
<hr class="rowLg">
<% if(ob.metadata.shippingFromCountryCode !== '' || ob.metadata.shippingFromPostalCode !== '') { %>
<% if (ob.metadata.contractType === 'PHYSICAL_GOOD') { %>
<% if (ob.metadata.shippingFromCountryCode !== '' || ob.metadata.shippingFromPostalCode !== '') { %>
<h5><%= ob.polyT('editListing.sendLocation.shippingFromLabel') %></h5>
<div class="rowLg">
<% if(ob.metadata.shippingFromCountryCode !== '') { %>
Expand All @@ -212,7 +213,7 @@ <h5><%= ob.polyT('editListing.sendLocation.shippingFromLabel') %></h5>
<%= ob.polyT('editListing.sendLocation.shippingFromPostalCodeLabel') %>: <%= ob.metadata.shippingFromPostalCode %>
<% } %>
</div>
<% } %>
<% } } %>
<h5><%= ob.polyT('listingDetail.tags') %></h5>
<div class="tagWrapper rowLg">
<% ob.item.tags.forEach(function(tag){
Expand Down
3 changes: 3 additions & 0 deletions js/views/modals/editListing/EditListing.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ export default class extends BaseModal {
// If the type is not 'PHYSICAL_GOOD', we'll clear out any shipping options.
if (metadata.get('contractType') !== 'PHYSICAL_GOOD') {
this.model.get('shippingOptions').reset();
const m = this.model.get('metadata');
m.set('shippingFromCountryCode', 'NA');
m.set('shippingFromPostalCode', '');
} else {
// If any shipping options have a type of 'LOCAL_PICKUP', we'll
// clear out any services that may be there.
Expand Down
9 changes: 9 additions & 0 deletions styles/modules/modals/_editListing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@

.tab-shipping,
.shippingSection,
.shippingFromSection,
.conditionWrap {
display: none;
}
Expand All @@ -341,6 +342,14 @@
}
}

&.TYPE_PHYSICAL_GOOD {
.tab-shippingFrom,
.conditionWrap,
.shippingFromSection {
display: block;
}
}

&.TYPE_CRYPTOCURRENCY {
.tab-variants,
.tab-coupons {
Expand Down

0 comments on commit fa98ecb

Please sign in to comment.