Create your own ecommerce website and start selling successfully with ShopWired today
Bulk pricing discount tables
Before you proceed: |
Pro tip!
If you are using a version 3 or version 4 theme you won't need to add this code to your theme's files to produce these tables. Instead, you just need to activate a setting in your theme's settings.
If you're using the Bulk Discounts app then you may want to display, on your product pages, a table (or tables) that display the bulk discounts that you offer, as shown in the example below.
If you sell a product that has variations, and you set different prices for the variations (and so different bulk discounts are applicable) then you can display multiple tables on the product page - one for each variation.
Adding the code below will add the tables to products that have bulk pricing discounts set.
1. Locate the product.twig file (located in /views/product pages/product.twig)
2. You'll need to add the code shown below where you would like to display the table
{% if product.bulk_prices %} <table> <h3>Bulk Buy Discounts</h3> <tr> <td>Quantity Purchased</td> <td>Price</td> </tr> {% for bulk_price in product.bulk_prices %} <tr> <td>{{ bulk_price.quantity }}</td> <td>{{ currency_value(bulk_price.value) }}</td> </tr> {% endfor %} </table> {% endif %} |
for example
This will display a table for bulk discount pricing on the product. If your product has variations, and you have set bulk pricing rules for the variations, then the table above will not display.
3. We recommend that you only add the code for the display of bulk discounts for variations if you have products that have variations and will be setting bulk pricing rules for them.
Here's the code
{% if product.bulk_variations %} {% for variation in product.bulk_variations %} <h3>{{ variation.title }}</h3> <table> <tr> <td>Quantity Purchased</td> <td>Price</td> </tr> {% for bulk_price in variation.prices %} <tr> <td>{{ bulk_price.quantity }}</td> <td>{{ currency_value(bulk_price.value) }}</td> </tr> {% endfor %} </table> {% endfor %} {% endif %} |
for example
You should put both the normal product discount table code and the product variation discount table code onto the page (not just the variation discount table code).
Please Note: The code above has no styling, so it will need to be styled (with CSS or inline styles) to display nicely.
Global bulk discounts
If you're setting bulk discounts for products as percentage discounts using the feature described in this help guide, then to display a table containing these discounts you'll need to use the code shown below.
{% if product.bulk_discounts %} <table> <h3>Bulk Buy Discounts</h3> <tr> <td>Quantity Purchased</td> <td>Discount</td> </tr> {% for discount in product.bulk_discounts %} <tr> <td>{{ discount.quantity }}</td> <td>{{ discount.percent }}%</td> </tr> {% endfor %} </table> {% endif %} |
The {{ discount.percent }} variable will return the % discount, not the price of the product with the discount applied.
Please Note: As with the code further up this article, the above code above has no styling, so it will need to be styled (with CSS or inline styles) to display nicely.