EspañolEnglish (United Kingdom)

"Web Joomla a medida para tu empresa..."

rss facebook twitter digg youtube vimeo linkedin flickr
14
Dec
2009
Subtotal Virtuemart PDF Print E-mail
Written by kim1   

Working for a client to whom I have developed a template and some modifications for Virtuemart I found the problem that this wonderful program for Joomla! shows (in the case of choosing the product details show prices with taxes) the subtotal of the invoice as if it were the total, we will not make much sense to show us the subtotal plus tax being equal to the total subtotal and the sum of this and taxes.

We can not apply on the variables that these data show arithmetic rules since their values incorporate the currency symbol and are not numbers but strings.

The solution is to clean these non-numeric strings for the removal of subtotal - taxes. Before you begin the actual code we write in components/com_virtuemart/themes/default/templates/basket/basket_b2c.html.php:

  $ Subtotal = str_replace ('€','', $ subtotal_display) 
  $ Tax = str_replace ('$ euro;','', $ tax_display) 

Cambiamostodo foreach loop to display prices without VAT percentage:

  <? Php foreach ($ product_rows as $ product) (?> 
  <tr valign="top"> 
  <td> <? php echo $ product ['product_name'].  $ Product ['product_attributes']?> </ Td> 
  <td> <? php echo $ product ['product_sku']?> </ td> 
  <? Php 
  $ Price = str_replace ('€','', $ product ['product_price']); 
  $ Percent = 16; 
  $ Discount_value = ($ price / 100) * $ Percent; 
  $ Final_price = $ price - $ discount_value; 
  ?> 
  <td align="right"> <? php echo number_format ($ final_price, 2);?> </ td> 
  <td> <? php echo $ product ['update_form']?> 
  <? Php echo $ product ['delete_form']?> 
  </ Td> 
  <td align="right"> <? php echo number_format ($ final_price, 2);?> </ td> 
  </ Tr> 
  <? Php)?> 

And in a few lines below we apply the total by subtracting the tax:

  colspan="3" <td align="right"> <? php echo "€".  ($ Subtotal - $ tax)?> </ Td> 

To be consistent we must apply these changes also in components / com_virtuemart / themes / default / templates / order_emails / confirmation_email.tpl.php so that the confirmation email showing the same results.


blog comments powered by Disqus