[Tutorial]How to customize UPS Carrier Module for Negotiated Rates - Core developers - PrestaShop

Jump to content

Photo

[Tutorial]How to customize UPS Carrier Module for Negotiated Rates

#1

Posted 11 July 2013 - 08:41 PM

manfield

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 Active Posts
If you negotiated rates with UPS, you may would like to receive correct data from the carrier, during price calculation.
Since the standard module does not consider this case, here is the hack to make it work.

Modify file /modules/upscarrier/xml.tpl

Just after
<Shipment>
tag, add:
<RateInformation>
	<NegotiatedRatesIndicator />
</RateInformation>

Then modify /modules/upscarrier/upscarrier.php, row 1732.

Substitute block

  // Return results
  if (isset ($resultTab['RATINGSERVICESELECTIONRESPONSE']['RESPONSE']['RESPONSESTATUSDESCRIPTION']) && $resultTab['RATINGSERVICESELECTIONRESPONSE']['RESPONSE']['RESPONSESTATUSDESCRIPTION'] == 'Success')
   return array('connect' => true, 'cost' => $resultTab['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['TOTALCHARGES']['MONETARYVALUE'] * $conversionRate);

with

  // Return results
  if (isset ($resultTab['RATINGSERVICESELECTIONRESPONSE']['RESPONSE']['RESPONSESTATUSDESCRIPTION']) && $resultTab['RATINGSERVICESELECTIONRESPONSE']['RESPONSE']['RESPONSESTATUSDESCRIPTION'] == 'Success') {
   if (isset($resultTab['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['NEGOTIATEDRATES'])) {
	return array('connect' => true, 'cost' => $resultTab['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['NEGOTIATEDRATES']['NETSUMMARYCHARGES']['GRANDTOTAL']['MONETARYVALUE'] * $conversionRate);
   } else {
	return array('connect' => true, 'cost' => $resultTab['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['TOTALCHARGES']['MONETARYVALUE'] * $conversionRate);
   }
  }


#2

Posted 11 July 2013 - 09:22 PM

PascalVG

    PrestaShop Fanatic

  • Global Moderators
  • 3708 Active Posts
Hi Manfield,
Thanks for posting!

pascal
How to add [SOLVED]: press "Edit" at original Q, press "Use Full Editor" and edit the header line. Voilá!
Please, always add your PS version and Link to your site.
Please, always tell/add the final solution working for your problem, so others can re-use it :-)

#3

Posted 04 November 2013 - 06:17 PM

shturmie

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts

Hi Manfield,

 

Thank you so very much for posting this.  However the suggested updates didn't have an impact for us.   For us, after making the code updates you suggested, the module still returns the non negotiated rates.  Would you have any other suggestions/recommendations? 



#4

Posted 04 November 2013 - 06:48 PM

manfield

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 Active Posts

Hi,

UPS carrier module caches results in a table: PS_UPS_CACHE

I suggest you to truncate the table, then retry. Probably you're looking at old results.

Let me know.



#5

Posted 04 November 2013 - 07:21 PM

shturmie

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts

Thank you so much for the quick response!  

 

Unfortunately, truncating PS_UPS_CACHE didn't make a difference. 



#6

Posted 04 November 2013 - 07:45 PM

manfield

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 Active Posts

Hi, in order to help you I need more information.

Try to send this message (https://www.dropbox....rierXMLTemplate, replacing your account data to XXX I typed in the file)  as POST request to:

 

https://onlinetools....ps.app/xml/Rate

 

You may use a Firefox add on called Poster: http://screencast.com/t/HibT53U7j to easily submit the request and check response.

 

You may send the response to manfredi[at]fabvla.com, I will check and tell you.



#7

Posted 04 November 2013 - 08:57 PM

shturmie

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts

WOW, you are amazing! Thank you so much for sending all this along and offering to assist!  In the process of me updating the file that you have sent, I realized that we must be using the wrong ShipperNumber.  Once I have updated the Your MyUps ID (ShipperNumber in the xml), all worked perfectly.  Thank you so much!!!!



#8

Posted 04 November 2013 - 09:07 PM

manfield

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 Active Posts

Awesome.

You're welcome.



#9

Posted 28 May 2015 - 12:35 AM

panamahatpub

    PrestaShop Newbie

  • Members
  • Pip
  • 9 Active Posts

This is a great tip! It is amazing that this is not included in the module itself.

 

In the UPS Module v1.3.5 there is a drop-down for Pickup Type that greatly affects the rates returned by the UPS API. When using your hack, which Pickup Type will result in the correct negotiated rate being returned by the API?

 

Daily Pickup

Customer Counter

One Time Pickup

On Call Air

Suggested Retail Rates

Letter Center

Air Service Center

 

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more