<?php
/**
 * @package ThemeREX\AutoDealer
 */

declare(strict_types=1);

namespace ThemeREX\AutoDealer\Elementor\DynamicTags;

if ( ! class_exists( '\Elementor\Core\DynamicTags\Tag' ) ) {
	return;
}

use function ThemeREX\AutoDealer\formatPrice;

class PriceTag extends AbstractVehicleTag {

	protected string $tag_name  = 'trx-ad-price';
	protected string $tag_title = 'Vehicle Price';

	public function __construct( array $data = array() ) {
		parent::__construct( $data );
		$this->tag_title = __( 'Vehicle Price', 'trx-auto-dealer' );
	}

	protected function resolveValue( int $vehicleId ): string {
		$value = $this->specs( $vehicleId, 'price' );
		if ( '' === $value || ! is_numeric( $value ) ) {
			return '';
		}
		return formatPrice( (float) $value, false );
	}
}
