I'm trying to add a few lines to Spree admin.
File I would like to override:
backend/app/views/spree/admin/orders/_shipment.html.erb
I want to add it here:
<tr class="show-tracking total">
<td colspan="5" class="tracking-value">
<% if shipment.tracking.present? %>
<strong><%= Spree.t(:tracking) %>:</strong> <%= shipment.tracking %>
<% else %>
<%= Spree.t(:no_tracking_present) %>
<% end %>
</td>
</tr>
My override is:
<!-- insert_after '.tracking-value' -->
</br>
<strong><%= Spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br>
<% if shipment.date_delivered? %>
<strong><%= Spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br>
<% end %>
located in app/overrides/spree/admin/orders/shipment/add_tracking_info.html.erb.deface
Content:
</br>
<strong><%= Spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br>
<% if shipment.date_delivered? %>
<strong><%= Spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br>
<% end %>
I would like to render:
<tr class="show-tracking total">
<td colspan="5" class="tracking-value">
<% if shipment.tracking.present? %>
<strong><%= Spree.t(:tracking) %>:</strong> <%= shipment.tracking %>
</br>
<strong><%= Spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %</br>
<% if shipment.date_delivered? %>
<strong><%= Spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br>
<% end %>
<% else %>
<%= Spree.t(:no_tracking_present) %>
<% end %>
</td>
</tr>
any help regarding this issue would be greatly appreciated, thank you so much!
You are missing a step. In a very abstract fashion you need to tell spree where and what you need to insert.
The following that is copied from a project I was working till yesterday. What does is it instructs
Deface
to add the partial 'spree/admin/shared/admin_order_custom_detailsjust after the dom element identified by
header#order_tab_summary > dl.additional-info`.So as I see what you need to do is
html.erb.deface
to justhtml.erb
and move it to some where such that it will be likeapp/views/spree/admin/orders/add_order_detials_to_shipment.html.erb
app/overides/
(spoiler alert, make it a meaningful alert or regret later)erb[silent]:contains('if shipment.tracking.present?')
insert_bottom
instead ofinsert_after
I have not run this, but I believe this is what you are looking for.
PS
After reading that section of the doc, which I wasn't aware there was a DSL for Deface, I think you need to update the DSL such that