Type¶
Namespace: DMS\Listing\Type Obtained via: dms_get_type(), dms_get_current_type(), dms_get_types()
Represents a single inventory type (e.g. Vehicles, Boats). Stores its own settings and provides typed accessors for categories, badges, pricing ranges, and admin links.
Core¶
get_id(): int¶
Returns the type ID.
exists(): bool¶
Returns true if the type was found.
get( string $value, mixed $default = false ): mixed¶
Returns a type property or setting value. Checks direct properties first, then the settings array.
Common keys: id, singular, plural, slug, settings, vdp_template, not_found_image, apply_sold_badge, sold_badge, apply_sale_pending_badge, sale_pending_badge, badge_conditions, hotlink_images
echo esc_html( $type->get( 'plural' ) ); // e.g. "Vehicles"
echo esc_html( $type->get( 'slug' ) ); // e.g. "vehicles"
echo esc_html( $type->get( 'singular' ) ); // e.g. "Vehicle"
set( $name, $value ): bool|int¶
Updates a type property or setting and persists to the database. Direct properties (singular, plural, slug) update their own column; everything else is stored in the serialized settings column.
delete(): bool¶
Deletes the type and all its associated categories and terms.
get_all_data(): array¶
Returns a plain array of all type data including id, singular, plural, slug, and settings.
Categories & Badges¶
get_categories( array $filter = [] ): Category[]¶
Returns all categories belonging to this type, optionally filtered.
$categories = $type->get_categories();
// Filter to a specific setting value
$filterable = $type->get_categories( [ 'is_filterable' => 1 ] );
get_badges( array $args = [] ): Badge[]¶
Returns all badges registered for this type.
Pricing¶
get_price_value( string $min_or_max = 'min' ): int¶
Returns the minimum or maximum price across all published listings for this type.
Admin Links¶
get_link( string $link_type, bool $full_url = false ): string¶
Returns an admin URL for a common action on this type.
$link_type options: view-all, all-categories, templates, new, settings, leads, statuses, imports
$url = $type->get_link( 'settings', true );
$url = $type->get_link( 'leads', true );
$url = $type->get_link( 'new', true );
Groups¶
get_groups(): array¶
Returns listing groups associated with this type.