Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-sales
Model
Order
Validation
CanShip.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Sales\Model\Order\Validation
;
7
8
use
Magento\Sales\Api\Data\OrderInterface
;
9
use
Magento\Sales\Model\Order
;
10
use
Magento\Sales\Model\ValidatorInterface
;
11
15
class
CanShip
implements
ValidatorInterface
16
{
21
public
function
validate
(
$entity
)
22
{
23
$messages = [];
24
if
(!$this->isStateReadyForShipment(
$entity
)) {
25
$messages[] =
__
(
'A shipment cannot be created when an order has a status of %1'
,
$entity
->getStatus());
26
}
elseif
(!$this->
canShip
(
$entity
)) {
27
$messages[] =
__
(
'The order does not allow a shipment to be created.'
);
28
}
29
30
return
$messages;
31
}
32
37
private
function
isStateReadyForShipment(
OrderInterface
$order
)
38
{
39
if
(
$order
->getState() ===
Order::STATE_PAYMENT_REVIEW
||
40
$order
->getState() ===
Order::STATE_HOLDED
||
41
$order
->getIsVirtual() ||
42
$order
->getState() ===
Order::STATE_CANCELED
43
) {
44
return
false
;
45
}
46
47
return
true
;
48
}
49
54
private
function
canShip
(
OrderInterface
$order
)
55
{
57
foreach
(
$order
->getItems() as
$item
) {
58
if
(
$item
->getQtyToShip() > 0 && !
$item
->getIsVirtual() && !
$item
->getLockedDoShip()) {
59
return
true
;
60
}
61
}
62
63
return
false
;
64
}
65
}
Magento\Sales\Model\Order\canShip
canShip()
Definition:
Order.php:709
Magento\Sales\Model\Order\STATE_HOLDED
const STATE_HOLDED
Definition:
Order.php:73
elseif
elseif(isset( $params[ 'redirect_parent']))
Definition:
iframe.phtml:17
Magento\Sales\Model\Order
$order
$order
Definition:
order.php:55
__
__()
Definition:
__.php:13
$item
$item
Definition:
partial_invoice.php:27
Magento\Sales\Model\Order\Validation
Definition:
CanInvoice.php:6
Magento\Sales\Api\Data\OrderInterface
Definition:
OrderInterface.php:17
Magento\Sales\Model\Order\STATE_CANCELED
const STATE_CANCELED
Definition:
Order.php:71
Magento\Sales\Model\ValidatorInterface
Definition:
ValidatorInterface.php:14
Magento\Sales\Model\Order\Validation\CanShip
Definition:
CanShip.php:15
$entity
$entity
Definition:
element.phtml:22
Magento\Sales\Model\Order\Validation\CanShip\validate
validate($entity)
Definition:
CanShip.php:21
Magento\Sales\Model\Order\STATE_PAYMENT_REVIEW
const STATE_PAYMENT_REVIEW
Definition:
Order.php:75