Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 46
  1. #21
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

    You also added the rest of the code from post #10 correct?
    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!]
    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!

  2. #22
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Ok...this is what I've done (and boy did I really do something, because now NO SHIPPING ESTIMATIONS show up!):

    */
    // test contents for Media Mail
    $skip_media = false;
    $chk_media = 0;
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','4');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','19');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','20');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','25');
    if ($chk_media != $_SESSION['cart']->count_contents()) {
    $skip_media = true;
    }
    $methods = array();
    $size = sizeof($uspsQuote);
    for ($i=0; $i<$size; $i++) {
    list($type, $cost) = each($uspsQuote[$i]);
    // BOF: UPS USPS
    $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
    if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
    /*
    $methods[] = array('id' => $type,
    'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    */
    if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
    } else {
    $methods[] = array('id' => $type,
    'title' => $title,
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    }

  3. #23
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Interesting...in my admin I have no usps shipping option. At the top of the page it says:

    Parse error: syntax error, unexpected T_ELSEIF in /home/***/public_html/***/includes/modules/shipping/usps.php on line 242

  4. #24
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Luckily I saved the file before I made the changes, so I re-uploaded the original file. Have any ideas what I did wrong? (I saved the edited file as well if you need to see it)

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

    Default Re: Media Mail Option

    This is the code with a few lines before and after it showing ...
    Code:
            // BOF: UPS USPS
            $this->quotes = array('id' => $this->code,
            'module' => $this->title . $show_box_weight);
            // EOF: UPS USPS
    
    // bof: Media Check
    // test contents for Media Mail
            $skip_media = false;
            $chk_media = 0;
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','4');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','19');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','20');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','25');
            if ($chk_media != $_SESSION['cart']->count_contents()) {
              $skip_media = true;
            }
    //echo '<br>IN USPS I SEE ' . $chk_media . ' count: ' . $_SESSION['cart']->count_contents() . ' Skip Media: ' . ($skip_media == true ? 'YES' : 'NO') . '<br>';
            $methods = array();
            $size = sizeof($uspsQuote);
            for ($i=0; $i<$size; $i++) {
              list($type, $cost) = each($uspsQuote[$i]);
    
              // BOF: UPS USPS
              $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
              if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
              /*
              $methods[] = array('id' => $type,
              'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
              'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              */
    
              if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
              } else {
                $cost = preg_replace('/[^0-9.]/', '',  $cost);
                $methods[] = array('id' => $type,
                                   'title' => $title,
                                   'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
              }
            }
    // bof: Media Check
    
            $this->quotes['methods'] = $methods;
    See if this works 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!]
    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!

  6. #26
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Well, I still have my postage estimator, but media mail still shows up in every circumstance. I put a book in the shopping cart, which is from cat 4...media mail was an option and it should have been. Great so far...then I put an electronic in the shopping cart from cat 6...media mail was still an option and was not supposed to be. Here is my code, again like you, I have posted some code before and after:

    // BOF: UPS USPS
    if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
    switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
    case (0):
    $show_box_weight = '';
    break;
    case (1):
    $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
    break;
    case (2):
    $show_box_weight = ' (' . number_format($usps_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
    break;
    default:
    $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
    break;
    }
    }
    // EOF: UPS USPS
    // BOF: UPS USPS
    $this->quotes = array('id' => $this->code,
    'module' => $this->title . $show_box_weight);
    // EOF: UPS USPS
    // bof: Media Check
    // test contents for Media Mail
    $skip_media = false;
    $chk_media = 0;
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','4');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','19');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','20');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','25');
    if ($chk_media != $_SESSION['cart']->count_contents()) {
    $skip_media = true;
    }
    //echo '<br>IN USPS I SEE ' . $chk_media . ' count: ' . $_SESSION['cart']->count_contents() . ' Skip Media: ' . ($skip_media == true ? 'YES' : 'NO') . '<br>';
    $methods = array();
    $size = sizeof($uspsQuote);
    for ($i=0; $i<$size; $i++) {
    list($type, $cost) = each($uspsQuote[$i]);
    // BOF: UPS USPS
    $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
    if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
    /*
    $methods[] = array('id' => $type,
    'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    */
    $methods[] = array('id' => $type,
    'title' => $title,
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    }
    $this->quotes['methods'] = $methods;

    (I am editing file: /home/***/public_html/***/includes/modules/shipping/usps.php...right?)

    Last edited by debtag; 2 Feb 2010 at 08:11 AM. Reason: forgot something

  7. #27
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Ugh Ajeh...I have looking over your code comparing it to mine...I'm not sure, I think I might have left something out. I feel so stupid when it comes to this code stuff. I'm sorry if I am frustrating...believe me, I am frustrated. Is it a possibility to send you my file via PM?

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

    Default Re: Media Mail Option

    You are missing the final part of the code:
    Code:
              if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
              } else {
                $cost = preg_replace('/[^0-9.]/', '',  $cost);
                $methods[] = array('id' => $type,
                                   'title' => $title,
                                   'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
              }
            }
    // bof: Media Check
    Look at the code that I posted and I included the code above the changes and some code below the changes ...

    Start with a clean copy of usps.php so you can just copy in the code I gave you in place of that part of the code in the file ...
    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!]
    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!

  9. #29
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    217
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Hello again! (sadly)

    Ok....below is my code, (with a little before and after), and also a screen shot of what I get to this point

    AllI did was add one book from cat 4



    TEXT_SHIPPING_WEIGHT . ')';
    break;
    default:
    $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
    break;
    }
    }
    // EOF: UPS USPS
    // BOF: UPS USPS
    $this->quotes = array('id' => $this->code,
    'module' => $this->title . $show_box_weight);
    // EOF: UPS USPS
    // bof: Media Check
    // test contents for Media Mail
    $skip_media = false;
    $chk_media = 0;
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','4');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','19');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','20');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','25');
    if ($chk_media != $_SESSION['cart']->count_contents()) {
    $skip_media = true;
    }
    //echo '<br>IN USPS I SEE ' . $chk_media . ' count: ' . $_SESSION['cart']->count_contents() . ' Skip Media: ' . ($skip_media == true ? 'YES' : 'NO') . '<br>';
    $methods = array();
    $size = sizeof($uspsQuote);
    for ($i=0; $i<$size; $i++) {
    list($type, $cost) = each($uspsQuote[$i]);
    // BOF: UPS USPS
    $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
    if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
    /*
    $methods[] = array('id' => $type,
    'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    */
    if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
    } else {
    $cost = preg_replace('/[^0-9.]/', '', $cost);
    $methods[] = array('id' => $type,
    'title' => $title,
    'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
    }
    }
    // bof: Media Check

    $methods = array();
    $size = sizeof($uspsQuote);
    for ($i=0; $i<$size; $i++) {
    list($type, $cost) = each($uspsQuote[$i]);
    // BOF: UPS USPS
    $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
    if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
    Attached Images Attached Images  

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

    Default Re: Media Mail Option

    Okay ... here is the whole function quote ...
    Code:
      /**
       * Get quote from shipping provider's API:
       *
       * @param string $method
       * @return array of quotation results
       */
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
    
        if ( zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
          $this->_setService($method);
        }
    
    
        // usps doesnt accept zero weight send 1 ounce (0.0625) minimum
        $usps_shipping_weight = ($shipping_weight <= 0.0 ? 0.0625 : $shipping_weight);
        $shipping_pounds = floor ($usps_shipping_weight);
        $shipping_ounces = (16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
        // usps currently cannot handle more than 5 digits on international
        $shipping_ounces = zen_round($shipping_ounces, 3);
        // weight must be less than 35lbs and greater than 6 ounces or it is not machinable
        switch(true) {
          case ($shipping_pounds == 0 and $shipping_ounces < 6):
          // override admin choice too light
          $is_machinable = 'False';
          break;
    
          case ($usps_shipping_weight > 35):
          // override admin choice too heavy
          $is_machinable = 'False';
          break;
    
          default:
          // admin choice on what to use
          $is_machinable = MODULE_SHIPPING_USPS_MACHINABLE;
        }
    
        $this->_setMachinable($is_machinable);
        $this->_setContainer('None');
        $this->_setSize('REGULAR');
        $this->_setFirstClassType('FLAT');
    
        $this->_setWeight($shipping_pounds, $shipping_ounces);
        $uspsQuote = $this->_getQuote();
    
        if (is_array($uspsQuote)) {
          if (isset($uspsQuote['error'])) {
            $this->quotes = array('module' => $this->title,
                                  'error' => $uspsQuote['error']);
          } else {
    
            // BOF: UPS USPS
            if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
              switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
                case (0):
                $show_box_weight = '';
                break;
                case (1):
                $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
                break;
                case (2):
                $show_box_weight = ' (' . number_format($usps_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
                break;
                default:
                $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
                break;
              }
            }
            // EOF: UPS USPS
    
            // BOF: UPS USPS
            $this->quotes = array('id' => $this->code,
            'module' => $this->title . $show_box_weight);
            // EOF: UPS USPS
    
    // bof: Media Check
    // test contents for Media Mail
            $skip_media = false;
            $chk_media = 0;
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','4');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','19');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','20');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','25');
            if ($chk_media != $_SESSION['cart']->count_contents()) {
              $skip_media = true;
            }
    //echo '<br>IN USPS I SEE ' . $chk_media . ' count: ' . $_SESSION['cart']->count_contents() . ' Skip Media: ' . ($skip_media == true ? 'YES' : 'NO') . '<br>';
            $methods = array();
            $size = sizeof($uspsQuote);
            for ($i=0; $i<$size; $i++) {
              list($type, $cost) = each($uspsQuote[$i]);
    
              // BOF: UPS USPS
              $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
              if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
              /*
              $methods[] = array('id' => $type,
              'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
              'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              */
    
              if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
              } else {
                $cost = preg_replace('/[^0-9.]/', '',  $cost);
                $methods[] = array('id' => $type,
                                   'title' => $title,
                                   'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
              }
            }
    // bof: Media Check
    
            $this->quotes['methods'] = $methods;
    
            if ($this->tax_class > 0) {
              $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
            }
          }
        } elseif ($uspsQuote == -1) {
          $this->quotes = array('module' => $this->title,
                                'error' => MODULE_SHIPPING_USPS_TEXT_SERVER_ERROR . (MODULE_SHIPPING_USPS_SERVER=='test' ? MODULE_SHIPPING_USPS_TEXT_TEST_MODE_NOTICE : ''));
        } else {
          $this->quotes = array('module' => $this->title,
                                'error' => MODULE_SHIPPING_USPS_TEXT_ERROR . (MODULE_SHIPPING_USPS_SERVER=='test' ? MODULE_SHIPPING_USPS_TEXT_TEST_MODE_NOTICE : ''));
        }
    
        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
        return $this->quotes;
      }
      /**
       * check status of module
       *
       * @return boolean
       */
    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!]
    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!

 

 
Page 3 of 5 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. Media mail surcharge
    By Arunachala in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 13 Jun 2011, 01:42 AM

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