Automattic\WooCommerce\Internal\ShopperLists
ShopperList::get_by_slug_raw
Load a list by slug without the feature-flag gate, for internal callers (e.g. privacy export/erase). Do not use for user-facing reads.
Метод класса: ShopperList{}
Хуков нет.
Возвращает
self|false.
Использование
$result = ShopperList::get_by_slug_raw( $slug, ?int $user_id );
- $slug(строка) (обязательный)
- List identifier.
- ?int $user_id
- .
По умолчанию:null
Код ShopperList::get_by_slug_raw() ShopperList::get by slug raw WC 11.2.2
public static function get_by_slug_raw( string $slug, ?int $user_id = null ) {
if ( ! in_array( $slug, wc_get_container()->get( ShopperListsController::class )->get_supported_slugs(), true ) ) {
return false;
}
$user_id = absint( $user_id ? $user_id : get_current_user_id() );
if ( ! $user_id ) {
return false;
}
$stored = Users::get_site_user_meta( $user_id, self::META_KEY_PREFIX . $slug );
if ( is_array( $stored ) ) {
return self::from_array( $stored, $user_id );
}
return new self(
$user_id,
$slug,
current_time( 'mysql', true ),
array()
);
}