Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

UPSXML 1.3.5 $packing variable reference lost


Recommended Posts

Posted (edited)

After installing UPSXML 1.3.5, I noticed that upon return from Paypal Express checkout, the weight changed to zero. I traced the code and determined that the reference to $packing was not an object in the upsxml.php module upon return from Express. The if-statement there prevents that block of code from executing if that is true (is_object($packing)). Since $packing was not an object it could no longer be used to calculate the correct weight.

 

I put in code to re-instantiate the object at that point (in upsxml.php) and that caused the number of packages to double, but did bring the weight back correctly. UPS returned the correct rates shipment array in XML upon verifying the XML response from UPS. The order totaling module seems to have double the box count. So I took out the instantiation of $packing in upsxml.php.

 

Shipping charges were obviously incorrect when coming back from PayPal Express because either the weight was zero or the boxes doubled.

 

At checkout confirmation, editing the shipping choice and returning to the confirmation page, caused the values to be corrected.

 

I have tried to maintain the reference to $packing but could not. It keeps loosing it.

 

I am using dimensional support. Without dimensional support enabled it does not happen and works correctly with PayPal Express. Also with dimension support on, and using Paypal Pro option, this behavior does not happen either. It seems leaving my site, or executing code associated with express.php or paypal_express.php, is causing the $packing variables to become null somehow.

 

Any ideas? Experiences?

Edited by doubletap
Posted
I am using dimensional support. Without dimensional support enabled it does not happen and works correctly with PayPal Express. Also with dimension support on, and using Paypal Pro option, this behavior does not happen either. It seems leaving my site, or executing code associated with express.php or paypal_express.php, is causing the $packing variables to become null somehow.

The new PayPal Express module has it's own shipping code that you would normally only find in checkout_shipping.php. Therefore I would try adding the code mentioned on step 9 in dimensions.txt (UPS XML contribution) after these lines (126-127) in ext/modules/payment/paypal/express.php:

		  $total_weight = $cart->show_weight();
	  $total_count = $cart->count_contents();

Posted (edited)
The new PayPal Express module has it's own shipping code that you would normally only find in checkout_shipping.php. Therefore I would try adding the code mentioned on step 9 in dimensions.txt (UPS XML contribution) after these lines (126-127) in ext/modules/payment/paypal/express.php:

		  $total_weight = $cart->show_weight();
	  $total_count = $cart->count_contents();

 

 

Thank you. I must have missed that in the instructions. My apologies. I will try that and report back.

 

---After I posted this I went back and re-read them. Seems that this is not mentioned in my copy. Is this something to be added to this module? I have not added it as of now. I will in a moment.

Edited by doubletap
Posted
Seems that this is not mentioned in my copy. Is this something to be added to this module?

True, it is mentioned for checkout_shipping.php but not for this particular module (which is pretty new and non-standard osC in a way because the shipping does not go through checkout_shipping but uses it's own code).

Posted (edited)

Ok I added the code to instantiate the $packing variable, same as in checkout_shipping.php as in /ext/modules/payment/paypal/express.php after the code above.

 

The same thing happened as when I tried to re-instantiate it in upsxml.php. The number of boxes were exactly doubled, the shipping amount was exactly doubled, but the weight is fine.

 

After I use the paypal express checkout part, I can use paypal express again without any issues. The difference being that if I leave my site, the issue happens. Since after I use paypal express checkout, it remembers me for short time afterwards, I never leave my site. Then the issue does not happen.

 

---I wonder if this has something to do with the session variable for shipping_quotes. Seems I remember unregister/register being done. I also tried this with the ship in cart mod. When I change the shipping option using the estimator and it re-totals the order, the same thing. Boxes doubled, shipping chg doubled but not the weight.

Edited by doubletap
Posted

FIXED

 

I have found the issue. In addition to the above mentioned fix to /ext/modules/payment/paypal/express.php mentioned above also do this:

 

In the file upsxml.php

 

Find these lines:

 

if ($this->dimensions_support > 0 && is_object($packing)) {

$boxValue = 0;

 

$totalWeight = $packing->getTotalWeight();

 

$shipping_num_boxes = $packing->getNumberOfBoxes();

 

$boxesToShip = $packing->getPackedBoxes();

 

Add this line directly after $boxesToShip = $packing->getPackedBoxes();

 

$this->items_qty = 0;

 

END

 

What was happening was that upsxml->quote() sometimes was called twice. This happened during the paypal express checkout as well as for the mod 'ship in cart' when changing the shipping selections, say from UPS Ground to UPS 3-Day Select. When the upsxml->quote() method was called twice the items_qty field in the upsxml object was still holding the old value. the $packing object contained the correct value which was then added to the items_qty field in upsxml. This caused the xmlRequest to contain double the amount of boxes which affected the shipping results

 

Also during my trace of the code I found some other minor fixes

 

I changed the line:

 

var $code, $title, $description, $icon, $enabled, $types, $boxcount;

 

 

to

 

var $code, $title, $description, $icon, $enabled, $types, $boxCount;

 

 

And the line

 

global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes, $total_weight, $boxcount, $cart, $packing;

 

to

 

global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes, $total_weight, $cart, $packing;

 

since the reference to the global $boxcount was not used in this module. Every reference referred to this->$boxCount which was defined in the var line above as $boxcount.

 

I also changed this line

$this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ($this->boxCount > 1 ? ' pkg(s) x ' : ' pkg x ') . round($shipping_weight,0) . ' ' . strtolower($this->unit_weight) . ' total)');

 

to

 

$this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ($shipping_num_boxes > 1 ? ' pkg(s) x ' : ' pkg x ') . round($shipping_weight,0) . ' ' . strtolower($this->unit_weight) . ' total)');

 

because what was being printed was not was being checked to determine if 'pkg(s)' or 'pkg' should be displayed.

 

 

So now this works for me...thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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