cancel
Showing results for 
Search instead for 
Did you mean: 

Error creating CustomShipping

Error creating CustomShipping

Hi! I am new to Magento, actually trying 2.4 Community.

 

I have installed Magento correctly and all features seem to be running OK. Now I am trying to create a custom shipping carrier, so I followed this tutorial from Adobe, but it is throwing an error that I cannot resolve. I have searched anywhere and didn't found anything that could help me. The error happens when I try to compile the code, after enabling the module. The command is the following:

 

bin/magento setup:di:compile

And it throws the following error:

 

Fatal error: Type of Vendor\CustomShipping\Model\Carrier\Customshipping::$_code 
must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier)
in /var/www/html/magento/app/code/Vendor/CustomShipping/Model/Carrier/Customshipping.php
on line 18

 

Does someone know what I could be doing wrong? Anything helps. Thanks!

 

1 REPLY 1

Re: Error creating CustomShipping

Can't be certain without seeing your code but I guess based on the error that it wants you to not define $_code as string, so it wants you to change:

 

protected string $_code = 'customshipping';

to

 

protected $_code = 'customshipping';
Founder at https://agency418.com