- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
USPS API showing retail rates instead of online
I am using Magento 1.9.1 and have gotten access to USPS API. When I select a product from my store, I am seeing USPS retail rates and not online rates. As a result, the shipping estimate is showing higher than the actual cost. How can I change this? I have looked in the Shipping settings for USPS in Magento and see no setting to change to online rates.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
Did you ever figure this out? We seem to be having the same issue.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
This is actually something that I ran into when doing a huge UPS customization job. I learned that somewhere in Magento the retail pricing is being created, it's not created by UPS. I was able to fix this by creating an observer function that overwrote the retail pricing with the wholesale pricing. Here's what the function looks like:
public function update_shipping_rates(Varien_Event_Observer $observer) {
$address = $observer->getQuoteAddress();
$rates = $observer->getShippingRates();
try {
foreach ($rates as $rate) {
$price = $rate->getCost();
if (!$price) {
$price = $rate->getPrice();
}
$rate->setCost($price);
$rate->setPrice($price);
}
} catch (Exception $e) {
Mage::logException($e);
}
}
800-207-1221
https://merchantprotocol.com
Magento Extension Developers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
I have the same problem. The online rates are also called commercial rates. So far in my research (as a non-programer) it seems to me that magento passes XML variable "service" such as <Service>PRIORITY MAIL EXPRESS</Service> to the USPS and gets the rates back. The services listed in this user guide https://www.usps.com/business/web-tools-apis/rate-calculator-api.pdf list most of the service variables as as having a regular and commercial version:
whiteSpace=collapse enumeration=
First Class
First Class Commercial
First Class HFP Commercial
Priority
Priority Commercial
Priority Cpp
Priority HFP Commercial
Priority HFP Cpp
Priority Mail Express
Priority Mail Express Commercial
etc.
However the configuration settings in Magento under shipping methods>USPS>allowed methods show no services with "commercial" appended as in the USPS pdf.
I would hope there is a setting somewhere in Magento that tells it to return commercial rates, or perhaps one would need to do some hacking. Anyone?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
I am experiencing the exact same thing. I'm suprised this seems to to be the only place on the internet talking about this.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
It is puzzling. I would have thought this would come up a lot.
When I realized how old this thread was I started a new one at:
Myabe reply to that one and maybe we can attract some help.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
I am having this problem as well. I purchase my shipping online, however my customers are only presented with the Retail price, not the Online price.
I did find out that it has to do with the fact Magento is passing "ALL" vs. "ONLINE". I cannot find the module where I can change this, however. If anyone can help, please post. It sounds like it would be any easy fix.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
I have purchased web shop apps dimensional shipping extension and the extension have this issue the service is hard to code to ALL and unable to fetch the commercial rates.They are asking to purchase the support package to fix the issue.
Can any one answer to fix the issue.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: USPS API showing retail rates instead of online
You need to override app/Code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
I can't remember where I found the fix, but here is what I changed in mine:
// Read commercial rate instead
//$r->setService('ALL');
$r->setService('ONLINE');
and further down look for...
if (in_array($serviceCode, $allowedMethods)) {
// Read commercial rate instead
//$costArr[$serviceCode] = (string)$postage->Rate;
$costArr[$serviceCode] = (string)$postage->CommercialRate;
$priceArr[$serviceCode] = $this->getMethodPrice(
//(string)$postage->Rate,
(string)$postage->CommercialRate,
$serviceCode
);
}
Mine seems to get Regional Rate A sometimes though, but it is a lot closer to online rates at least.