Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display custom fields under "Specifications" tab on PDP #1295

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Changelog

## Draft
- Add option to display custom fields under "Specifications" tab on PDP [#1295](https://github.com/bigcommerce/cornerstone/pull/1295)

## 3.1.0 (2019-01-21)

- Fix for ESLint "func-names" warnings. [#1420](https://github.com/bigcommerce/cornerstone/pull/1420)
- Major performance improvements. Reduce Javascript bundle size from 376kb to 286kb. [#1390](https://github.com/bigcommerce/cornerstone/pull/1390)
- Fixed breadcrumbs for product and category pages [#1403](https://github.com/bigcommerce/cornerstone/pull/1403)
Expand Down
4 changes: 4 additions & 0 deletions assets/scss/components/foundation/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
@include breakpoint("medium") {
padding: spacing("half") spacing("single");
}

@include breakpoint("large") {
padding: remCalc(11px) remCalc(18px);
}
}

.tab-content {
Expand Down
2 changes: 2 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"show_accept_visa": false,
"show_product_details_tabs": true,
"show_product_reviews_tabs": false,
"show_custom_fields_tabs": false,
"show_product_weight": true,
"show_product_dimensions": false,
"product_list_display_mode": "grid",
Expand Down Expand Up @@ -298,6 +299,7 @@
"pdp-sale-price-label": "Now:",
"pdp-non-sale-price-label": "Was:",
"pdp-retail-price-label": "MSRP:",
"pdp-custom-fields-tab-label": "Specifications",
"paymentbuttons-paypal-layout": "horizontal",
"paymentbuttons-paypal-color": "gold",
"paymentbuttons-paypal-shape": "pill",
Expand Down
14 changes: 14 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,20 @@
"force_reload": true,
"id": "show_product_details_tabs"
},
{
"type": "checkbox",
"label": "Product custom fields in tabs",
"force_reload": true,
"id": "show_custom_fields_tabs"
},
{
"type": "text",
"label": "Product custom fields tab label",
"force_reload": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this setting isn't relevant if the above setting isn't checked, we should add

"reference": "show_custom_fields_tabs",
"reference_default": false,

This will cause this setting to be invisible if the above checkbox is not checked

"reference": "show_custom_fields_tabs",
"reference_default": false,
"id": "pdp-custom-fields-tab-label"
},
{
"type": "checkbox",
"label": "Show product weight",
Expand Down
15 changes: 15 additions & 0 deletions templates/components/products/description-tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<a class="tab-title" href="#tab-warranty">{{lang 'products.warranty'}}</a>
</li>
{{/if}}
{{#all product.custom_fields theme_settings.show_custom_fields_tabs}}
<li class="tab">
<a class="tab-title" href="#tab-specs">{{theme_settings.pdp-custom-fields-tab-label}}</a>
</li>
{{/all}}
{{#all settings.show_product_reviews theme_settings.show_product_reviews_tabs product.reviews.total}}
<li class="tab">
<a class="tab-title productView-reviewTabLink" href="#tab-reviews">{{lang 'products.reviews.header' total=product.reviews.total}}</a>
Expand All @@ -23,6 +28,16 @@
{{{product.warranty}}}
</div>
{{/if}}
{{#all product.custom_fields theme_settings.show_custom_fields_tabs}}
<div class="tab-content" id="tab-specs">
<dl class="productView-info">
{{#each product.custom_fields}}
<dt class="productView-info-name">{{name}}:</dt>
<dd class="productView-info-value">{{{value}}}</dd>
{{/each}}
</dl>
</div>
{{/all}}
{{#all settings.show_product_reviews theme_settings.show_product_reviews_tabs}}
<div class="tab-content" id="tab-reviews">
{{> components/products/reviews reviews=product.reviews product=product urls=urls}}
Expand Down
10 changes: 6 additions & 4 deletions templates/components/products/product-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ <h2 class="productView-brand"{{#if schema}} itemprop="brand" itemscope itemtype=
</div>
{{/if}}

{{#each product.custom_fields}}
<dt class="productView-info-name">{{name}}:</dt>
<dd class="productView-info-value">{{{value}}}</dd>
{{/each}}
{{#if theme_settings.show_custom_fields_tabs '!==' true}}
{{#each product.custom_fields}}
<dt class="productView-info-name">{{name}}:</dt>
<dd class="productView-info-value">{{{value}}}</dd>
{{/each}}
{{/if}}
</dl>
</div>
</section>
Expand Down