<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Template/class file; variables are widget-scoped, not true globals.
/**
 * Shop archive shell: outputs assigned Elementor library template (no default product loop).
 *
 * Render before any loop so Elementor’s recursion guard does not match the current post ID.
 *
 * @package storzen
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();

$id = class_exists( 'Storzen_WC_Elementor_Templates' )
	? Storzen_WC_Elementor_Templates::get_shop_template_id()
	: 0;

$rendered = '';
if ( $id && class_exists( '\Elementor\Plugin' ) ) {
	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor HTML output.
	$rendered = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $id, true );
}

if ( is_string( $rendered ) && '' !== trim( $rendered ) ) {
	echo $rendered; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( function_exists( 'woocommerce_content' ) ) {
	woocommerce_content();
}

get_footer();
