// ──────────────────────────────────────────────

function aevoria_single_product_meta() {
    global $product;
    if (!$product) return;

    echo '<div class="product-meta">';

    if ($product->get_sku()) {
        echo '<div class="product-meta-item">';
        echo '<span class="product-meta-label">' . esc_html__('SKU:', 'aevoria') . '</span>';
        echo '<span>' . esc_html($product->get_sku()) . '</span>';
        echo '</div>';
    }

    echo '<div class="product-meta-item">';
    echo '<span class="product-meta-label">' . esc_html__('Category:', 'aevoria') . '</span>';
    echo '<span>' . wp_kses_post(wc_get_product_category_list($product->get_id())) . '</span>';
    echo '</div>';

    $tags = wc_get_product_tag_list($product->get_id());
    if ($tags) {
        echo '<div class="product-meta-item">';
        echo '<span class="product-meta-label">' . esc_html__('Tags:', 'aevoria') . '</span>';
        echo '<span>' . wp_kses_post($tags) . '</span>';
        echo '</div>';
    }

    echo '</div>';
}

// ──────────────────────────────────────────────
// Mini Cart Helper
// ──────────────────────────────────────────────

function aevoria_mini_cart_content() {
    if (!function_exists('WC') || !WC()->cart) {
        return;
    }

    $cart_items = WC()->cart->get_cart();

    if (empty($cart_items)) {
        echo '<div style="text-align:center; padding: 3rem 1rem; color: var(--aevoria-medium-gray);">';
        echo '<p>' . esc_html__('Your cart is empty', 'aevoria') . '</p>';
        echo '<a href="' . esc_url(wc_get_page_permalink('shop')) . '" class="btn btn--primary btn--sm">' . esc_html__('Start Shopping', 'aevoria') . '</a>';
        echo '</div>';
        return;
    }

    foreach ($cart_items as $cart_item_key => $cart_item) {
        $product = $cart_item['data'];
        $product_id = $cart_item['product_id'];
        $quantity = $cart_item['quantity'];
        $thumbnail = $product->get_image('thumbnail');

        echo '<div class="mini-cart-item" data-cart-key="' . esc_attr($cart_item_key) . '">';

        echo '<div class="mini-cart-item-image">';
        echo '<a href="' . esc_url($product->get_permalink()) . '">' . wp_kses_post($thumbnail) . '</a>';
        echo '</div>';

        echo '<div class="mini-cart-item-details">';
        echo '<div class="mini-cart-item-title">' . esc_html($product->get_name()) . '</div>';
        echo '<div class="mini-cart-item-price">' . wp_kses_post(WC()->cart->get_product_price($product)) . '</div>';
        echo '<div class="mini-cart-item-qty">';
        echo '<button class="qty-minus" data-key="' . esc_attr($cart_item_key) . '">-</button>';
        echo '<span>' . esc_html($quantity) . '</span>';
        echo '<button class="qty-plus" data-key="' . esc_attr($cart_item_key) . '">+</button>';
        echo '</div>';
        echo '</div>';

        echo '<button class="cart-remove mini-cart-item-remove" data-key="' . esc_attr($cart_item_key) . '" aria-label="' . esc_attr__('Remove item', 'aevoria') . '">';
        echo aevoria_icon('close', 16);
        echo '</button>';

        echo '</div>';
    }
}

// ──────────────────────────────────────────────
// Cart Fragments (AJAX cart updates)
// ──────────────────────────────────────────────

function aevoria_cart_fragments($fragments) {
    $count = WC()->cart->get_cart_contents_count();

    ob_start();
    echo '<span class="badge cart-count">' . esc_html($count) . '</span>';
    $fragments['.cart-count'] = ob_get_clean();

    ob_start();
    echo '<span class="badge cart-count-mobile">' . esc_html($count) . '</span>';
    $fragments['.cart-count-mobile'] = ob_get_clean();

    ob_start();
    echo '<strong class="mini-cart-total-amount">' . wp_kses_post(WC()->cart->get_cart_subtotal()) . '</strong>';
    $fragments['.mini-cart-total-amount'] = ob_get_clean();

    ob_start();
    aevoria_mini_cart_content();
    $fragments['#mini-cart-items'] = '<div class="mini-cart-items" id="mini-cart-items">' . ob_get_clean() . '</div>';

    return $fragments;
}
add_filter('woocommerce_add_to_cart_fragments', 'aevoria_cart_fragments');

// ──────────────────────────────────────────────
// Country-based payment gateway filter
// ──────────────────────────────────────────────
//
// Shows only locally-relevant payment methods per billing country.
// e.g. SK customer sees Stripe + Comgate + PayPal, not Przelewy24 or Barion.
// Falls back to all available gateways if country not mapped.
//
// Activate / deactivate gateways in WooCommerce → Settings → Payments first;
// this filter only HIDES from non-target countries.

function aevoria_filter_gateways_by_country($gateways) {
    if (is_admin() || !WC()->customer) return $gateways;

    $country = WC()->customer->get_billing_country();
    if (!$country) return $gateways;

    // Map: country ISO → array of allowed gateway IDs
    $allowed_map = apply_filters('aevoria_country_payment_methods', [
        'SK' => ['stripe', 'stripe_apple_pay', 'stripe_google_pay', 'comgate', 'paypal', 'ppcp-gateway', 'bacs'],
        'CZ' => ['comgate', 'gopay', 'stripe', 'paypal', 'ppcp-gateway', 'bacs'],
        'GB' => ['stripe', 'stripe_apple_pay', 'klarna', 'paypal', 'ppcp-gateway'],
        'EN' => ['stripe', 'stripe_apple_pay', 'klarna', 'paypal', 'ppcp-gateway'],
        'DE' => ['stripe', 'stripe_sepa_debit', 'klarna', 'klarna_sofort', 'klarna_paylater', 'paypal', 'ppcp-gateway'],
        'AT' => ['stripe', 'stripe_sepa_debit', 'klarna', 'paypal', 'ppcp-gateway'],
        'PL' => ['przelewy24', 'blik', 'payu', 'stripe', 'paypal', 'ppcp-gateway'],
        'HU' => ['barion', 'simplepay', 'stripe', 'paypal', 'ppcp-gateway'],
        'RO' => ['netopia', 'euplatesc', 'stripe', 'paypal', 'ppcp-gateway'],
        'BG' => ['borica', 'epay', 'stripe', 'paypal', 'ppcp-gateway'],
    ]);

    if (!isset($allowed_map[$country])) return $gateways;

    $allowed = $allowed_map[$country];
    foreach ($gateways as $id => $gateway) {
        if (!in_array($id, $allowed, true)) {
            unset($gateways[$id]);
        }
    }
    return $gateways;
}
add_filter('woocommerce_available_payment_gateways', 'aevoria_filter_gateways_by_country', 20);

// ──────────────────────────────────────────────
// Related Products
// ──────────────────────────────────────────────

function aevoria_related_products_args($args) {
    $args['posts_per_page'] = 4;
    $args['columns'] = 4;
    return $args;
}
add_filter('woocommerce_output_related_products_args', 'aevoria_related_products_args');

// ──────────────────────────────────────────────
// Breadcrumb defaults
// ──────────────────────────────────────────────

function aevoria_wc_breadcrumb_defaults($defaults) {
    $defaults['delimiter'] = '<span class="breadcrumb-separator">/</span>';
    $defaults['wrap_before'] = '<nav class="breadcrumb"><div class="container"><ol class="breadcrumb-list">';
    $defaults['wrap_after'] = '</ol></div></nav>';
    $defaults['before'] = '<li>';
    $defaults['after'] = '</li>';
    return $defaults;
}
add_filter('woocommerce_breadcrumb_defaults', 'aevoria_wc_breadcrumb_defaults');

// ──────────────────────────────────────────────
// Shop page layout — DISABLED
// ──────────────────────────────────────────────
// The new archive-product.php template ships with its own full-bleed layout
// (hero banner + subcategory cards + chip filter bar). Re-introducing a 280px
// sidebar grid here would break the new design. If you ever need a classic
// sidebar layout, re-enable the function below and rewrite archive-product.php
// to wrap its content in <div class="aevoria-shop-layout">.
//
// function aevoria_shop_layout_styles() { /* ... */ }
// add_action('wp_head', 'aevoria_shop_layout_styles');
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//aevoria.mexcor.sk/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://aevoria.mexcor.sk/post-sitemap.xml</loc>
		<lastmod>2026-05-26T09:16:09+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://aevoria.mexcor.sk/page-sitemap.xml</loc>
		<lastmod>2026-05-26T12:34:58+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://aevoria.mexcor.sk/category-sitemap.xml</loc>
		<lastmod>2026-05-26T09:16:09+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->