Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

IMPORTANT FIX FOR PAYPAL_IPN_SHOPPING_CART


dailce

Recommended Posts

When you select itemized and charge tax on shipping and tax on the product the original code would not add the correct taxes up.

 

For instance, the total before checkout:

 

Item = $100

Shipping = $10

GST 7% + PST 8% = $15

GST on shipping + PST on shipping = $1.50

Total = $126.50

 

When the buyer checks out the PayPal_Shopping_Cart_IPN brings you to PayPal and only adds the following:

 

Item = $100

Shipping and Handling = $10

Sales Tax (GST 7% + PST 8%) = $15

Total = $125.00

 

It doesn't add/include the tax on shipping. I think I fixed it, well this works but I'm not sure about the call to get the shipping tax:

 

 

Modify

 

include/modules/payment/paypal.php

 

 

//Itemized Order Details
       for ($i=0,$index=1; $i<sizeof($order->products); $i++, $index++) {
         //$index = $i+1;
         $paypal_fields .= tep_draw_hidden_field('item_name_'.$index, $order->products[$i]['name']).
         tep_draw_hidden_field('item_number_'.$index, $order->products[$i]['model']).
         tep_draw_hidden_field('quantity_'.$index, $order->products[$i]['qty']).
         tep_draw_hidden_field('amount_'.$index, number_format($order->products[$i]['final_price']* $my_currency_value,2));
         

$tax = (($order->products[$i]['final_price'] * ($order->products[$i]['tax'] / 100)) +   ($order->info['shipping_cost'] * ($order->products[$i]['tax'] / 100))) * $my_currency_value;


         $paypal_fields .= tep_draw_hidden_field('tax_'.$index, number_format($tax, 2));

 

 

Basically I added:

 

"+ ($order->info['shipping_cost'] * ($order->products[$i]['tax'] / 100))"

 

 

However, I'm not sure if:

 

"order->products[$i]['tax'] "

 

 

is right

 

Is there a way to call it on the shipping, maybe something like:

 

"order->shipping[$i]['tax'] " ??????

 

 

I tested it and it works 100% great!

 

Just need someone with more code experince to verify or correct my syntax.

Link to comment
Share on other sites

I should add that this definatly works.

 

But, I have:

 

"+ ($order->info['shipping_cost'] * ($order->products[$i]['tax'] / 100))"

 

This assumes the tax on shipping is the same as the tax on products, but it should be changed if you were adding a differnet tax rate on shipping.

 

Maybe somehitng like:

 

"+ ($order->info['shipping_cost'] * ($order->shipping[XXXX]['tax'] / 100))"

 

I'm just not great at PHP so if someone knows the way to do it please respond.

Link to comment
Share on other sites

I did more test and with mulitple items there seems to be an error, I'm not sure what going on, but I feel that this is the code to alter to correct the problem I listed above - I know this because aggreate works perfectly.

Link to comment
Share on other sites

        //Itemized Order Details
       for ($i=0,$index=1; $i<sizeof($order->products); $i++, $index++) {
         //$index = $i+1;
         $paypal_fields .= tep_draw_hidden_field('item_name_'.$index, $order->products[$i]['name']).
         tep_draw_hidden_field('item_number_'.$index, $order->products[$i]['model']).
         tep_draw_hidden_field('quantity_'.$index, $order->products[$i]['qty']).
         tep_draw_hidden_field('amount_'.$index, number_format($order->products[$i]['final_price']* $my_currency_value,2));
         $tax = ($order->products[$i]['final_price'] * ($order->products[$i]['tax'] / 100));
         $paypal_fields .= tep_draw_hidden_field('tax_'.$index, number_format($tax, 2));

         //Customer Specified Product Options: PayPal Max = 2
         if ($order->products[$i]['attributes']) {
           //$n = sizeof($order->products[$i]['attributes']);
           for ($j=0; $j<2; $j++) {
             if($order->products[$i]['attributes'][$j]['option']){
               $paypal_fields .= $this->optionSetFields($j,$index,$order->products[$i]['attributes'][$j]['option'],$order->products[$i]['attributes'][$j]['value']);
             } else {
               $paypal_fields .= $this->optionSetFields($j,$index);
             }
           }
         } else {
           for ($j=0; $j<2; $j++) {
             $paypal_fields .= $this->optionSetFields($j,$index);
           }
         }
       }
     } else { //Aggregate Cart (Method 1)

 

 

 

 

SO does anyone know what to change?

Link to comment
Share on other sites

  • 3 months later...
DAMM ANOTHER BUG.

 

ANY EXPERT CAN DO WHAT I WANT IT TO DO!!!!

 

 

I added this line as per your previous post:

 

"+ ($order->info['shipping_cost'] * ($order->products[$i]['tax'] / 100))"

 

but now it adds the shipping tax twice during Paypal checkout. Were you ever able to find a fix?

 

Rob

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...