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!
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';