WordPress.org

Ready to get started?Download WordPress

Forums

WP eCommerce
[resolved] USPS xml style wierd char (15 posts)

  1. jmessick9
    Member
    Posted 11 months ago #

    Does anyone know how to correct <sup>&#8482 in the usps shipping. When the cart returns the shipping rate it has this on the page Priority Mail 3-Day<sup>&#8482

    http://wordpress.org/plugins/wp-e-commerce/

  2. Mihai
    Member
    Plugin Author

    Posted 11 months ago #

    The problem is that USPS has started to send the weird characters and they don`t encode them properly.
    Below is a fix that should work.

    Edit: usps_20.php
    Find:

    /**
      * USPS seems to be not able to encode their own XML appropriately
      * This function is used to fix their mistakes.
      * @author Greg Gullett (greg@ecsquest.com)
      * @since 2.0
      * @param string $response Reference to the $response string
      */
     function _clean_response( &$response ) {
      $bad_encoding = array( "<sup>&", ";</sup>" );
      $good_encoding = array( "<sup>","</sup>" );
      $response = str_replace( $bad_encoding, $good_encoding, $response );
     }

    Replace with:

    /**
      * USPS seems to be not able to encode their own XML appropriately
      * This function is used to fix their mistakes.
      * @author Greg Gullett (greg@ecsquest.com)
      * @since 2.0
      * @param string $response Reference to the $response string
      */
     function _clean_response( &$response ) {
     $response = str_replace('<sup>®</sup>',"",$response);
     $response = str_replace('<sup>™</sup>',"",$response);
     }
  3. jmessick9
    Member
    Posted 11 months ago #

    That did not work but atleast I know where it is at. This is what I have:

    function _clean_response( &$response ) {
    		$bad_encoding = array( "<sup>&", ";</sup>" );
    		$good_encoding = array( "<sup>","</sup>" );
    		$response = str_replace( $bad_encoding, $good_encoding, $response );
    	}
  4. jmessick9
    Member
    Posted 11 months ago #

    it didnt post the code correctly... hmm

    Here is the code on Pastebin:

    http://pastebin.com/qaJzkArw

  5. jmessick9
    Member
    Posted 11 months ago #

    This worked: Just in case someone needs it.

    function _clean_response( &$response ) {
    $bad_encoding = array( "& amp;lt;sup& amp;gt;", ";& amp;lt;/sup& amp;gt;" );
    $good_encoding = array( "<sup>", "</sup>" );
    $response = str_replace( $bad_encoding, $good_encoding, $response );

    remove the Space after the & above.

    Thanks.

  6. benarobinson
    Member
    Posted 10 months ago #

    Not sure why, but I have this same issue and the code above doesn't work for me. I agree that it should work and I've tried a few different variations. URL is rubyslube.com

    Has anybody else found any other place in the files for WP e-Commerce 3.8.12.1 where the original encoding might avoid being replaced?

    It's also possible that it's some sort of caching issue where I'm just not seeing the results of the change (I haven't been able to get it to change at all, which seems odd since I would expect *something* to happen), but I've tried from multiple devices and it's still showing me:

    Standard Post<sup>®</sup> $5.60
    First-Class Mail $3.60
    Priority Mail 1-Day<sup>™</sup> $5.60
    Priority Mail Express 2-Day<sup>™</sup> $16.05

  7. benarobinson
    Member
    Posted 10 months ago #

    Actually, it's not even showing it as well as here... Maybe a document encoding issue?

  8. benarobinson
    Member
    Posted 10 months ago #

    Hmm, adding htmlspecialchars_decode() as a wrapper for str_replace( $bad_encoding, $good_encoding, $response ); does get it to look like it does above, but I can't get it to remove or parse the <sup> as html.

  9. FreshIdeaWebsites
    Member
    Posted 8 months ago #

    Thx to jmessick9
    The correction you posted worked very nicely

  10. Mihai
    Member
    Plugin Author

    Posted 8 months ago #

    The "better" way of doing it is to replace that function with this one:

    function _clean_response( &$response ) {
    	$response = html_entity_decode( html_entity_decode( $response ) );
    }
  11. ottomek
    Member
    Posted 8 months ago #

    Yes I had this problem and the function from misulicus fixed it.

    Thanks.

  12. lotsamottsa
    Member
    Posted 5 months ago #

    Hmmm none of these fixes are working for me.. any other ideas on how I can fix this error? I am still seeing:

    & lt;sup& gt;& #8482;& lt;/sup& gt; (minus the spaces of course)

  13. alfredwestlake
    Member
    Posted 4 months ago #

    I'm having the same issues as benarobinson. Has anyone had any new ideas? I have tried all that are shown here.

    Benarobinson did you ever find a solution?

    Thanks for any help,
    Alfred

  14. Jessica
    Member
    Posted 4 months ago #

    I'm also looking for a fix to

    <sup>™</sup>

    being displayed with the USPS shipping options.

  15. Mihai
    Member
    Plugin Author

    Posted 4 months ago #

    Try replacing the _clean_response function in USPS with this:

    function _clean_response( &$response ) {
    		$response = str_replace('<sup>®</sup>', '&reg;', $response);
    		$response = str_replace('<sup>™</sup>', '&trade;', $response);
    		$response = str_replace('<sup>®</sup>', '&reg;', $response);
    		$response = wp_specialchars_decode( wp_specialchars_decode( $response ) );
    		return $response;
    	}

Reply

You must log in to post.

About this Plugin

About this Topic