Created
July 5, 2017 07:23
-
-
Save tvlgiao/327e87dfad937181eca3d5f8c2d6bb8b to your computer and use it in GitHub Desktop.
BigCommerce Show Bulk Pricing Table inline on the product details page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/templates/components/products/product-view.html b/templates/components/products/product-view.html | |
index 768a46a..83379c8 100644 | |
--- a/templates/components/products/product-view.html | |
+++ b/templates/components/products/product-view.html | |
@@ -109,6 +109,41 @@ | |
{{/if}} | |
{{/if}} | |
{{/if}} | |
+ {{#if product.bulk_discount_rates.length}} | |
+ <dt class="productView-info-name">{{lang 'products.bulk_pricing.title'}}</dt> | |
+ <dd class="productView-info-value"> | |
+ <a href="{{product.url}}" | |
+ {{#unless is_ajax }}data-reveal-id="bulkPricingModal" {{/unless}}> | |
+ {{lang 'products.bulk_pricing.view'}} | |
+ </a> | |
+ </dd> | |
+ | |
+ <div id="bulkPricingModal" class="modal modal--small" data-reveal> | |
+ <div class="modal-header"> | |
+ <h2 class="modal-header-title">{{lang 'products.bulk_pricing.modal_title'}}</h2> | |
+ <a href="#" class="modal-close" aria-label="Close"><span aria-hidden="true">×</span></a> | |
+ </div> | |
+ <div class="modal-body"> | |
+ <p>{{lang 'products.bulk_pricing.instructions'}}</p> | |
+ <ul> | |
+ {{#each product.bulk_discount_rates}} | |
+ <li> | |
+ {{lang 'products.bulk_pricing.range' min=min max=max}} | |
+ {{#if type '===' 'percent'}} | |
+ {{lang 'products.bulk_pricing.percent' discount=discount.formatted}} | |
+ {{/if}} | |
+ {{#if type '===' 'fixed'}} | |
+ {{lang 'products.bulk_pricing.fixed' discount=discount.formatted}} | |
+ {{/if}} | |
+ {{#if type '===' 'price'}} | |
+ {{lang 'products.bulk_pricing.price' discount=discount.formatted}} | |
+ {{/if}} | |
+ </li> | |
+ {{/each}} | |
+ </ul> | |
+ </div> | |
+ </div> | |
+ {{/if}} | |
{{#each product.custom_fields}} | |
{{#if name '!=' 'Case Pack'}} | |
@@ -206,49 +241,6 @@ | |
</div> | |
- {{#if product.bulk_discount_rates.length}} | |
- <table class="table"> | |
- <tbody class="table-tbody"> | |
- <tr> | |
- <td>Quantity</td> | |
- {{#each product.bulk_discount_rates}} | |
- <td>{{lang 'products.bulk_pricing.range' min=min max=max}}</td> | |
- {{/each}} | |
- </tr> | |
- <tr> | |
- <td>Per Piece</td> | |
- {{#each product.bulk_discount_rates}} | |
- <td> | |
- {{#if type '===' 'percent'}} | |
- {{../../settings.money.currency_token}}{{multiple ../../product.price.without_tax.value discount.value}} | |
- {{/if}} | |
- {{#if type '===' 'fixed'}} | |
- {{lang 'products.bulk_pricing.fixed' discount=discount.formatted}} | |
- {{/if}} | |
- {{#if type '===' 'price'}} | |
- {{../../settings.money.currency_token}}{{divide (round (multiply (subtract ../../product.price.without_tax.value discount.value) 100)) 100}} | |
- {{/if}} | |
- </td> | |
- {{/each}} | |
- </tr> | |
- <tr> | |
- <td>Savings</td> | |
- {{#each product.bulk_discount_rates}} | |
- {{#if type '===' 'percent'}} | |
- {{lang 'products.bulk_pricing.percent' discount=discount.formatted}} | |
- {{/if}} | |
- {{#if type '===' 'fixed'}} | |
- {{../../settings.money.currency_token}}{{subtract ../../product.price.without_tax.value discount.value}} | |
- {{/if}} | |
- {{#if type '===' 'price'}} | |
- <td>{{divide (round (multiply (divide discount.value ../../product.price.without_tax.value) 10000) 2) 100}}%</td> | |
- {{/if}} | |
- {{/each}} | |
- </tr> | |
- </tbody> | |
- </table> | |
- {{/if}} | |
- | |
{{#if product.can_purchase}} | |
<ul class="accordion" data-accordion> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello sir, great job but this really does not work well as the ../../product.price.without_tax.value only reflect the initial product price, it does not change with Options that involve price increases. So if the product initial cost is $100, let's say a customer selects a red color tshirt for 25 more, the code above will only calculate from the initial $100 value, not new $125 value. What would be the correct price variable to call to fix this?