Automattic\WooCommerce\Internal\RestApi\Routes\V4\Orders
UpdateUtils::item_is_null_or_zero
Helper method to check if the resource ID associated with the provided item is null. Items can be deleted by setting the resource ID to null.
Method of the class: UpdateUtils{}
No Hooks.
Returns
true|false. True if the item resource ID is null, false otherwise.
Usage
// protected - for code of main (parent) or child class $result = $this->item_is_null_or_zero( $item );
- $item(array) (required)
- Item provided in the request body.
UpdateUtils::item_is_null_or_zero() UpdateUtils::item is null or zero code WC 10.4.3
protected function item_is_null_or_zero( $item ) {
$keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' );
foreach ( $keys as $key ) {
if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
return true;
}
}
if ( array_key_exists( 'quantity', $item ) && 0 === $item['quantity'] ) {
return true;
}
return false;
}