Post by BionicBill » Sat Nov 14, 2015 4:42 am

Is there a way to get USPS Parcel Select Rates? that I could use as they are available in Stamps.com.

New member

Posts

Joined
Tue Dec 04, 2012 4:08 am

Post by JeffroDH » Sun Nov 15, 2015 10:19 am

BionicBill wrote:Is there a way to get USPS Parcel Select Rates? that I could use as they are available in Stamps.com.
I'm not sure if this API will pull those rates. You can look in the web tools API documentation for Rate Request V4 and see if the XML can be modified to pull those rates.

https://www.usps.com/business/web-tools ... c423593286

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by olwm » Wed Nov 18, 2015 3:44 am

The extension works great for the most part. The only issue we are having is with ship station...in ship station it doesn't send the shipping method. We only use USPS. It doesn't produce any errors in the error logs. We are using OpenCart version 1.5.6.1

Newbie

Posts

Joined
Wed Nov 18, 2015 3:38 am

Post by JeffroDH » Wed Nov 18, 2015 8:13 pm

olwm wrote:The extension works great for the most part. The only issue we are having is with ship station...in ship station it doesn't send the shipping method. We only use USPS. It doesn't produce any errors in the error logs. We are using OpenCart version 1.5.6.1
I'm not familiar with the Ship Station extension. This mod is not written to integrate with any other extensions, although custom integration can be done for a fee.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Tue Dec 01, 2015 3:03 am

1. As soon as I add this VQMod, the entire store breaks with this error:

Code: Select all

 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ~/vqmod/vqmod.php on line 329
When I remove theAPI update XML from the VQMod folder, the site behaves normally again. I downloaded the appropriate version of the mod for 1.5.5.1. I did a search through all my other VQMods for the files modified in this mod and didn't find any that also modified usps.* or cart.tpl.
2. OpenCart log - attached (note: I changed the home directory to ~ in all instances in the log to mask the admin username and site, and trimmed to just today's log for size considerations.)
3. VQMod log wasn't recently updated, so I didn't see any pertinent logs to include
4. OpenCart 1.5.5.1

Would appreciate your help in resolving this.

Update: I found that this error was fixed in a later version of VQMod (I was on 2.3.2), and upgrading to the latest VQMod fixed this issue. However, now that I'm able to use the store after installing this USPS API update, I'm finding that I'm still getting the same error as before the modification when trying to calculate USPS shipping costs to Canada:

Code: Select all

Notice: Trying to get property of non-object in ~/catalog/model/shipping/usps.php on line 425
Notice: Trying to get property of non-object in ~/catalog/model/shipping/usps.php on line 428
I've attached an updated OpenCart error log file. As far I can tell, the VQMod log has not been modified at all in the past couple of weeks.

Attachments

OpenCart Error Log


Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by JeffroDH » Tue Dec 01, 2015 7:20 am

Check the VQMod error logs at /VQMod/logs, and make sure that there aren't any conflicts that are aborting the mod. With a custom template, sometimes a particular search isn't found.

If you need help interpreting something in the logs, post them here.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by JeffroDH » Tue Dec 01, 2015 7:23 am

If there is still nothing in the VQMod logs, let me know.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Tue Dec 01, 2015 2:18 pm

JeffroDH wrote:Check the VQMod error logs at /VQMod/logs, and make sure that there aren't any conflicts that are aborting the mod. With a custom template, sometimes a particular search isn't found.

If you need help interpreting something in the logs, post them here.
Apparently my FTP client wasn't refreshing the logs directory, so I was missing the new log (attached).

Not seeing any indication of conflicts. Definitely getting search not found errors, but no custom templates to blame. Shouldn't be any modifications to the USPS files, either.

Attachments


Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by JeffroDH » Wed Dec 02, 2015 5:34 am

Quick fix, find the line in the xml file that contains the line in the log, and compare it to a similar line in your USPS file.

You'll copy the line out of the USPS.php file and replace the text within the relevant <search></search> Tag.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Thu Dec 03, 2015 12:38 am

JeffroDH wrote:Quick fix, find the line in the xml file that contains the line in the log, and compare it to a similar line in your USPS file.

You'll copy the line out of the USPS.php file and replace the text within the relevant <search></search> Tag.
Here's what I'm seeing in the USPS.php vs. the XML:

In the XML:

Code: Select all

        <operation>
        	<search position="replace" offset="1"><![CDATA[$result = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', '', $result);]]></search>
        	<add><![CDATA[$result = str_replace('&lt;sup&gt;&#174;&lt;/sup&gt;', '&#174;', $result);
				$result = str_replace('&lt;sup&gt;&#8482;&lt;/sup&gt;', '&#8482;', $result);
				$result = str_replace(' 1-Day', '', $result);
				$result = str_replace(' 2-Day', '', $result);]]></add>
        </operation>
In the USPS.php:

Code: Select all

// strip reg, trade and ** out 01-02-2011
				$result = str_replace('&lt;sup&gt;&#174;&lt;/sup&gt;', '', $result);
				$result = str_replace('&lt;sup&gt;&#8482;&lt;/sup&gt;', '', $result);
				$result = str_replace('**', '', $result);
				$result = str_replace("\r\n", '', $result);
				$result = str_replace('\"', '"', $result);
I don't see the string in the USPS.php that the XML is searching for at all, but rather only see the two lines (including #174 and #8482) that are referenced in the XML <add></add>. So, not sure that I want to replace the current search string with one of the lines that's already referenced in the <add>.

Any thoughts?

Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by JeffroDH » Thu Dec 03, 2015 4:15 am

It looks like your USPS file has been modified to include the changes already present in the VQMod. You can simply delete that operation. If there are no further problems, you should see it begin to work appropriately.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Thu Dec 03, 2015 5:52 am

JeffroDH wrote:It looks like your USPS file has been modified to include the changes already present in the VQMod. You can simply delete that operation. If there are no further problems, you should see it begin to work appropriately.
Commenting out that whole operation seems to have worked, and Canada shipping is no longer generating an error. That being said, am I losing anything by not having the two remaining added lines that were part of that add operation?

Code: Select all

				$result = str_replace(' 1-Day', '', $result);
				$result = str_replace(' 2-Day', '', $result);]]></add>
The first two added lines are in the USPS.php, but these weren't - do they need to be included somehow?

Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by JeffroDH » Thu Dec 03, 2015 9:53 pm

Now that there isn't an operation that VQMod can't execute (the failed search), the extension isn't aborted, and the changes necessary for the Canada error are implemented. This particular operation had nothing to do with the problem, but it was preventing the rest of the code from executing.
That being said, am I losing anything by not having the two remaining added lines that were part of that add operation?
Those were designed to eliminate the USPS generated delivery time estimates from the returned responses, because I and many of my customers found them to be inaccurate and confusing to customers. You can either add them directly to the usps.php file (underneath the existing str_replace statements), or create an operation in the VQMod that does it.

Code: Select all

<operation>
	<search position="after"><![CDATA[]]></search>
	<add><![CDATA[$result = str_replace(' 1-Day', '', $result);
            $result = str_replace(' 2-Day', '', $result);]]></add>
</operation>
VQMod only searches for single lines, so choose a line in that section, and copy/paste it in between the innermost brackets in the search tag, if you want to remove those. You can also choose to remove/replace any other string in the response using the same function. Essentially, you're searching the USPS response string ($result) for a string (' 1-Day', e.g.), replacing it with another string (or in this case, with an empty string).

In plain english, one of these lines would read:

Make the variable $result equal to the result of the function: Find the string ' 1-Day' and replace it with an empty string (delete it) if it is found within the variable $result.

Code: Select all

str_replace(search(needle), replace, subject(haystack))
For more details on how it works, check out the documentation on PHP.net.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by JeffroDH » Sat Dec 05, 2015 2:35 am

There is an upcoming update that will affect USPS users on January 17th, 2016. More detailed information can be found in the original post in this thread.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by BionicBill » Fri Dec 11, 2015 2:38 am

Re:

Code: Select all

            $result = str_replace(' 1-Day', '', $result);
            $result = str_replace(' 2-Day', '', $result);]]></add>
If I want the 1-Day , 2- Day back do I just change the above code to this?

Code: Select all

                 ]]></add>

New member

Posts

Joined
Tue Dec 04, 2012 4:08 am

Post by JeffroDH » Fri Dec 11, 2015 2:58 am

Just remove the lines entirely.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Fri Jan 15, 2016 11:22 pm

JeffroDH wrote:There is an upcoming update that will affect USPS users on January 17th, 2016. More detailed information can be found in the original post in this thread.
Has this update been released? I'd like to make sure I'm up-to-date before the 17th, but the latest update is still showing as November 2015.

Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by JeffroDH » Sat Jan 16, 2016 1:02 am

airhead3 wrote:
JeffroDH wrote:There is an upcoming update that will affect USPS users on January 17th, 2016. More detailed information can be found in the original post in this thread.
Has this update been released? I'd like to make sure I'm up-to-date before the 17th, but the latest update is still showing as November 2015.
It has not been released, but will be available no later than this afternoon. Most of the changes are simply cosmetic in any case. Nothing should break in the event that I'm not able to get it done today.

Active Member

Posts

Joined
Thu Jul 11, 2013 8:29 am

Post by airhead3 » Mon Jan 18, 2016 7:32 am

I'm wondering if there's an order of operations problem with the vqmod. I'm getting the search error seen in the attached log file for:

Code: Select all

 <CommercialFlag>Y</CommercialFlag>
and looking in the usps.php there's only:

Code: Select all

<CommercialFlag>N</CommercialFlag>
Looking into which searches are involving <CommercialFlag>Y</CommercialFlag>, I find:

Code: Select all

        	<search position="before"><![CDATA[$xml .= '		<CommercialFlag>Y</CommercialFlag>';]]></search>
        	<add><![CDATA[					$xml .=	'		<OriginZip>' . substr($this->config->get('usps_postcode'), 0, 5) . '</OriginZip>';]]></add>
        </operation>

Code: Select all

        <operation>
        	<search position="after"><![CDATA[$xml .= '		<CommercialFlag>Y</CommercialFlag>';]]></search>
        	<add><![CDATA[
        		if((strlen($postcode)) >= "1"){
        			$xml .= '      <AcceptanceDateTime>'.date('c').'</AcceptanceDateTime>';
        			$xml .=	'		<DestinationPostalCode>' . $postcode . '</DestinationPostalCode>';
        		}]]></add>
        </operation>
...and finally, later in the file:

Code: Select all

    	<operation>
    		<search position="replace"><![CDATA[$xml .= '		<CommercialFlag>N</CommercialFlag>';]]></search>
    		<add><![CDATA[$xml .= '		<CommercialFlag>Y</CommercialFlag>';]]></add>
    	</operation>
Which appears to be changing the <CommercialFlag>N</CommercialFlag> into <CommercialFlag>Y</CommercialFlag>.

So, if that replacement later in the file is putting the <CommercialFlag>Y</CommercialFlag> into the usps.php file, is that why the searches earlier in the file aren't finding it?

Newbie

Posts

Joined
Thu Apr 11, 2013 1:16 am

Post by Redcomet » Tue Jan 19, 2016 5:18 am

Hello,

I had previously had your 2013 API update and it was working properly on my website. I went ahead and downloaded your new Jan API update and made sure my USPS.php files were stock and removed the old XML file.

At the moment I do not have anything listed in the shipping options, just blank white spaces where the services should be.

Attached is my error.txt file

Thanks

Newbie

Posts

Joined
Mon Jul 06, 2015 10:54 am
Who is online

Users browsing this forum: No registered users and 17 guests