69 lines
2.5 KiB
PHP
69 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Shop / category archive — uses Woo hooks, XShop toolbar/grid/empty states.
|
|
*
|
|
* Override is minimal: we keep Woo's before/after hooks but ensure XShop
|
|
* container, breadcrumbs, title, sorting, result count, pagination, and empty state
|
|
* are rendered with XShop components/tokens. For full logic see
|
|
* inc/woocommerce/setup.php hooks (xshop_wc_loop_start, toolbar).
|
|
*
|
|
* WC version tested: 11.1.0
|
|
* Template version: 3.4.0
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
get_header('shop');
|
|
|
|
do_action('woocommerce_before_main_content');
|
|
|
|
if (is_product_category() || is_product_tag() || is_tax('product_brand')) {
|
|
$term = get_queried_object();
|
|
if ($term instanceof WP_Term) {
|
|
echo '<header class="xshop-page-header">';
|
|
echo '<h1 class="xshop-page-header__title">' . esc_html($term->name) . '</h1>';
|
|
if (!empty($term->description)) {
|
|
echo '<div class="xshop-page-header__desc">' . wp_kses_post(wpautop($term->description)) . '</div>';
|
|
}
|
|
echo '<p class="xshop-text-muted" style="font-size:var(--xshop-text-sm)">' . esc_html(sprintf(esc_html__('%s products', 'xshop'), number_format_i18n((int) $term->count))) . '</p>';
|
|
echo '</header>';
|
|
}
|
|
} elseif (is_shop()) {
|
|
$shopId = wc_get_page_id('shop');
|
|
$title = $shopId ? get_the_title($shopId) : esc_html__('Shop', 'xshop');
|
|
echo '<header class="xshop-page-header"><h1 class="xshop-page-header__title">' . esc_html($title) . '</h1></header>';
|
|
}
|
|
|
|
do_action('woocommerce_before_shop_loop');
|
|
|
|
if (woocommerce_product_loop()) {
|
|
woocommerce_product_loop_start();
|
|
if (wc_get_loop_prop('is_shortcode')) {
|
|
$columns = absint(wc_get_loop_prop('columns'));
|
|
} else {
|
|
$columns = absint(get_option('woocommerce_catalog_columns', 4));
|
|
}
|
|
|
|
while (have_posts()) {
|
|
the_post();
|
|
do_action('woocommerce_shop_loop');
|
|
wc_get_template_part('content', 'product');
|
|
}
|
|
|
|
woocommerce_product_loop_end();
|
|
do_action('woocommerce_after_shop_loop');
|
|
} else {
|
|
do_action('woocommerce_no_products_found');
|
|
// Enhanced empty state for shop/category
|
|
get_template_part('template-parts/components/empty-state', null, [
|
|
'title' => esc_html__('No products found', 'xshop'),
|
|
'text' => esc_html__('Try adjusting your filters or browse all products.', 'xshop'),
|
|
'cta_label' => esc_html__('Browse shop', 'xshop'),
|
|
'cta_url' => wc_get_page_permalink('shop'),
|
|
]);
|
|
}
|
|
|
|
do_action('woocommerce_after_main_content');
|
|
|
|
get_footer('shop');
|