Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 62
  1. #21
    Join Date
    Jun 2008
    Posts
    627
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    ok, I will worry about the sub sub cats in a bit

    To start I have added:


    PHP Code:
    // see below use of $chk_cart
    // eof: example to block USPS Priority MailTM Small Flat Rate Box when anything from master_categories_id 12 or 15 are in the cart

    // bof: skip Products in any subcategory for parents_id 486
          
    $subcategories_array = array();
          
    $chk_cat '486'// parent categories_id
          
    $chk_cart 0;
          
    zen_get_subcategories($subcategories_array$chk_cat);
          for (
    $i=0$n=sizeof($subcategories_array); $i<$n$i++ ) {
            
    $chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id'$subcategories_array[$i]);
          }
    //echo 'USPS products in parent category 486: ' . $chk_cart . '<br>';
    // eof: skip Products in any subcategory for parents_id 486
          
    for ($i=0$i<$PackageSize$i++) { 

    I also have this code in place


    PHP Code:
    $show_hiddenCost '';
    // bof: test contents for Media Mail
              
    if ($type == 'Media Mail Parcel' && $skip_media) {
                
    // skip Media Mail
              
    } else {
              
    $methods[] = array('id' => $type_rebuilt,
                                 
    'title' => $title $show_hiddenCost,
                                 
    'cost' => $cost,
                                );
              }
    // eof: test contents for Media Mail
            
    } else {
             { 
    When I add a non media item, media mail is still offered. When I add a book from a sub cat and a non media item, media mail is still offered. Have I done something wrong? Should I be combining the code with what was posted in post #4?

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    You never set:
    $skip_media

    so you need an IF or something to set that once you get the results ...
    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. #23
    Join Date
    Jun 2008
    Posts
    627
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Quote Originally Posted by Ajeh View Post
    You never set:
    $skip_media

    so you need an IF or something to set that once you get the results ...

    yeah...so I'm lost lol. I have tried multiple variations most of which broke things. This one is the latest one I tried which doesn't break my cart but doesn't offer media for anything. I'm sure this must look like a lame attempt



    PHP Code:
    // bof: skip Products in any subcategory for parents_id 486

          
    $subcategories_array = array();
          
    $chk_cat '486'// parent categories_id
          
    $chk_cart 0;
          
    zen_get_subcategories($subcategories_array$chk_cat);
          for (
    $i=0$n=sizeof($subcategories_array); $i<$n$i++ ) {
            
    $chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id'$subcategories_array[$i]);

          }if (
    $chk_media != $_SESSION['cart']->count_contents()) {
              
    $skip_media true;}
    //echo 'USPS products in parent category 486: ' . $chk_cart . '<br>';
    // eof: skip Products in any subcategory for parents_id 486 

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    I used $chk_cart and you are using $chk_media ...

    Something like this:
    Code:
    // bof: skip Products in any subcategory for parents_id 486
    
          $subcategories_array = array();
          $chk_cat = '486'; // parent categories_id
          $chk_cart = 0;
          zen_get_subcategories($subcategories_array, $chk_cat);
          for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
            $chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id', $subcategories_array[$i]);
    
          }
    if ($chk_cart != $_SESSION['cart']->count_contents()) {
      $skip_media = true;
    }
    //echo 'USPS products in parent category 486: ' . $chk_cart . '<br>';
    // eof: skip Products in any subcategory for parents_id 486
    might work better ...

    NOTE: I do not know if that is your code or your copy and paste that made your IF test look so odd ...
    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!

  5. #25
    Join Date
    Jun 2008
    Posts
    627
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Quote Originally Posted by Ajeh View Post
    I used $chk_cart and you are using $chk_media ...

    Something like this:
    Code:
    // bof: skip Products in any subcategory for parents_id 486
    
          $subcategories_array = array();
          $chk_cat = '486'; // parent categories_id
          $chk_cart = 0;
          zen_get_subcategories($subcategories_array, $chk_cat);
          for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
            $chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id', $subcategories_array[$i]);
    
          }
    if ($chk_cart != $_SESSION['cart']->count_contents()) {
      $skip_media = true;
    }
    //echo 'USPS products in parent category 486: ' . $chk_cart . '<br>';
    // eof: skip Products in any subcategory for parents_id 486
    might work better ...



    NOTE: I do not know if that is your code or your copy and paste that made your IF test look so odd ...
    Awesome, that works great! Adding media items from sub cats and sub sub cats are offered media shipping option. Mixing media and non media items are not offered media shipping option. Adding only non media items are not offered media shipping option. Thank you so much for your help with this.

    Not sure what it is that looks odd but I'm sure it must be something I did. Is it the 'if' not starting on a new line that is wrong?
    Last edited by buildingblocks; 7 Oct 2014 at 10:25 PM.

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Code is usually written where the IF would be on its own lines and not bunched up in there ...

    Glad that this is now working for you ...
    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!

  7. #27
    Join Date
    Nov 2014
    Location
    Athens, GA
    Posts
    25
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Hi,

    I'm fairly new to ZenCart and all the way new to php. However, I do have some experience in coding (just a bit) so it doesn't all look like a complete foreign language to me. I'm trying to set up this same thing - exclude media mail as a shipping option for just one category of items in my shop. However, it doesn't seem to be working. What I've done so far is add the recommended code to usps.php; uploaded the modified file to my server under includes / modules / shipping, and verified that the file there is the custom one; and even reinstalled the USPS module afterward, because I wasn't sure if I needed to or not (I know you need to when USPS releases a new version). Still it doesn't seem to work.

    Here is what I have added in the .php:

    // see below use of $chk_cart
    // eof: example to block USPS Priority MailTM Small Flat Rate Box when anything from master_categories_id 12 or 15 are in the cart

    // bof: test contents for Media Mail
    $skip_media = false;
    $chk_media = 0;
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','65');
    if ($chk_media != $_SESSION['cart']->count_contents()) {
    $skip_media = true;
    }
    // eof: test contents for Media Mail


    for ($i=0; $i<$PackageSize; $i++) {


    Then further down:

    $show_hiddenCost = '';
    // bof: test contents for Media Mail
    if ($type == 'Media Mail Parcel' && $skip_media) {
    // skip Media Mail
    } else {

    $methods[] = array('id' => $type_rebuilt,
    'title' => $title . $show_hiddenCost,
    'cost' => $cost,
    'insurance' => $usps_insurance_charge,
    );
    }
    // eof: test contents for Media Mail

    //echo 'setting insurance: ' . $usps_insurance_charge . '<br>';
    } else {


    My category ID (it's merch, a.k.a. shirts and whatnot) does appear to be 65:



    What am I missing? The code seems straightforward to me - if category is 65 for any product in the cart (and it is in my tests), then disable the media mail option. But in both estimate shipping and actual checkout, media mail is still coming up.

  8. #28
    Join Date
    Nov 2014
    Location
    Athens, GA
    Posts
    25
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Should also note, I tried changing each instances of chk_media to chk_cart and reinstalling again, but that had no effect either.

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Are there only Products in Category 65?

    Are you using the current USPS October 30, 2014 K6 version?
    http://www.zen-cart.com/showthread.p...ovember-2-2014

    This is also a good time to ensure that you are subscribed to the News & Announcements forum:
    http://www.zen-cart.com/forumdisplay...-Announcements

    And it never hurts to test the correct USPS module is on the server:
    Go to your Zen Cart Admin and go to Tools ... Developers Tool Kit ...

    In the bottom input box enter:
    usps.php

    Then, select Catalog ... click SEARCH ...

    What comes up on the paths to the files and the lines for:
    * @version $Id: 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!

  10. #30
    Join Date
    Nov 2014
    Location
    Athens, GA
    Posts
    25
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Thanks for the quick response -

    I have products in category 65 and others. I did a few tests to see how it would behave - checking out one product in another category; then checking out one product from 65; then a combined checkout with a product from each category. In all cases I got a media mail option.

    Yes, I'm using the current USPS module. I just installed the newest one this morning before I tackled this project.

    The last question might get to the problem, I don't know. This is what came back:

    /home2/unspeak4/public_html/purchase/includes/languages/english/modules/shipping/usps.php

    Line #12 : * @version $Id: usps.php 2014-09-07 ajeh Version K5 $

    /home2/unspeak4/public_html/purchase/includes/modules/shipping/usps.php

    Line #14 : * @version $Id: usps.php 2014-10-30 ajeh Version K6 $

    I actually only installed to modules / shipping - should the same file go under languages / english / modules / shipping as well?

    EDIT - Never mind, I see that I didn't install the languages... .php file, but it's a different file entirely with a lot less in it. Going to load it now just in case that's part of my problem...

 

 
Page 3 of 7 FirstFirst 12345 ... LastLast

Similar Threads

  1. v139h USPS Media Mail problem.
    By Beau91324 in forum Addon Shipping Modules
    Replies: 4
    Last Post: 8 Jul 2014, 08:50 PM
  2. v150 USPS Module RateV3 -- trying to integrate Media Mail eligible option
    By jaheadlee in forum Addon Shipping Modules
    Replies: 1
    Last Post: 24 Jul 2012, 10:59 PM
  3. USPS-Offering Media mail on all items
    By flyred77 in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 2 Dec 2009, 12:04 AM
  4. Product Customization USPS Media Mail
    By rfloyd in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 30 May 2008, 09:46 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