Magento – How to enable to “Create Shipping Label” for a custom shipping method

custom-shipping-methodmagento2

I have been developing a Magento 2 plugin based upon the standard format being used here:

https://magenticians.com/create-magento-2-shipping-module-method/

It all seems to be working well, but now we want to be able to take the information from the selected booking option and actually use it to book a shipment for the order.

On doing some research it seems the standard way to do this in Magento 2 is to go through Sales > Orders > View Order > Ship… At that point you can either add a tracking number for a manual shipment or (if it applies like for example the Magento 2 UPS module) select "Create Shipping Label" from the Shipment options and then follow this process through.

I have gone through the UPS module and it looks as though I have found the actual booking logic somewhere between the Carrier.php _doShipmentRequest and _sendShipmentAcceptRequest however I can't seem to find the logic that actually enables this checkbox. Can anyone advise where I should be looking for this?

Thanks

Best Answer

So in my case the tutorial doesn't quite apply to what i was doing. To make the button i was looking for appear and allow me to continue down the route i was looking for a couple of things had to be done:

  1. AbstractCarrier changed to AbstractCarrierOnline
  2. Changed __construct to work with the new base (see module_ups)
  3. Add the function IsShippingLablesAvailable with a return of true

Answer was courtesy of the Magento Community user Sunil Patel to my similar question on there... (Thanks!)

https://community.magento.com/t5/Magento-2-x-Programming/How-can-i-create-a-module-similar-to-UPS-that-allows-me-to-book/m-p/101506/highlight/false#M5235

It seems fairly poor to ask a question and get credit for the answer, so if someone with more magento experience would like to review this and perhaps add some useful how/why you need to do what I've done then ill mark that answer.

My answer posted in case someone was looking for a similar thing in the meantime.

Related Topic