4

How to change shipping rate in magento when check out. i have many tried to make

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Module_CustomShippingrate>
            <module>0.0.1</module>
        </Module_CustomShippingrate>
    </modules>
    <global>
        <models>
            <module_customshippingrate>
                <class>Module_CustomShippingrate_Model</class>
            </module_customshippingrate>
        </models>
    </global>
    <!-- Default configuration -->
    <default>
        <carriers>
            <module_customshippingrate>
                <active>1</active>
                <model>module_customshippingrate/carrier</model>
                <title>Shipping Rate</title>
                <sort_order>10</sort_order>
                <sallowspecific>0</sallowspecific>
            </module_customshippingrate>
        </carriers>
    </default>
</config>

Call Of Shipping method class

public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
}
2

You need lot of work for create custom shipping method:

Missing system.xml

<?xml version="1.0"?>
<config>
   <sections>
    <carriers>
        <groups>
            <newmodule translate="label" module="shipping">
                <label>Carrier Name</label>
                <frontend_type>text</frontend_type>
                <sort_order>13</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                   <fields>
                      <account translate="label">
                            <label>Account number</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>7</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </account>
                        <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>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </active>
                        <contentdesc translate="label">
                            <label>Package Description</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </contentdesc>
                        <!--
                        If the free_shipping_enable flag enable, the system will check free_shipping_subtotal to give free shipping
                        otherwise will use shopping cart price rule behaviour
                        -->
                        <free_shipping_enable translate="label">
                            <label>Free shipping with minimum order amount</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                            <sort_order>21</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </free_shipping_enable>
                        <free_shipping_subtotal translate="label">
                            <label>Minimum order amount for free shipping</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>22</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </free_shipping_subtotal>
                        <dutiable translate="label">
                            <label>Shipment Dutiable</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>13</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </dutiable>
                        <gateway_url translate="label">
                            <label>Gateway URL</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </gateway_url>
                        <handling_type translate="label">
                            <label>Calculate Handling Fee</label>
                            <frontend_type>select</frontend_type>
                            <source_model>shipping/source_handlingType</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </handling_type>
                        <handling_action translate="label">
                            <label>Handling Applied</label>
                            <frontend_type>select</frontend_type>
                            <source_model>shipping/source_handlingAction</source_model>
                            <sort_order>11</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </handling_action>
                        <handling_fee translate="label">
                            <label>Handling fee</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </handling_fee>
                        <max_package_weight translate="label">
                            <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>13</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </max_package_weight>
                        <id translate="label">
                            <label>Access ID</label>
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </id>
                        <password translate="label">
                            <label>Password</label>
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>6</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </password>
                        <shipping_intlkey translate="label">
                            <label>Shipping key (International)</label>
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>8</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </shipping_intlkey>
                        <shipping_key translate="label">
                            <label>Shipping key</label>
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>8</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </shipping_key>
                        <sort_order translate="label">
                            <label>Sort order</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </sort_order>
                        <title translate="label">
                            <label>Title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </title>
                        <sallowspecific translate="label">
                            <label>Ship to applicable countries</label>
                            <frontend_type>select</frontend_type>
                            <sort_order>90</sort_order>
                            <frontend_class>shipping-applicable-country</frontend_class>
                            <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </sallowspecific>
                        <specificcountry translate="label">
                            <label>Ship to Specific countries</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>91</sort_order>
                            <source_model>adminhtml/system_config_source_country</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </specificcountry>
                        <showmethod translate="label">
                            <label>Show method if not applicable</label>
                            <frontend_type>select</frontend_type>
                            <sort_order>92</sort_order>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </showmethod>
                        <specificerrmsg translate="label">
                            <label>Displayed Error Message</label>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>80</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </specificerrmsg>
                    </fields>
                </newmodule>
            </groups>
        </carriers>
    </sections>
</config>

Shipping class is not define properly

Every shipping method have an unique identifier in your class it missing

<?php

/**
* Our test shipping method module adapter
*/
class Module_CustomShippingrate_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract
{
  /**
   * unique internal shipping method identifier
   *
   * @var string [a-z0-9_]
   */
  protected $_code = 'newmodule';

  /**
   * Collect rates for this shipping method based on information in $request
   *
   * @param Mage_Shipping_Model_Rate_Request $data
   * @return Mage_Shipping_Model_Rate_Result
   */
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
  {
    // skip if not enabled
    if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
        return false;
    }

    /**
     * here we are retrieving shipping rates from external service
     * or using internal logic to calculate the rate from $request
     * you can see an example in Mage_Usa_Model_Shipping_Carrier_Ups::setRequest()
     */

    // get necessary configuration values
    $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');

    // this object will be returned as result of this method
    // containing all the shipping rates of this method
    $result = Mage::getModel('shipping/rate_result');

    // $response is an array that we have
    foreach ($response as $rMethod) {
      // create new instance of method rate
      $method = Mage::getModel('shipping/rate_result_method');

      // record carrier information
      $method->setCarrier($this->_code);
      $method->setCarrierTitle(Mage::getStoreConfig('carriers/'.$this->_code.'/title'));

      // record method information
      $method->setMethod($rMethod['code']);
      $method->setMethodTitle($rMethod['title']);

      // rate cost is optional property to record how much it costs to vendor to ship
      $method->setCost($rMethod['amount']);

      // in our example handling is fixed amount that is added to cost
      // to receive price the customer will pay for shipping method.
      // it could be as well percentage:
      /// $method->setPrice($rMethod['amount']*$handling/100);
      $method->setPrice($rMethod['amount']+$handling);

      // add this rate to the result
      $result->append($method);
    }

    return $result;
  }

  /**
   * This method is used when viewing / listing Shipping Methods with Codes programmatically
   */
  public function getAllowedMethods() {
    return array($this->_code => $this->getConfigData('name'));
  }
}

See at magento tutorial.How to create custom carrier method

|improve this answer|||||

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.