Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can someone explain this part of the paypal express script?


baps

Recommended Posts

Hi folks,

 

Hit a slight problem with transactions with more than one item quantity. The installation (v2.3.1) this is on has some issues with the tax implementation, but I'm not quite sure what the purpose of the following piece of script is in the paypal express script (ext\modules\payment\paypal\express.php).

 

 $nProd = sizeof($order->products);
 $subtotal = 0;
 for ($i = 0; $i < $nProd; ++$i) {
	 $subtotal += $paypal_express->format_raw($order->products[$i]['final_price']) * $order->products[$i]['qty'];
 }
 $difst = 0;
 if ($subtotal != $paypal_express->format_raw($order->info['subtotal'])) {
	 $difst = $paypal_express->format_raw($order->info['subtotal']) - $subtotal;
 }
 $order->products[$nProd - 1]['final_price'] += $difst;

 

Can anyone explain the purpose of this? I'm not quite sure why the script seems to be comparing the order subtotal to an aggregate product total, and then offsetting the last item by that difference?

 

Many thanks,

 

Baps.

Link to comment
Share on other sites

I would surmise that they are correcting for any difference between the sum of totals with tax and tax applied to the total price. It's not uncommon for there to be a penny or so difference, and they're just hiding it by adjusting one item's price. The alternative is to have the customer complaining that price totals don't add up.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...