Automattic\WooCommerce\Internal\ShopperLists
ShopperList::from_array
Build a ShopperList from a stored array.
Method of the class: ShopperList{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = ShopperList::from_array( $data, $user_id ): self;
- $data(array) (required)
- Stored list record.
- $user_id(int) (required)
- Owning user ID.
ShopperList::from_array() ShopperList::from array code WC 10.9.1
private static function from_array( array $data, int $user_id ): self {
$items = array();
if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) {
foreach ( $data['items'] as $key => $item_data ) {
if ( ! is_array( $item_data ) ) {
continue;
}
try {
$items[ (string) $key ] = ShopperListItem::from_array( $item_data );
} catch ( \Throwable $e ) {
continue;
}
}
}
return new self(
$user_id,
$data['slug'] ?? '',
$data['date_created_gmt'] ?? current_time( 'mysql', true ),
$items
);
}