0

Help me to set the pin code based shipping for each product.

Example:

  • Product A - shipment available in xxx pin code
  • but Product B - shipment not available in xxx pin code.

Suppose user add both the product A & B then user place the order the product B automatically remove or alert the shipment unavailable product.

How to set the above requirement?

1 Answer 1

0

You can try my recently created extension

app\etc\modules\Sipping_Disable.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Sipping_Disable>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Sipping_Disable>
  </modules>
</config>

app\code\local\Sipping\Disable\etc\config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Sipping_Disable>
      <version>0.1.0</version>
    </Sipping_Disable>
  </modules>
  <global>
    <models>
      <disable>
        <class>Sipping_Disable_Model</class>
        <resourceModel>disable_mysql4</resourceModel>
      </disable>
            <shipping>
                <rewrite>
                    <shipping>Sipping_Disable_Model_Shipping_Shipping</shipping>
                </rewrite>
            </shipping>
    </models>
  </global>
</config> 

app\code\local\Sipping\Disable\Model\Shipping\Shipping.php

    <?php
    class Sipping_Disable_Model_Shipping_Shipping extends Mage_Shipping_Model_Shipping
    {
        public function collectCarrierRates($carrierCode, $request)
        {
            if (!$this->_isAvailable($carrierCode, $request)) {
               return $this;
            }
            return parent::collectCarrierRates($carrierCode, $request);
        }

        /**
         * @param string $carrierCode
         * @param Varien_Object $request
         * @return bool
         */
        protected function _isAvailable($carrierCode, $request)
        {
/* you can customize code here according to your need */
              $regionCode = $request->getDestRegionCode();
                $cart = Mage::getSingleton('checkout/session')->getQuote();
                $ZipCodes = array('12345','54454'); //all zip codes put here where you want disable shipping
                $shippingAddress = $cart->getShippingAddress();
                $zip = $shippingAddress->getPostcode();
               switch ($carrierCode) {
                    case 'youshippingCode': // put your shipping code
                    if (in_array($zip ,$ZipCodes)) {
                        return false;
                    }
                    break;

          }
            return true;
        }
    }
5
  • Thanks for your reply. In that module how can i check or get each product carrier code? So that only i check the carrier for all the product. Commented Oct 13, 2015 at 7:29
  • Can you describe it in more detail?are you want to check any custom product attribute ??
    – Arunendra
    Commented Oct 14, 2015 at 4:50
  • Suppose in cart ProductA and ProductB. I assigned the shipper AAA for ProductA and BBB for ProductB. If the customer enter XXX as zipcode in shipping address. In Shipper AAA, XXX is not servicable but servicable in Shipper BBB. My Question is how can I get the product's shipper zipcode with the customer entered Zipcode. Commented Oct 14, 2015 at 7:43
  • You can get help from here : magento.stackexchange.com/questions/8814/…
    – Arunendra
    Commented Oct 14, 2015 at 7:54
  • Thanks for your reply. I will check the solution and let you know the status. @Arunendra Commented Oct 14, 2015 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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