feat: implement WooCommerce storefront foundation

This commit is contained in:
XShop
2026-09-13 19:51:31 +03:30
parent f11e1d650d
commit 00439fcea9
18 changed files with 871 additions and 65 deletions
@@ -0,0 +1,32 @@
<?php
/**
* Product Grid — wraps product cards in CSS grid.
*
* Args: ['products' => WC_Product[]|int[], 'columns'=>int, 'empty_text'=>string]
*
* @package XShop
*/
declare(strict_types=1);
defined('ABSPATH') || exit;
$products = $args['products'] ?? [];
$columns = isset($args['columns']) ? max(1, min(6, (int) $args['columns'])) : 4;
if (empty($products)) {
$text = $args['empty_text'] ?? esc_html__('No products found.', 'xshop');
get_template_part('template-parts/components/empty-state', null, ['title' => esc_html__('No products', 'xshop'), 'text' => $text]);
return;
}
?>
<ul class="xshop-products" data-columns="<?php echo esc_attr((string) $columns); ?>">
<?php foreach ($products as $p):
$product = is_int($p) ? wc_get_product($p) : $p;
if (!$product instanceof WC_Product) { continue; }
?>
<li class="xshop-products__item">
<?php get_template_part('template-parts/components/product-card', null, ['product' => $product, 'show_hooks' => $args['show_hooks'] ?? false]); ?>
</li>
<?php endforeach; ?>
</ul>