Eutanasio Posted March 14, 2022 Share Posted March 14, 2022 Hi, I need to find where and how is the total Tax being calculated for each order. When customers access their account in the Front and go to check the details of an order, I found that this table with the details is located in the file themes > classic > templates > customer > _partials > order-detail-no-return.tpl and I guess that the total TAX value is $line.value, but where is this value calculated? there must be a formula somewhere {block name='order_products_table'} <div class="box hidden-sm-down"> <table id="order-products" class="table table-bordered"> <thead class="thead-default"> <tr> <th>{l s='Product' d='Shop.Theme.Catalog'}</th> <th>{l s='Quantity' d='Shop.Theme.Catalog'}</th> <th>{l s='Unit price' d='Shop.Theme.Catalog'}</th> <th>{l s='Total price' d='Shop.Theme.Catalog'}</th> </tr> </thead> {foreach from=$order.products item=product} <tr> <td> <strong> <a {if isset($product.download_link)}href="{$product.download_link}"{/if}> {$product.name} </a> </strong><br/> {if $product.reference} {l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}<br/> {/if} {if $product.customizations} {foreach from=$product.customizations item="customization"} <div class="customization"> <a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization}">{l s='Product customization' d='Shop.Theme.Catalog'}</a> </div> <div id="_desktop_product_customization_modal_wrapper_{$customization.id_customization}"> <div class="modal fade customization-modal" id="product-customizations-modal-{$customization.id_customization}" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">{l s='Product customization' d='Shop.Theme.Catalog'}</h4> </div> <div class="modal-body"> {foreach from=$customization.fields item="field"} <div class="product-customization-line row"> <div class="col-sm-3 col-xs-4 label"> {$field.label} </div> <div class="col-sm-9 col-xs-8 value"> {if $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {$field.text} {/if} {elseif $field.type == 'image'} <img src="{$field.image.small.url}"> {/if} </div> </div> {/foreach} </div> </div> </div> </div> </div> {/foreach} {/if} </td> <td> {if $product.customizations} {foreach $product.customizations as $customization} {$customization.quantity} {/foreach} {else} {$product.quantity} {/if} </td> <td class="text-xs-right">{$product.price}</td> <td class="text-xs-right">{$product.total}</td> </tr> {/foreach} <tfoot> {foreach $order.subtotals as $line} {if $line.value} <tr class="text-xs-right line-{$line.type}"> <td colspan="3">{$line.label}</td> <td>{$line.value}</td> </tr> {/if} {/foreach} <tr class="text-xs-right line-{$order.totals.total.type}"> <td colspan="3">{$order.totals.total.label}</td> <td>{$order.totals.total.value}</td> </tr> </tfoot> </table> </div> <div class="order-items hidden-md-up box"> {foreach from=$order.products item=product} <div class="order-item"> <div class="row"> <div class="col-sm-5 desc"> <div class="name">{$product.name}</div> {if $product.reference} <div class="ref">{l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}</div> {/if} {if $product.customizations} {foreach $product.customizations as $customization} <div class="customization"> <a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization}">{l s='Product customization' d='Shop.Theme.Catalog'}</a> </div> <div id="_mobile_product_customization_modal_wrapper_{$customization.id_customization}"> </div> {/foreach} {/if} </div> <div class="col-sm-7 qty"> <div class="row"> <div class="col-xs-4 text-sm-left text-xs-left"> {$product.price} </div> <div class="col-xs-4"> {if $product.customizations} {foreach $product.customizations as $customization} {$customization.quantity} {/foreach} {else} {$product.quantity} {/if} </div> <div class="col-xs-4 text-xs-right"> {$product.total} </div> </div> </div> </div> </div> {/foreach} </div> <div class="order-totals hidden-md-up box"> {foreach $order.subtotals as $line} {if $line.value} <div class="order-total row"> <div class="col-xs-8"><strong>{$line.label}</strong></div> <div class="col-xs-4 text-xs-right">{$line.value}</div> </div> {/if} {/foreach} <div class="order-total row"> <div class="col-xs-8"><strong>{$order.totals.total.label}</strong></div> <div class="col-xs-4 text-xs-right">{$order.totals.total.value}</div> </div> </div> {/block} Thanks for the help! Link to comment Share on other sites More sharing options...
ventura Posted March 14, 2022 Share Posted March 14, 2022 There is no record or variable that calculates the taxes paid in the subtotal of the purchase. The logic is set in src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php In the function getProducts() in the array you can add with a comma before 'amount_taxes' => $this->priceFormatter->format( ($this->order->total_products_wt - $this->order->total_products), Currency::getCurrencyInstance((int) $this->order->id_currency) ) And then add in the .tpl file {$line.amount_taxes} 1 Link to comment Share on other sites More sharing options...
Eutanasio Posted March 14, 2022 Author Share Posted March 14, 2022 5 minutes ago, ventura said: There is no record or variable that calculates the taxes paid in the subtotal of the purchase. The logic is set in src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php In the function getProducts() in the array you can add with a comma before 'amount_taxes' => $this->priceFormatter->format( ($this->order->total_products_wt - $this->order->total_products), Currency::getCurrencyInstance((int) $this->order->id_currency) ) And then add in the .tpl file {$line.amount_taxes} Thanks for your answer! as for that formula you shared, this seem to be only the total taxes for the products. Normally it should be (product taxes + shipping taxes + wrapping taxes) isn't it? The issue I have, and that's why I'm trying to understand this, is that in the Front customers can see the total Taxes of the order well, the correct value. But in the admin, in the order details, when an order has shipping fee, the total Taxes I can see are just the shipping taxes (this doesn't happen with free delivery carriers and I'm just using default PS modules, no third parties). In the DB things are cristal clear, I can see all correct values for each order (with and without taxes), but the way PS prints this values in the Front and BO, I just don't understand it Link to comment Share on other sites More sharing options...
ventura Posted March 14, 2022 Share Posted March 14, 2022 if you need the total amount of taxes paid on the order, in src/Adapter/Presenter/Order/OrderLazyArray.php in the the function getAmounts() in the array you can add with a comma before $amounts['totals']['total_amount_tax'] = [ 'type' => 'total_amount_tax', 'label' => $this->translator->trans('Total tax amount (tax excl.)', [], 'Shop.Theme.Checkout'), 'amount' => $order->total_amount_tax, 'value' => $this->priceFormatter->format( ( $order->total_paid_tax_incl - $order->total_paid_tax_excl), Currency::getCurrencyInstance((int) $order->id_currency) ), And then add in the .tpl file {$order.totals.total_amount_tax.value} 1 Link to comment Share on other sites More sharing options...
Eutanasio Posted March 18, 2022 Author Share Posted March 18, 2022 On 3/14/2022 at 3:24 PM, ventura said: if you need the total amount of taxes paid on the order, in src/Adapter/Presenter/Order/OrderLazyArray.php in the the function getAmounts() in the array you can add with a comma before $amounts['totals']['total_amount_tax'] = [ 'type' => 'total_amount_tax', 'label' => $this->translator->trans('Total tax amount (tax excl.)', [], 'Shop.Theme.Checkout'), 'amount' => $order->total_amount_tax, 'value' => $this->priceFormatter->format( ( $order->total_paid_tax_incl - $order->total_paid_tax_excl), Currency::getCurrencyInstance((int) $order->id_currency) ), And then add in the .tpl file {$order.totals.total_amount_tax.value} I think I found my problem, is the table ps_order_detail_tax, it is not recording all tax details of all order and I was wondering if this table is conditioned by the order's status generating or not invoices, do you know? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now