Jump to content

How to migrate an override from the old Admin Order template (tpl) to the new Symfony (twig) system?


Matt E
 Share

Recommended Posts

I'm surprised this is still an issue, but the new Admin Order page does not calculate/display discounted products correctly (or at all). To fix this in 1.7.6.X, I created a general override to the back office order detail page by adding the following lines in (controllers\admin\templates\orders\helpers\view.tpl):

{* CUSTOM column added to show discount *}
{assign var="isDiscount" value="False"}
{foreach from=$products item=product key=k}
  {if $product.reduction_percent > 0}
   {$isDiscount = "True"}
  {/if}
{/foreach}                  
<th class="text-center">
  {if $isDiscount == "True"}
  <span class="title_box ">{l s='Discount' d='product.discount'} %</span>
  {/if}
</th>

I also made the following edits to (controllers\admin\templates\orders\_product_line.tpl) and (controllers\admin\templates\orders\_customized_data.tpl):

Changed from:

<span class="product_price_show">{displayPrice price=$product_price currency=$currency->id}</span>

To:

<span class="product_price_show">{displayPrice price=$orig_price currency=$currency->id}</span>

Added:

  {* CUSTOM column added to show discount *}
  <td class="productQuantity text-center reduction">
    {if $product.reduction_percent > 0}
      {$product.reduction_percent} %
    {/if}
  </td>

This had the overall intended effect of showing the original price before reductions, and then showing the discount only for line items with a specific price reduction.

I recently updated to 1.7.7.1 and noticed the entire back office order detail page has been reworked from Admin template files (.tpl) to Symfony (.twig), so all of those overrides are now obsolete.  It seems this information is now contained within (src\PrestaShopBundle\Resources\views\Admin\Sell\Order\Order\Blocks\View) in the file product.html.twig.

What is the best way to override this file to recreate the same result as the previous overrides (which were working as intended) without directly modifying the core files?

Edited by Matt E (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More