Oba-san
- Join Date:
- Sep 2003
- Location:
- Ohio
- Posts:
- 62,757
- Plugin Contributions:
- 1
USPS allow media mail based on cart contents?
How about something like this:
if (preg_match('#First\-Class.*(?!GXG|International)#i', $type)) {
$cnt_first ++;
}
[B]// USPS customize for filtering displayed methods and costs
echo 'USPS $type: ' . $type . '<br>';
// bof: Media Check
// test contents for Media Mail
$skip_media = false;
$chk_media = 0;
/* ----------------------- here is where you can add more media mail categories in the future ....
Just copy and paste the following line including semicolon into the correct numerical order and replace the words at the end with the category number
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','category number goes here');
*/
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','77');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','78');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','79');
// skip Media if shopping cart does not hold *only* Products allowed to go Media based on master_categories_id
if ($chk_media != $_SESSION['cart']->count_contents()) {
$skip_media = true;
}
// if ($type == 'Media MailRM' && $skip_media) {
if (preg_match('#Media Mail#i', $type) && $skip_media) { // bof: if $skip_media
// skip Media Mail
// echo 'USPS Skip Media ' . '<br>';
} else {
[/B] if ($this->usps_countries == 'US' && MODULE_SHIPPING_USPS_FIRST_CLASS_FILTER_US == 'True' && preg_match('#First\-Class#i', $type) && $cnt_first > 1) continue;
$methods[] = array('id' => $type_rebuilt,
'title' => $title,
'cost' => $cost,
);
[B] } // eof: if $skip_media [/B]
} else {
//echo 'MISSING! USPS $type: ' . $type . (in_array($type, $this->typeCheckboxesSelected) ? ' YES' : ' NO') . ' $method: ' . $method . ' $usps_shipping_weight: ' . $usps_shipping_weight . ' $minweight: ' . $minweight . ' $maxweight: ' . $maxweight . '<br>';
}
} // end for $i to $PackageSize
if (sizeof($methods) == 0) return false;

