[23-Mar-2024 11:34:42 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Uri.php on line 24 [23-Mar-2024 17:22:13 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Toolbar.php on line 22 [26-Mar-2024 13:29:00 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Shortcode.php on line 19 [07-Apr-2024 20:50:03 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_SingletonTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Compatibility.php on line 21 [22-Apr-2024 01:11:01 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/LoginRedirect.php on line 23 [27-Apr-2024 12:01:47 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_SingletonTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Core.php on line 29 [29-Apr-2024 08:46:14 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Capability.php on line 16 [20-May-2024 23:30:31 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Capability.php on line 16 [14-Jun-2024 03:19:07 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Capability.php on line 16 [15-Jun-2024 11:51:01 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Uri.php on line 24 [21-Jun-2024 22:54:39 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_SingletonTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Compatibility.php on line 21 [25-Jul-2024 17:18:44 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [25-Jul-2024 17:18:44 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Toolbar.php on line 22 [15-Aug-2024 09:41:56 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [15-Aug-2024 09:41:56 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [15-Aug-2024 09:41:56 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Capability.php on line 16 [26-Aug-2024 09:54:58 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [26-Aug-2024 09:54:58 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [26-Aug-2024 09:54:58 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Capability.php on line 16 [28-Aug-2024 00:16:58 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [28-Aug-2024 00:16:58 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [28-Aug-2024 00:16:58 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Shortcode.php on line 19 [06-Sep-2024 22:28:06 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [06-Sep-2024 22:28:06 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [06-Sep-2024 22:28:06 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_SingletonTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Core.php on line 29 [11-Sep-2024 15:48:15 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [11-Sep-2024 15:48:15 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [11-Sep-2024 15:48:15 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/SecureLogin.php on line 32 [13-Sep-2024 13:54:30 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [13-Sep-2024 13:54:30 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [13-Sep-2024 13:54:30 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/DeniedRedirect.php on line 21 [24-Sep-2024 18:09:42 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [24-Sep-2024 18:09:42 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [24-Sep-2024 18:09:42 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_RequestTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/Toolbar.php on line 22 [24-Oct-2024 10:28:10 UTC] PHP Warning: Module 'sodium' already loaded in Unknown on line 0 [24-Oct-2024 10:28:10 UTC] PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1692 but version 1693 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 [24-Oct-2024 10:28:10 UTC] PHP Fatal error: Trait 'AAM_Core_Contract_ServiceTrait' not found in /home/xhtmljunkies/public_html/wp-content/plugins/advanced-access-manager/application/Service/DeniedRedirect.php on line 21 Create a Shipping Method Module In Magento | Xhtmljunkies
Check out our newest developed Magento 2 Customer Discount More Info

Create a Shipping Method Module In Magento

Shipping Method ModuleMagento is one of the best and well-to-do e-commerce platforms where you can find quite a lot of shipping methods. On the other hand, when you are having big e-commerce sites you may need to build up your own custom shipping methods.

Generating a custom shipping method is not so difficult; you just have to get all the necessary information regarding various functions that have to be use inside the shipping method class to put in various configuration selections.

Every shipping method can be prepared as separate module but if some methods could be used together or have same functionality than it can be combined in the same module.

Make sure that app/code/local is in PHP‘s include_path. For doing this, you need to carry out the following code:

<?php echo get_include_path();?>

Be certain you place this code anywhere after Magento was loaded.
Configuration:

You need to form app/code/local/YourCompany/NewModule/etc/config.xml:
<?xml version=”1.0″?>
<config>
<modules>
<!– declare module’s version information –>
<YourCompany_NewModule>
<!– this version number will be used for database upgrades –>
<version>0.1.0</version>
</YourCompany_NewModule>
</modules>
<global>
<!– declare model group for new module –>
<models>
<!– model group alias to be used in Mage::getModel() –>
<newmodule>
<!– base class name for the model group –>
<class>YourCompany_NewModule_Model</class>
</newmodule>
</models>
<!– declare resource setup for new module –>
<resources>
<!– resource identifier –>
<newmodule_setup>
<!– specify that this resource is a setup resource and used for upgrades –>
<setup>
<!– which module to look for install/upgrade files in –>
<module>YourCompany_NewModule</module>
</setup>
<!– specify database connection for this resource –>
<connection>
<!– do not create new connection, use predefined core setup connection –>
<use>core_setup</use>
</connection>
</newmodule_setup>
</resources>
</global>
</config>

Now, create app/etc/modules/YourCompany_NewModule.xml:

<config>
<!– … –>
<modules>
<!– … –>
<!– declare YourCompany_NewModule module –>
<YourCompany_NewModule>
<active>true</active>
<codePool>local</codePool>
</YourCompany_NewModule>
<!– … –>
</modules>
<!– … –>
</config>

Now, create app/code/local/YourCompany/NewModule/Model/Carrier/ShippingMethod.php:

<?php

/**
* Our test shipping method module adapter
*/
class YourCompany_NewModule_Model_Carrier_ShippingMethod 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’));
}
}

Now you need to facilitate your new shipping method in admin panel (System->Configuration->Shipping Methods).

Author: Harshal Shah

Harshal Shah is CEO & Founder of Xhtmljunkies, Located in Gujarat, India, XHTML Junkies is one of the best companies that offer unique eCommerce solutions by the virtue of its dedicated professionals. Our professionals are extremely proficient in offering development services pertaining to eCommerce. You can find Harshal on and Twitter.

The following two tabs change content below.

Harshal Shah

Harshal Shah is CEO & Founder of Xhtmljunkies, Located in Gujarat, India, XHTML Junkies is one of the best companies that offer unique eCommerce solutions by the virtue of its dedicated professionals. Our professionals are extremely proficient in offering development services pertaining to eCommerce. You can find Harshal on and Twitter.