3

I have built a shipping module that calculates a number of things, then makes three options available for the customer to choose from. I am not using any of the built-in options for shipping.

When I try to create an order (from scratch or a reorder) from the admin, it gives me the message Sorry, no quotes are available for this order at this time.

How do I make my shipping method available to the admin? Do I have to create a separate module for the admin or is there xml I can add to make this available?

I am running version 1.9.

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <ECB_Shipping>
            <version>0.1.0</version>
        </ECB_Shipping>
    </modules>
    <global>
        <models>
            <ecb_shipping>
                <class>ECB_Shipping_Model</class>
            </ecb_shipping>
        </models>
        <helpers>
            <ecb_shipping>
                <class>ECB_Shipping_Helper</class>
            </ecb_shipping>
        </helpers>
    </global>
    <default>
        <carriers>
            <ecb_shipping>
                <active>1</active>
                <sort_order>10</sort_order>
                <model>ecb_shipping/carrier</model>
                <title>ECB Shipping Methods</title>
                <sort_order>10</sort_order>
            </ecb_shipping>
        </carriers>
    </default>
</config>

system.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <sections>
        <carriers>
            <groups>
                <ecb_shipping translate="label">
                    <label>ECB Shipping Methods</label>
                    <sort_order>2</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>0</show_in_website>
                    <show_in_store>0</show_in_store>
                    <fields>
                        <active translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </active>
                        <title translate="label">
                            <label>Shipping Method title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </title>
                    </fields>
                </ecb_shipping>
            </groups>
        </carriers>
    </sections>
</config>

For the cart functions, I won't paste them all here, but some of the items in question have to do with getting the customer's cart. Do these things work for the admin?

$count = Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty();
$cart = Mage::getSingleton('checkout/cart');

This is how the functions are being initialized:

class ECB_Shipping_Model_Carrier
    extends Mage_Shipping_Model_Carrier_Abstract
        implements Mage_Shipping_Model_Carrier_Interface {

The easiest method, the better. If this isn't possible and there is a way to just override this completely and have the admin enter the shipping, that's a fine end solution.

  • Does your custom shipping method follow the right way of creating custom shipping methods ? Understand does your model extend Mage_Shipping_Model_Carrier_Abstract and implement Mage_Shipping_Model_Carrier_Interface ? Maybe a look here could here: inchoo.net/magento/custom-shipping-method-in-magento – Raphael at Digital Pianism Jan 14 '16 at 15:15
  • It is. I've updated the question, but I'm thinking I can probably get away with using a module I found that uses shipping conditions that behave like the coupons. – PBwebD Jan 14 '16 at 15:49
  • Try having a look at Owebia Shipping 2 module, really powerful, lets you create a lot of rules. – Raphael at Digital Pianism Jan 14 '16 at 15:50
1

No need create separate module for the admin or is there xml.

Your bellow code is not working both end (frontend & admin)

$count = Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty();
$cart = Mage::getSingleton('checkout/cart');

So please use bellow code in model file ECB_Shipping_Model_Carrier and it is no issue both end (admin & frontend) and shipping method also available to admin

<?php

class ECB_Shipping_Model_Carrier
    extends Mage_Shipping_Model_Carrier_Abstract
    implements Mage_Shipping_Model_Carrier_Interface

{

   ...
   ...
   ...
    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        if (!$this->getConfigFlag('active')) {
            return false;
        }

        $freeBoxes = 0;
        $count = count($request->getAllItems());

        if ($request->getAllItems()) {
            foreach ($request->getAllItems() as $item) {

                if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                    continue;
                }

                if ($item->getHasChildren() && $item->isShipSeparately()) {
                    foreach ($item->getChildren() as $child) {
                        if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                            $freeBoxes += $item->getQty() * $child->getQty();
                        }
                    }
                } elseif ($item->getFreeShipping()) {
                    $freeBoxes += $item->getQty();
                }
            }
        }

        ...
        ...
        ...

        return $result;
    }
    ...
    ...
    ...
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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