<?php
/**
 * Order Confirmation Widget
 * Displays order details on the Thank You page after checkout
 *
 * @package GGM_Commerce
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

require_once __DIR__ . '/widget-order-confirmation/elementor-render.php';

class GGM_Commerce_Widget_Order_Confirmation extends \GGM_Commerce_Base_Widget {

	public function get_name() {
		return 'ggmc-order-confirmation';
	}

	public function get_title() {
		return 'Order Confirmation';
	}

	public function get_icon() {
		return 'eicon-check-circle';
	}

	public function get_categories() {
		return [ 'ggmc-widgets' ];
	}

	/**
	 * Get widget keywords.
	 */
	public function get_keywords() {
		return [ 'ggm-commerce', 'order', 'confirmation', 'thank you', 'receipt' ];
	}

	/**
	 * Register widget controls.
	 */
	protected function register_controls() {
		require __DIR__ . '/widget-order-confirmation/elementor-controls.php';
		require __DIR__ . '/widget-order-confirmation/elementor-controls-style.php';
	}

	/**
	 * Render widget output.
	 */
	protected function render() {
		ggmc_order_confirmation_render( $this );
	}

	/**
	 * Static method to generate order confirmation URL.
	 * Called from checkout after order creation.
	 *
	 * @param object $order Order object.
	 * @return string Order confirmation URL.
	 */
	public static function get_confirmation_url( $order ) {
		// Delegate to the helper which is always available during AJAX.
		return GGM_Commerce_Helpers::get_order_confirmation_url( $order );
	}

	/**
	 * Get default styles for this widget.
	 */
	public static function get_static_default_styles() {
		return self::get_defaults_from_config();
	}
}
