Skip to content

Instantly share code, notes, and snippets.

@boldsupport
Last active October 12, 2017 18:31
Show Gist options
  • Save boldsupport/5775c64cc77ec20d6f04eb42aacb546a to your computer and use it in GitHub Desktop.
Save boldsupport/5775c64cc77ec20d6f04eb42aacb546a to your computer and use it in GitHub Desktop.
Tier 2 Fix for Product Options v2 - Order Printer Template - Linked from: https://support.boldcommerce.com/hc/en-us/articles/115005175743-Order-Printer-Template-for-Product-Options-v2
<!-- Bold tips
You can cut and paste this complete basic template
or copy and paste the 2 Bold blocks before and after the "for line in line_item" loop,
adding these 3 items to your own template
{{ bold_options }}
{{ bold_item_price }}
{{ bold_line_price }}
where you want options, item price or line price to display
***************** -->
<div class="row">
<div class="col-xs-12 col-no-margin">
<table class="order-table table">
<thead>
<tr>
<th colspan=2 class="order-table-title editable" data-key="item">Item Description</th>
<th class="order-table-qty text-center editable" data-key="qty">Qty</th>
<th class="order-table-price text-right editable" data-key="price">Price</th>
<th class="order-table-item-total text-right editable" data-key="item_total">Item Total</th>
</tr>
</thead>
<tbody>
<!-- Bold 1 -->
{% assign hidden_variant_ids = "" %}
{% for line in line_items %}
{% for prop in line.properties %}
{% if prop.first == "_boldVariantIds" %}
{% assign hidden_variant_ids = hidden_variant_ids | append: prop.last | append: ',' %}
{% endif %}
{% endfor %}
{% endfor %}
<!-- Bold 1 -->
{% for line in line_items %}
<!-- Bold 2 -->
{% assign variant_id = line.variant_id | append: "" %}
{% if hidden_variant_ids contains variant_id %}{% continue %}{% endif %}
{% assign bold_item_price = line.price %}
{% assign bold_line_price = line.line_price %}
{% assign bold_var_ids = "" %}
{% assign price_index = "" %}
{% assign bold_qtys = "" %}
{% for prop2 in line.properties %}
{% if prop2.first == "_boldVariantIds" %}
{% assign bold_var_ids = prop2.last | split: "," %}
{% elsif prop2.first == "_boldVariantPrices" %}
{% assign price_index = prop2.last | split: "," %}
{% elsif prop2.first == "_boldVariantQtys" %}
{% assign bold_qtys = prop2.last | split: "," %}
{% endif %}
{% endfor %}
{% unless price_index == "" && bold_var_ids == "" %}
{% for price in price_index %}
{% assign bold_qty = 1 %}
{% if bold_qtys.length > 0 %}{% assign bold_qty = bold_qtys[forloop.index0] %}{% endif %}
{% assign bold_item_price = bold_item_price | plus: price %}
{% assign temp_price = price | times: bold_qty %}
{% assign bold_line_price = bold_line_price | plus: temp_price %}
{% endfor %}
{% endunless %}
{% assign bold_options = " " %}
{% for bold_option in line.properties %}
{% assign first_char = bold_option.first | slice: 0, 1 %}
{% assign opt_title = bold_option | first %}
{% assign opt_desc = bold_option | last %}
{% unless first_char == '_' or first_char=='_boldOptionLocalStorageId' or bold_option.first == 'master_builder' or bold_option.first == 'builder_id' or bold_option.first == '_boldOptionLocalStorageId' or bold_option.first == 'builder_info' or bold_option.last == "" %}
{% assign bold_options = bold_options | append: '<br />' | append: opt_title | append: ': ' | append: opt_desc %}
{% endunless%}
{% endfor %}
{% assign bold_options = bold_options | prepend: '<span class="bold_options">' | append: "</span>" %}
<!-- end Bold 2 -->
<tr>
<td class="product-image-wrapper">{% if line.image != blank %}<img class="product-image" src="{{ line.image | img_url: 'medium' }}"/>{% endif %}</td>
<td class="line-item-description">
{{ line.title | replace: " - Default Title", "" }}
{% if line.sku != blank %}
<p class="line-item-sku">SKU: {{ line.sku }}</p>
{% endif %}
{{ bold_options }}
</td>
<td class="text-center line-item-qty">× {{ line.quantity }}</td>
<td class="text-right no-wrap line-item-price">
{% if line.variant.price > line.price %}
{% assign original_price = line.variant.price %}
{% elsif line.variant.compare_at_price > line.price %}
{% assign original_price = line.variant.compare_at_price %}
{% else %}
{% assign original_price = 0 %}
{% endif %}
{% if original_price > 0 %}<s>{{ original_price | money }}</s>
{% endif %}
{{ bold_item_price | money }}
</td>
<td class="text-right no-wrap line-item-line-price">{{ bold_line_price | money }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment