If cart consists both book and other kind products, then to hide USPS Media mail shipping method, you need to override Model file of USPS into your local folder.
app\code\local\Mage\Usa\Model\Shipping\Carrier\Usps.php
Go to the line no :517 with function _parseXmlResponse.
//to get order is placed from admin side or frontend
$module_name = Mage::app()->getRequest()->getModuleName();
$adminUrl = Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
if ($module_name == $adminUrl) {
$quote_obj = new Mage_Adminhtml_Model_Sales_Order_Create();
} else {
$quote_obj = new Mage_Checkout_Model_Type_Onepage();
}
$Quote = $quote_obj->getQuote();
$isContainBook = false;
foreach ($Quote->getAllItems() as $ext_cart_item) {
//get ur cart item contain only book or not
$isContainBook = true;
}
foreach ($priceArr as $method => $price) {
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier('usps');
if ($method == "6" && !$isContainBook) {
continue;
}
to get the method code for Media Mail Parcel, Go to the line no 576 within function getCode in the same file.
public function getCode($type, $code = '')
{
$codes = array(
'method' => array(
'0_FCLE' => Mage::helper('usa')->__('First-Class Mail Large Envelope'),
'0_FCL' => Mage::helper('usa')->__('First-Class Mail Letter'),
'0_FCSL' => Mage::helper('usa')->__('First-Class Mail Stamped Letter'),
'0_FCP' => Mage::helper('usa')->__('First-Class Package Service - Retail'),
'0_FCPC' => Mage::helper('usa')->__('First-Class Mail Postcards'),
'1' => Mage::helper('usa')->__('Priority Mail'),
'2' => Mage::helper('usa')->__('Priority Mail Express Hold For Pickup'),
'3' => Mage::helper('usa')->__('Priority Mail Express'),
'4' => Mage::helper('usa')->__('Retail Ground'),
'6' => Mage::helper('usa')->__('Media Mail Parcel'),
'7' => Mage::helper('usa')->__('Library Mail Parcel'),
you can get the all methods codes from this funtion.