Skip to content

Error while using code from docs #389

@denish-ktpl

Description

@denish-ktpl

Is there an existing issue for this?

  • I have searched the existing issues

Expected behavior

I have tried code from https://developer.adobe.com/commerce/php/tutorials/frontend/custom-checkout/add-shipping-carrier/#step-3-create-the-carrier-model

While testing with PHP 8.3.4 (cli) (built: Mar 16 2024 08:39:49) (NTS) it is throwing an error

"Fatal Error: 'Type of ---\Model\Carrier\Express::$_code must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier)' in '.../Model/Carrier/Express.php' on line 18"

"Fatal Error: 'Type of ...\Model\Carrier\Express::$_isFixed must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier)' in '.../Model/Carrier/Express.php' on line 18"

Should be fixed in docs.

Actual behavior

It should be corrected

protected string $_code = 'expressdelivery';

protected bool $_isFixed = true;

protected $_code = 'expressdelivery';

protected $_isFixed = true;

Steps to reproduce

Create custom module from https://developer.adobe.com/commerce/php/tutorials/frontend/custom-checkout/add-shipping-carrier/#step-3-create-the-carrier-model

Run coomands
Go to cart or checkout

Environment

  • Browser:Chrome
  • OS:Linux

Sample code

protected string $_code = 'expressdelivery';

protected bool $_isFixed = true;

protected $_code = 'expressdelivery';

protected $_isFixed = true;

Logs

"Fatal Error: 'Type of ---\Model\Carrier\Express::$_code must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier)' in '.../Model/Carrier/Express.php' on line 18"

"Fatal Error: 'Type of ...\Model\Carrier\Express::$_isFixed must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier)' in '.../Model/Carrier/Express.php' on line 18"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    🆕 Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions