TransWikia.com

Problem with custom shipping module

Magento Asked by Robert Pounder on December 4, 2021

When upgrading from 1.6-1.9 our shipping module just seems to come up with problem after problem, assuming its outdated XML, was just wondering if anyone can see any issues with the config xml we have as when playing about with everything to do with the shipping module this seems to be the only thing that changing doesn’t affect anything.

Just to be clear the problem we are having it, the products used to be put into a matrix (defined in config) now it just has the default handling fee as the total cost of shipping and not adding the relevant price matrix, anyway heres the config:

<?xml version="1.0"?>
<config>
    <modules>
        <Excellence_Ship>
            <version>0.1.0</version>
        </Excellence_Ship>
    </modules>

    <default>
        <carriers>
            <excellence>
                <active>1</active>
                <model>ship/carrier_excellence</model>
                <title>Carrier Title</title>
                <name>Method Name</name>
                <price>5.00</price>
                <dgn_fee>3.95</dgn_fee>
                <sml_box_fee>5.50</sml_box_fee>
                <med_box_fee>7.95</med_box_fee>
                <lrg_box_fee>10.50</lrg_box_fee>
                <nonhazone>TNT</nonhazone>
                <nonhaztwo>Airsure</nonhaztwo>
                <hazone>TNT</hazone>
                <haztwo>Airsea Worldwide</haztwo>
                <lastchoice>International Signed For</lastchoice>
                <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
            </excellence>
        </carriers>
    </default>

    <global>
        <blocks>
            <ship>
                <class>Excellence_Ship_Block</class>
            </ship>
            <checkout>
                <rewrite>
                    <cart_shipping>Excellence_Ship_Block_Cart_Shipping</cart_shipping>
                </rewrite>
            </checkout>         
        </blocks>
        <models>
        <ship>
            <class>Excellence_Ship_Model</class>
        </ship>       
        </models>
        <helpers>
        <ship>
                <class>Excellence_Ship_Helper</class>
        </ship>       
        </helpers>
    </global>

    <adminhtml>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <my_boxes>
                                            <title>Configure Boxes</title>
                                        </myboxes>
                                        <dummy_products>
                                            <title>Configure Dummy Products</title>
                                        </dummy_products>
                                        <tnt_stuff>
                                            <title>Configure TNT Tables</title>
                                        </tnt_stuff>
                                        <airsure_stuff>
                                            <title>Configure Airsure Tables</title>
                                        </airsure_stuff>
                                        <airsea_stuff>
                                            <title>Configure AirSea Tables</title>
                                        </airsea_stuff>
                                        <isf_stuff>
                                            <title>Configure ISF Tables</title>
                                        </isf_stuff>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>

</config>

Carrier:

<?php
class Excellence_Ship_Model_Carrier_Excellence extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface {
    protected $_code = 'excellence';

    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
            return false;
        }

        $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
        $result = Mage::getModel('shipping/rate_result');
        $show = true;
        if($show){ // This if condition is just to demonstrate how to return success and error in shipping methods

            $method = Mage::getModel('shipping/rate_result_method');
            $method->setCarrier($this->_code);
            $method->setMethod($this->_code);
            $method->setCarrierTitle($this->getConfigData('title'));
            $method->setMethodTitle($this->getConfigData('name'));
            $method->setPrice($this->getConfigData('price'));
            $method->setCost($this->getConfigData('price'));
            $result->append($method);

        }else{
            $error = Mage::getModel('shipping/rate_result_error');
            $error->setCarrier($this->_code);
            $error->setCarrierTitle($this->getConfigData('name'));
            $error->setErrorMessage($this->getConfigData('specificerrmsg'));
            $result->append($error);
        }
        return $result;
    }
    public function getAllowedMethods()
    {
        return array('excellence'=>$this->getConfigData('name'));
    }
}

LAST THING

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <myconfig translate="label" module="ship">
            <label>My Shipping Config</label>
            <sort_order>99999</sort_order>
        </myconfig>
    </tabs>
    <sections>
        <my_boxes translate="label" module="ship">
            <label>Boxes</label>
            <tab>myconfig</tab>
            <frontend_type>text</frontend_type>
            <sort_order>1000</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <non_hazardous translate="label">
                    <label>Non-Hazardous Boxes</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <my2_dim translate="label">
                            <label>My 2 Dimensions</label>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>300</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                            <comment>Dimensions of My 2 box. L W H (one per line)</comment>
                        </my2_dim>

One Answer

It seems the carrier model only uses the 'price' field, as you can see in the following two lines:

        $method->setPrice($this->getConfigData('price'));
        $method->setCost($this->getConfigData('price'));

It retrieves the config data field 'price', but it doesn't use the other fields like dgn_fee, sml_box_fee etc.

Maybe you're using an older unfinished version of the extension?

Answered by Milan Simek on December 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP