1
votes

I am trying to create a new shipping method. This method allows users to COLLECT items from a paticular warehouse. So not much involved really.

I have followed a couple of tuts online, and have my module built and installed. It is working on the backend, i can enAble it, and set various values.

When i use the frontend checkout....or even use the following code:

Mage::getSingleton('shipping/config')->getAllCarriers();

I do not get the new shipping method name output.

The message i get on the frontend checkout is:

Sorry, no quotes are available for this order at this time.

Even though i have other shipping methods enabled.


I have another extension in use (regarding stock located in several warehouses). As part of this extension, it lists available shipping options...so that i can assign specific options to a specific warehouse. My new shipping method is not listed that shipping options list.


I seem to have everything required. My other extension is not picking up the method...so must be missing something. Also, given i am getting no shipping options on frontend...confusing. Been at this a while...debugging :(

any help much appreciated.

1
Bit too much info to discuss regarding setting up a new module. If anyone has any questions, ill happily go through the process, and what I currently have....try to narrow down where my issue might be. - ShaunTheSheep

1 Answers

0
votes

I was creating a complex shipping method...rather than a copy of the free shipping method. Turns out i actually needed a copy of the free shipping method, so made my life easier... This was easier than i thought it would be.

Dont want to post all my code (you will also need a config.xml and system.xml file) but heres my carrier model logic file:

class Myco_Clickcollectshipping_Model_Carrier_Mymethod extends Mage_Shipping_Model_Carrier_Abstract {

protected $_code = 'mymethod ';

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{

    if (!$this->getConfigFlag('active')) {
        return false;
    }

    $freeBoxes = 0;
    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {
            if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
                $freeBoxes+=$item->getQty();
            }
        }
    }

    $this->setFreeBoxes($freeBoxes);

    $result = Mage::getModel('shipping/rate_result');
    if ($this->getConfigData('type') == 'O') { // per order
        $shippingPrice = $this->getConfigData('price');
    } elseif ($this->getConfigData('type') == 'I') { // per item
        $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
    } else {
        $shippingPrice = false;
    }

    $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);

    if ($shippingPrice !== false) {
        $method = Mage::getModel('shipping/rate_result_method');

        $method->setCarrier('mymethod ');
        $method->setCarrierTitle($this->getConfigData('title'));

        $method->setMethod('mymethod ');
        $method->setMethodTitle($this->getConfigData('name'));

        if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
            $shippingPrice = '0.00';
        }

        $method->setPrice($shippingPrice);
        $method->setCost($shippingPrice);

        $result->append($method);

    }

    return $result;
}

public function getAllowedMethods()
{
    return array('mymethod ' => $this->getConfigData('name'));
}
}