Handling Manual Orders with Free Shipping for Cash Payment and Pickup in Magento
Hello! I understand that you’re looking to manually create orders via the admin backend where customers pay cash on delivery and have the option to pick up their items directly from your store. Here’s a step-by-step guide on how to achieve this.
Enabling Cash on Delivery Only for the Backend
To enable cash payment only in the backend, you’ll need to modify the shipping methods available for admin orders. Follow these steps:
-
Navigate to “Stores” â “Configuration” â “Sales” â “Payment Methods”.
-
Find the “Cash On Delivery” method and set it as “Disabled” for your frontend (customer) scope.
-
In the “Backend” or “Default Config” scope, set it as “Enabled”. This ensures that cash on delivery is available only when creating orders in the backend.
-
Save the configuration and clear cache using “System” â “Cache Management”.
Offering Pickup Option Exclusively for Backend Orders
To offer pickup as an option only for backend orders, you’ll need to create a custom shipping method that is visible only to admin users. Here’s how:
-
Create a new module in your Magento installation using the following directory structure:
app/code/Vendor/CustomShipping/etc/config.xml. -
Define your custom shipping method configuration in the “etc/config.xml” file:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_CustomShipping">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>
- Create a new file
app/code/Vendor/CustomShipping/etc/adminhtml/system.xmlto configure the admin settings for your pickup option:
<system xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ConfigurableProduct:etc/system_file.xsd">
<config>
<groups>
<customshipping translate="title" module="Vendor_CustomShipping">
<label>Custom Shipping</label>
<reset>Default Value</reset>
<sortOrder>10</sortOrder>
<sections>
<pickup_options sectionType="text" sortOrder="10" showInWebsite=true showInStore=false translate="label">
<label>Pickup Options</label>
<comment></comment>
<fields>
<enabled field-type="select" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="0">
<label>Enabled</label>
<sourceModel>Magento\Config\Model\Config\Source\Yesno</sourceModel>
</enabled>
</fields>
</pickup_options>
</sections>
</customshipping>
</groups>
</config>
</system>
- Create a custom shipping model in
app/code/Vendor/CustomShipping/Model/Checkout/Pickup.php:
class Pickup extends \Magento\Quote\Model\ShippingMethod\AbstractShipping
{
public function isFixed()
{
return true;
}
public function getAllowedMethods()
{
return ['pickup' => 'Pickup'];
}
}
- Register your custom shipping method in
app/code/Vendor/CustomShipping/etc/shipping.xml:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<shipping>
<carrier name="pickup">
<title>Pickup</title>
<model>Vendor\CustomShipping\Model\Checkout\Pickup</model>
<active>1</active>
<specific_error>Sorry, we cannot ship to this address.</specific_error>
<allowed_methods>pickup</allowed_methods>
<sort_order>101</sort_order>
</carrier>
</shipping>
</config>
- Flush the cache and recompile from “System” â “Cache Management”.
Creating a Manual Order with Free Shipping and Pickup Option
Now, when you create an order in the backend using “Sales” â “Orders” â “Create New Order”, you’ll find your custom pickup option available for shipping method selection. Set it as free shipping or adjust the fee as needed.
Remember to enable the pickup option from “Stores” â “Configuration” â “Sales” â “Shipping Methods” â “Pickup Options”.
For detailed instructions on creating a custom module in Magento, please refer to our official documentation.
Conclusion
By following this guide, you should now be able to handle manual orders via the admin backend with cash payment and pickup options enabled specifically for these orders. This allows you to provide a seamless shopping experience while maintaining control over certain features for your internal order management process.
If you have any further questions or need assistance with Magento development, feel free to explore our services at Laravel Company. We specialize in creating custom eCommerce solutions tailored to your business needs.