Skip to content

getPrice() returns a string when setting custom price in admin order #25968

Closed
@ghost

Description

Preconditions

M 2.3.3

Steps to reproduce

  1. The method getPrice() from /vendor/magento/module-sales/Model/Order/Item.php
    /**
     * Return price
     *
     * @return float|null
     */
    public function getPrice()
    {
        return $this->getData(OrderItemInterface::PRICE);
    }

Expected result

Clearly states it should return a float, or null.

Actual result

However, when creating a MOTO order, and you set a custom price for a product, when you call getPrice() for the order items, the returned value will be a string, not a float.

We switched to getBasePrice() (seemingly operates the same as getPrice()....) as that should also return a float, or null. It worked fine locally, but had a report that on Magento Cloud, it would return a string.

Metadata

Metadata

Assignees

Labels

Component: SalesFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions