<?php
namespace Prodigy\Includes\Frontend\Mappers;

use Prodigy\Includes\frontend\Prodigy_Product_Template_Builder;
use Prodigy\Includes\Frontend\Prodigy_Product_Template_Item;
use Prodigy\includes\helpers\Prodigy_Elementor_Layouts;

/**
 * Prodigy product tiered prices data mapper
 *
 * @version    3.0.9
 * @package    Prodigy
 * @subpackage Prodigy/includes
 */
class Prodigy_Product_Tiered_Prices_Data_Mapper extends Prodigy_Main_Data_Mapper {

	/**
	 * @param array $options
	 *
	 * @return array
	 */
	public function get_default_parameters( array $options ): array {
		// Initialize product template and retrieve a product
		$product_template = new Prodigy_Product_Template_Builder( new Prodigy_Product_Template_Item() );
		$default_product  = (int) Prodigy_Product_Template_Builder::get_random_product_id();

		$options['product'] = $GLOBALS['prodigy_product'] ?? $product_template->set_product( $default_product );

		if ( ! Prodigy_Elementor_Layouts::is_elementor_action() ) {
			$options['product'] = $GLOBALS['prodigy_product'] ?? $options['product'];
		}

		return $options;
	}
}
