Re: Issue With Migration to Shopify Order Printer

Issue With Migration to Shopify Order Printer

nadeem3
Visitor
3 0 0

Hi,

 

Hope someone is able to assist me.

Been trying to rectify the issue with order printer code for over two months.

 

If i view these two codes separately and on individual invoices  it seems to be perfect but as soon as I want to use print both the packing slip and the invoice information seems missing as well as format changes.

 

Invoice code  

 

<div class="legacy"><p style="float: right; text-align: right; margin: 0;font-size:11px">
{{ "now" | date: "%m/%d/%y" }}<br />
Invoice for {{ order.order_name }}
</p>

<div style="float: left; margin: 0 0 1.5em 0;font-size:11px" >
<div>
{{ shop.address.address1 }}<br/>
{{ shop.address.city }} {{ shop.address.province_code }} {{ shop.address.zip | upcase }}<br/>
{{ shop.address.country }}
{{ shop.phone_number }}
</div>

<hr />

<h3 style="margin: 0 0 1em 0;">Item Details</h5>

<table class="table-tabular" style="margin: 0 0 1.5em 0;font-size:11px;">
<thead>
<tr>
<th>Quantity</th>
<th>Item</th>
<th>Description</th>
{% if order.tax_lines.size > 0 %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% # - Shopify migration: replicating behaviour of line_items variable %}
{% assign shopify_migrated_refunded_line_items = refunds | map: "refund_line_items" | map: "line_item" %}
{% assign shopify_migrated_line_items = order.line_items | concat: shopify_migrated_refunded_line_items | concat: order.tip_line_items | uniq %}
{% for line_item in shopify_migrated_line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td>{{ line_item.product.featured_image | product_img_url: 'thumb' | img_tag }} </td>
<td><b>{{ line_item.title }}</b></td>
{% if line_item.tax_lines.size > 0 %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<br/>
{% endfor %}
</td>
{% endif %}
<td>{{ line_item.price | money }}</td>
</tr>
{% endfor %}
</tbody>
</table>

{% if order.transactions.size > 1 %}
<h3 style="margin: 0 0 1em 0;">Transaction Details</h3>
<table class="table-tabular" style="margin: 0 0 1.5em 0;font-size:11px">
<thead>
<tr>
<th>Type</th>
<th>Amount</th>
<th>Kind</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for transaction in order.transactions %}
<tr>
<td>{{ transaction.gateway | payment_method }}</td>
<td>{{ transaction.amount | money }}</td>
<td>{{ transaction.kind }}</td>
<td>{{ transaction.status }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}

<h3 style="margin: 0 0 1em 0;">Payment Details</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;font-size:11px">

<tr>
<td>Payment Method: {{ order.gateway }}</td>
<td>{{ transaction.kind }}</td>
</tr>
<tr>
<td>Subtotal price:</td>
<td>{{ order.subtotal_price | money }}</td>
</tr>
{% for discount in order.discounts %}
<tr>
<td>Includes discount "{{ discount.title }}"</td>
<td>{{ discount.savings | money }}</td>
</tr>
{% endfor %}
<tr>
<td>Total tax:</td>
<td>{{ order.tax_price | money }}</td>
</tr>
{% if order.shipping_address %}
<tr>
<td>Shipping:</td>
<td>{{ order.shipping_price | money }}</td>
</tr>
{% endif %}
<tr>
<td><strong>Total price:</strong></td>
<td><strong>{{ order.total_price | money }}</strong></td>
</tr>
{% if order.net_payment != order.total_price %}
<tr>
<td><strong>Total paid:</strong></td>
<td><strong>{{ order.net_payment | money }}</strong></td>
</tr>
<tr>
<td><strong>Outstanding Amount:</strong></td>
<td><strong>{{ order.total_price | minus: order.net_payment | money }}</strong></td>
</tr>
{% endif %}
</table>

{% if order.note %}
<h3 style="margin: 0 0 1em 0;font-size:11px">Note</h3>
<p>{{ order.note }}</p>
{% endif %}

{% if order.shipping_address %}
<h3 style="margin: 0 0 1em 0;">Shipping Details</h3>

<div style="margin: 0 0 1em 0; padding: 1em; border: 1px solid black;font-size:11px">
<strong>{{ order.shipping_address.name }}</strong><br/>
{% if order.shipping_address.company %}
{{ order.shipping_address.company }}<br/>
{% endif %}
{{ order.shipping_address.street }}<br/>
{{ order.shipping_address.city }}
{{ order.shipping_address.province_code }}
{{ order.shipping_address.zip | upcase }}<br/>
{{ order.shipping_address.country }}
</div>
{% endif %}

{% for attribute in order.attributes %}
{% capture key %}{{ attribute | first }}{% endcapture %}
{% if key == 'Checkout-Method' or key == 'Pickup-Location-Id' %}
{% comment %}Display nothing{% endcomment %}
{% elsif key == 'Pickup-Date' %}
Pickup Date: {{ attribute | last }}
{% elsif key == 'Pickup-Time' %}
Pickup Time: {{ attribute | last }}
{% elsif key == 'Delivery-Date' %}
Delivery Date: {{ attribute | last }}
{% elsif key == 'Delivery-Time' %}
Delivery Time: {{ attribute | last }}
{$ else %}
{{ attribute | first }}: {{ attribute | last }}
{% endif %}
{% endfor %}

<h3 style="margin: 0 0 1em 0;">Returns & Refunds</h3>
<p>Please ensure that you are completely satisfied with ALL the goods delivered to you.</p>
<strong><p>Perishable Goods:</strong><br/></p>
<p>If you are for any reason dissatisfied with any perishable goods (i.e. Fresh Fruit & Vegetables, Milk, Bread etc.) purchased online, you may return it within 3 days of purchase for a full refund, replacement, store credit or exchange, provided you have the original tax invoice. Due to the nature of Perishable Goods, we do not accept further returns or exchanges once the 3 day period has lapsed.</p>
<strong><p>Non-Perishable Goods:</strong><br/></p>
<p>If you are for any reason dissatisfied with any non- perishable goods (i.e. Canned Goods, Detergents, Cereals etc.) purchased online, you may return it within 7 days of purchase for a full refund, replacement, store credit or exchange, provided you have the original tax invoice. Once the 7 day period has lapsed we will exchange or provide store credit on non-perishable items up to 30 days after the date of purchase.</p>
<p> If you have any questions, please send an email to <u>{{ shop.email }}</u></p>


</div>

 

Packing slip code 

 

<div class="legacy">{% if order.shipping_address %}
<div style="padding: 1.5em; border: 1px solid black;">
<h4 style="margin: 0 0 0.5em 0;">Order Number: {{ order.order_number }}</h4>
<h4 style="margin: 0 0 0.5em 0;"<td>Payment Method: {{ order.gateway }}</td>
<h4 style="margin: 0 0 0.5em 0;">Notes: {{ order.note }}</h4>
<h4 style="margin: 0 0 0.5em 0;">Phone No.: {{ order.shipping_address.phone }}</h4>
<h4 style="margin: 0 0 0.5em 0;">Recipient: {{ order.shipping_address.name }}</h4>
{% if order.shipping_address.company %}
{{ order.shipping_address.company }}<br/>
{% endif %}
{{ order.shipping_address.street }}<br/>
{{ order.shipping_address.city }} {{ order.shipping_address.province_code }} {{ order.shipping_address.zip | upcase }}<br/>
{{ order.shipping_address.country }}{% for attribute in order.attributes %}
{% capture key %}{{ attribute | first }}{% endcapture %}
{% if key == 'Checkout-Method' or key == 'Pickup-Location-Id' %}
{% comment %}Display nothing{% endcomment %}
{% elsif key == 'Pickup-Date' %}
Pickup Date: {{ attribute | last }}
{% elsif key == 'Pickup-Time' %}
Pickup Time: {{ attribute | last }}
{% elsif key == 'Delivery-Date' %}
Delivery Date: {{ attribute | last }}
{% elsif key == 'Delivery-Time' %}
Delivery Time: {{ attribute | last }}
{$ else %}
{{ attribute | first }}: {{ attribute | last }}
{% endif %}
{% endfor %}
{% for attribute in order.attributes %}
{% capture key %}{{ attribute | first }}{% endcapture %}
{% if key == 'Checkout-Method' or key == 'Pickup-Location-Id' %}
{% comment %}Display nothing{% endcomment %}
{% elsif key == 'Pickup-Date' %}
Pickup Date: {{ attribute | last }}
{% elsif key == 'Pickup-Time' %}
Pickup Time: {{ attribute | last }}
{% elsif key == 'Delivery-Date' %}
Delivery Date: {{ attribute | last }}
{% elsif key == 'Delivery-Time' %}
Delivery Time: {{ attribute | last }}
{$ else %}
{{ attribute | first }}: {{ attribute | last }}
{% endif %}
{% endfor %}
</div>
{% endif %}

<div style="margin: 0 0 1.5em 0; padding: 1.5em; border: 1px solid black;">
<h4 style="margin: 0 0 0.5em 0;">Sender: {{ shop.name }}</h4>
{{ shop.address.address1 }}<br/>
{{ shop.address.city }} {{ shop.address.province_code }} {{ shop.address.zip | upcase }}<br/>
{{ shop.address.country }}
</div>

</div>

 

 

Thank you 

Replies 2 (2)

EcomGraduates
Shopify Partner
735 63 105

It looks like there might be conflicts when combining the invoice and packing slip codes. Try integrating both into one template by ensuring each section is properly enclosed and separated.

 

 <p style="float: right; text-align: right; margin: 0; font-size: 11px">
    {{ "now" | date: "%m/%d/%y" }}<br />
    Invoice for {{ order.order_name }}
  </p>
  <div style="float: left; margin: 0 0 1.5em 0; font-size: 11px">
    <div>
      {{ shop.address.address1 }}<br/>
      {{ shop.address.city }} {{ shop.address.province_code }} {{ shop.address.zip | upcase }}<br/>
      {{ shop.address.country }}<br/>
      {{ shop.phone_number }}
    </div>
  </div>
  <hr />

 

 {% if order.shipping_address %}
  <div style="padding: 1.5em; border: 1px solid black;">
    <h4 style="margin: 0 0 0.5em 0;">Order Number: {{ order.order_number }}</h4>
    <h4 style="margin: 0 0 0.5em 0;">Payment Method: {{ order.gateway }}</h4>
    <h4 style="margin: 0 0 0.5em 0;">Notes: {{ order.note }}</h4>
    <h4 style="margin: 0 0 0.5em 0;">Phone No.: {{ order.shipping_address.phone }}</h4>
    <h4 style="margin: 0 0 0.5em 0;">Recipient: {{ order.shipping_address.name }}</h4>
    {% if order.shipping_address.company %}
    {{ order.shipping_address.company }}<br/>
    {% endif %}
    {{ order.shipping_address.street }}<br/>
    {{ order.shipping_address.city }} {{ order.shipping_address.province_code }} {{ order.shipping_address.zip | upcase }}<br/>
    {{ order.shipping_address.country }}
    {% for attribute in order.attributes %}
    {% capture key %}{{ attribute | first }}{% endcapture %}
    {% if key == 'Checkout-Method' or key == 'Pickup-Location-Id' %}
    {% comment %}Display nothing{% endcomment %}
    {% elsif key == 'Pickup-Date' %}
    Pickup Date: {{ attribute | last }}
    {% elsif key == 'Pickup-Time' %}
    Pickup Time: {{ attribute | last }}
    {% elsif key == 'Delivery-Date' %}
    Delivery Date: {{ attribute | last }}
    {% elsif key == 'Delivery-Time' %}
    Delivery Time: {{ attribute | last }}
    {% else %}
    {{ attribute | first }}: {{ attribute | last }}
    {% endif %}
    {% endfor %}
  </div>
  {% endif %}

 

 

  <div style="margin: 0 0 1.5em 0; padding: 1.5em; border: 1px solid black;">
    <h4 style="margin: 0 0 0.5em 0;">Sender: {{ shop.name }}</h4>
    {{ shop.address.address1 }}<br/>
    {{ shop.address.city }} {{ shop.address.province_code }} {{ shop.address.zip | upcase }}<br/>
    {{ shop.address.country }}
  </div>
</div>

If this fixed your issue, likes and accepting as a solution are highly appreciated.

Build an online presence with our custom built Shopify Theme EcomifyTheme




nadeem3
Visitor
3 0 0

Thank you for the response.

 

how do I create a page break to separate the templates