Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2012
    Posts
    10
    Plugin Contributions
    0

    help question Usps 2014 0907 k6

    I am trying to add some changes to the latest USPS (K6) to test for media mail eligibility. I added a new table that has two fields -- products_id and media_mail_eligible. I have made a number of changes in files to make this work, and it does seem to. The last change now is in usps.php -- test each item to see if its media mail eligible. If the number of items in the cart equals number of media mail items, then allow media mail. Otherwise, don't show that option.

    The code isn't working, it allows media mail for everything. But more importantly it crashed Paypal integration. When clicking on PayPal option on shopping cart screen, the page goes white. The logs show this error:

    Code:
                                    [03-Nov-2014 19:07:26 America/Los_Angeles] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/walbur5/public_html/includes/modules/shipping/usps.php:1) in /home/walbur5/public_html/includes/modules/payment/paypalwpp.php on line 1635
    [03-Nov-2014 19:07:26 America/Los_Angeles] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/walbur5/public_html/includes/modules/shipping/usps.php:1) in /home/walbur5/public_html/includes/functions/functions_general.php on line 46
    If I replace my revised usps.php with the original K6, PayPal works fine -- but of course doesn't have any of my code.

    The code I added replaces the example of $chk_cart for categories.

    PHP Code:
    if (true) {

        
    error_log($_SESSION['cart']->count_contents() . ' items in cart -- ' $type );
      
    $skip_media 0;
      
    $chk_cart 0;
      
    $chk_cart += $_SESSION['cart']->in_cart_media_check('media_mail_eligible','1'); // 1 means media mail eligible
      //if $chk)cart = the entire contents of hte cart, then media mail eligible 
      
    if ($chk_cart $_SESSION['cart']->count_contents()) {

              
    $skip_media 0;  // false
            
    } else {
            
    $skip_media 1// true
            
    }
            
    error_log($chk_cart ' media mail eligible items -- ' $type 'skip_media = ' $skip_media );
    //  $chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','15');

    I created the new function in_cart_media_check since I don't use the products table for storing the info, but the new table. I simply changed the appropriate code to work. It seems to work (based on error_log output).

    2nd code change:
    PHP Code:
    if (true) {
      if (
    $skip_media ==  && $type == 'Media Mail Parcel') {

        continue;
      }

    I will admit I don't quite understand what the test is doing -- I simply left it from the original code, which seemed to imply that the test looked for cases where the example (Priority Mail small box) shouldn't be allowed and "continue" made that happen, but I think that must be wrong.

    So there's two questions (which perhaps should be divided into two forum topics, but the code is the same for both):
    1) How did I lose Paypal?
    2) what is wrong with this code that it can't skip media mail when it should?

    I am attaching the whole usps.php file in case something strange has been added that the above code isn't the cause of-- since the PayPal error suggests line 1. Thanks for all the help!
    Attached Files Attached Files
    Last edited by jaheadlee; 4 Nov 2014 at 04:49 AM. Reason: attached wrong file

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Usps 2014 0907 k6

    First check if you have a space or blank line before the starting <?php in:
    /includes/modules/shipping/usps.php
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Usps 2014 0907 k6

    NOTE: you have lots of spaces there ...

    Also around line 372 you have:
    Code:
      if ($chk_cart = $_SESSION['cart']->count_contents()) {
    yet you are adding to $chk_cart above:
    Code:
      $chk_cart += $_SESSION['cart']->in_cart_media_check('media_mail_eligible','1'); // 1 means media mail eligible
    I have not tried your code, as you have database changes that I do not, but these are things that are jumping out so far ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Jul 2012
    Posts
    10
    Plugin Contributions
    0

    Default Re: Usps 2014 0907 k6

    Quote Originally Posted by Ajeh View Post
    NOTE: you have lots of spaces there ...
    Yeah, the spaces thing has been weird. I keep getting rid of them, they keep coming back. I'll try it again. There might be something about the editor my website host puts me in that isn't compatible, although I didn't used to have this problem. Thanks!

  5. #5
    Join Date
    Jul 2012
    Posts
    10
    Plugin Contributions
    0

    Default Re: Usps 2014 0907 k6

    Well, it all seems to be working now. Paypal -- spaces were key, and they were caused by the site host's code edit capability. So, back to Notepad++ for me -- just hated to keep uploading. And the dreaded '=" vs. "==" caught me again! I flipped the check on the cart -- instead of checking to see how many items were media mail eligible, I checked to see how many weren't, and if greater than zero set the skip_media flag to 1. And all worked great. Then figured out what you were saying. Now, on to checking package weights to determine which Priority Mail box to use....

    Thanks so much for your help! Sometimes it's just the simplest thing that gets us.
    Last edited by jaheadlee; 5 Nov 2014 at 12:56 AM.

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Usps 2014 0907 k6

    Trust me ... easy to spot as I've been there ... done that ... got the T-shirts ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. USPS RateV4 Intl RateV2 October 30, 2014 K6 for - November 2, 2014
    By Ajeh in forum Zen Cart Release Announcements
    Replies: 1
    Last Post: 16 Nov 2014, 02:48 PM
  2. Replies: 10
    Last Post: 7 Nov 2014, 04:06 PM
  3. v139h USPS RateV4 Intl RateV2 October 30, 2014 K6 for - November 2, 2014
    By WiccanWitch420 in forum Addon Shipping Modules
    Replies: 2
    Last Post: 3 Nov 2014, 03:34 AM
  4. Replies: 4
    Last Post: 28 Jan 2014, 03:28 AM
  5. USPS RateV4 Intl RateV2 Jan 26, 2014 Rates, January 26, 2014 Version K1
    By Ajeh in forum Zen Cart Release Announcements
    Replies: 0
    Last Post: 24 Jan 2014, 06:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR