Zen Cart Logo
Forums / Customization from the Admin / Onetime charges calculated in the total price

Onetime charges calculated in the total price

Views: 1,189

Results 1 to 2 of 2
02 Sep 2011, 08:28
#1
shockraver avatar

shockraver

New Zenner

Join Date:
Nov 2004
Posts:
47
Plugin Contributions:
0

Onetime charges calculated in the total price

Hi,

I've been working on this for quite some time and still haven't got it the way i want.

All our products on the website have attributes with onetime charges on them.
the onetime charges are shown seperately on the confirmation page, shopping-cart, confirmation email, and invoice.

What i want is that the onetime charge is added to the product price, so that the customer is only shown one price (the total price including the onetime charges)

this works correctly if the customer buys the product x1. if the customer buys the product x2, then the onetime charge of the attribute is also x2.
(the total price xcl. vat and incl vat in orders_total is shown correctly by the way, but not the products price)

The code i have been using for this (example, invoice.php around line 167)

$otc = $order->products[$i]['onetime_charges'];
      echo '        </td>' . "\n" .
       
           '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price']+$otc, $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
                     
                    '</b></td>' . "\n";
      echo '      </tr>' . "\n";
    }

now i have altered this to:

$otc = $order->products[$i]['onetime_charges'];
      echo '        </td>' . "\n" .

          '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty']+$otc, true, $order->info['currency'], $order->info['currency_value']) .
                     
                    '</b></td>' . "\n";
      echo '      </tr>' . "\n";

So now it displays corretly on the invoice, but then the confirmation emails.
There it is still shown wrong.... let me show the code of order.php

      // build output for email notification
	    $otc = $this->products[$i]['onetime_charges'];
      $this->products_ordered .=  $this->products[$i]['qty'] . ' x ' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') . ' = ' .
      $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) .
      ($this->products[$i]['onetime_charges'] !=0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') .
      $this->products_ordered_attributes . "\n";
      $this->products_ordered_html .=
      '<tr>' . "\n" .
      '<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . ' x</td>' . "\n" .
      '<td class="product-details" valign="top">' . nl2br($this->products[$i]['name']) . ($this->products[$i]['model'] != '' ? ' (' . nl2br($this->products[$i]['model']) . ') ' : '') . "\n" .
      '<nobr>' .
      '<small><em> '. nl2br($this->products_ordered_attributes) .'</em></small>' .
      '</nobr>' .
      '</td>' . "\n" .
      '<td class="product-details-num" valign="top" align="right">' .
      $currencies->display_price($this->products[$i]['final_price']+$otc, $this->products[$i]['tax'], $this->products[$i]['qty']) .
      ($this->products[$i]['onetime_charges'] !=0 ?
      '</td></tr>' . "\n" . '<tr><td class="product-details"></td>' . "\n" .
      '<td style="display:none;">' . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') . '</td></tr>' . "\n"; 
    }

i tried putting the +$otc on different places, but it seems the quantity is coded different here ?

i know it's all a bit a messy explanation. basicly we don't want to show the onetime charge to the customer.... just add it to the productprice. which is going ok, if customer buys product x1, not multiple...

hope someone understands and can help me.

26 Aug 2013, 15:12
#2
dalmen avatar

dalmen

New Zenner

Join Date:
Jan 2013
Location:
Utah
Posts:
20
Plugin Contributions:
0

Re: Onetime charges calculated in the total price

I'm looking for the same thing. Has this been answered someplace else by now?