1

Most of my inventory I sell is books, which I offer to ship through media mail.

However I recently started selling other products which aren't media related items. How do I set up Magento that when one purchases one of these non-media items, automatically media mail won't show up as an shipping option?

1 Answer 1

2

I don't know what media mail is, but If it's properly implemented in Magento there should be a method called collectRates in the shipping method model. You need to change this method to return nothing in case you have non-media items in the cart. The method collectRates receives a parameter called $request.

Here is how you can do it.

foreach ($request->getAllItems() as $item) {
    //$product = $item->getProduct(); //you can access the product entity if needed
    if (condition here to check if $item or $product is non-media) {
         //so if non-media
         return false;
    }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.