Stramm - Photo_shop Plug ??s -- Adding Taxes to the total Stramm - Photo_shop Plug ??s -- Adding Taxes to the total
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Stramm - Photo_shop Plug ??s -- Adding Taxes to the total

Started by Jasondt2001, January 02, 2009, 09:58:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jasondt2001

Stramm, I swear I've tried and tried and tried to do this myself and I just can't get it... Please, would you help me? I've learned alot going about it on my own but not enough to make this one work.

What I'm trying to do is add tax to the TOTAL and have that be the total amount emailed and listed to the user and the administrator.
I've screen shotted and will give you an example, and I also have the tax code setup working the way I need it to. The problem is I can NOT figure out how to add tax to the total amount.


Here is the code I'm using in coppermine/plugins/photo_shop/include/functions.inc.php
//calculate and format total, discount, shipping
function photoshop_format_price($temp_price, $cd_counter, $error='', $template){
global $lang_photoshop, $SHOP_CONFIG;

$out =array();
$discount_calc = calculate_discount($temp_price, $cd_counter);
$shipping_calc = calculate_shipping();
$discount = number_format(($discount_calc),2);
$shipping = number_format(($shipping_calc),2);
$tot_price = number_format(($temp_price[1]+$temp_price[0]+$shipping_calc-$discount_calc),2);
$tax = number_format(($tot_price*.0825),2);
$cd_price = number_format($temp_price[1],2);
$photo_price = number_format($temp_price[0],2);

if ($cd_price > 0) {
$cd_price2 = "{$lang_photoshop['on_cd']}: {$cd_counter['cd']} {$lang_photoshop['pics']} :: $cd_price{$lang_photoshop['USD']}&nbsp;<br />";
} else $cd_price2 = '';
if ($photo_price > 0) {
$photo_price2 = "{$lang_photoshop['for_print']}: {$cd_counter['photo']} {$lang_photoshop['pics']} :: $photo_price{$lang_photoshop['USD']}&nbsp;<br />";
} else $photo_price2 = '';

if ($tot_price > 0) {
if ($shipping > 0) {
$total_price = "{$lang_photoshop['shipping']} :: ".$shipping."{$lang_photoshop['USD']}&nbsp;<br>";
} else $total_price = "";
if ($discount > 0) {
$total_price .= "{$lang_photoshop['discount']} :: % {$discount}{$lang_photoshop['USD']}&nbsp;";
}
$total_price .= "<hr size=\"1\" width=\"200\" align=\"right\" />&nbsp;";
$total_price .= "{$lang_photoshop['total']}: {$tot_price}{$lang_photoshop['USD']}&nbsp;";
} else $tot_price = '';

$out['html'] = <<<EOT
<tr>
<td colspan="6" align="center">
<hr size="1" />
</td>
</tr>
<tr>
<td colspan="6" align="right">
{$photo_price2}
{$cd_price2}{$error}
Tax.: {$tax}{$lang_photoshop['USD']}&nbsp;<br>
{$total_price}

</td>
</tr>
EOT;
$out['text'] = sprintf("%+63s\n\n", '');
if ($photo_price > 0) { $out['text'] .= sprintf("%+63s\n", $lang_photoshop['for_print'].': '. $cd_counter['photo'].' '.$lang_photoshop['pics'].' :: '.$photo_price.$lang_photoshop['USD']); }
if ($cd_price > 0) { $out['text'] .= sprintf("%+63s\n", $lang_photoshop['on_cd'].': '. $cd_counter['cd'].' '.$lang_photoshop['pics'].' :: '.$cd_price.$lang_photoshop['USD']); }
if ($shipping > 0) { $out['text'] .= sprintf("%+63s\n", $lang_photoshop['shipping'].' :: '.$shipping.$lang_photoshop['USD']); }
if ($discount > 0) { $out['text'] .= sprintf("%+63s\n", $lang_photoshop['discount'].' :: %'.$discount.$lang_photoshop['USD']); }
$out['text'] .= sprintf("%+63s\n", 'Incl. MWSt: '.$tax.$lang_photoshop['USD']);
$out['text'] .= sprintf("%+63s\n", '--------------------------');
$out['text'] .= sprintf("%+63s\n", $lang_photoshop['total'].': '.$tot_price.$lang_photoshop['USD']);
return $out[$template];
}


Thank you in advance, I swear if i could have figured this out I would have done it myself!

Stramm

That needs some recoding... as you see I was lazy and did it the easy way with ... 'includes 19% VAT: x.yz USD'

the total is calculated here
$tot_price = number_format(($temp_price[1]+$temp_price[0]+$shipping_calc-$discount_calc),2);

just calc tax and add it... however that won't be enough... there's more you need to modify, eg. photo_shop_checkout.php function photoshop_add_data() ... check if all gets added correctly, IPN will need modifications and maybe a bunch of other files as well (admin, sales history etc.).

Jasondt2001

Ick - Maybe I'll just up the price and do it your way  ;D

Thank you!!

- Jason