From 890c98d4cd5c17665aee8d86e8160469c07e973f Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sun, 14 Jun 2026 19:47:08 +0000 Subject: [PATCH] Fix product images, add-to-cart, and add Sub Categories filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add display:block to .product-card-image so padding-top aspect ratio works on anchor tags - Add Cache-Control: no-transform header to disable Cloudflare Rocket Loader (was deferring main.js and breaking add-to-cart click handlers) - Add Sub Categories filter row on shop page using product_types table - Show category ยท sub-category on product cards - Add Sub Categories section to footer - Preserve subcat param across category/sort filter links Co-Authored-By: Claude Sonnet 4.6 --- assets/css/style.css | 1 + includes/footer.php | 11 +++++++ includes/header.php | 1 + shop.php | 76 +++++++++++++++++++++++++++++++++----------- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index c5ef5ff..6f971c9 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -338,6 +338,7 @@ img { } .product-card-image { + display: block; position: relative; padding-top: 100%; overflow: hidden; diff --git a/includes/footer.php b/includes/footer.php index 4014ce4..6cfe5a7 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -23,6 +23,17 @@
  • Blends
  • + +
    +

    Sub Categories

    + +

    Company

    diff --git a/includes/header.php b/includes/header.php index 247cde7..7c44065 100644 --- a/includes/header.php +++ b/includes/header.php @@ -6,6 +6,7 @@ if (session_status() === PHP_SESSION_NONE) { session_start(); } +header('Cache-Control: no-store, no-cache, must-revalidate, no-transform'); require_once __DIR__ . '/db.php'; require_once __DIR__ . '/../config/config.php'; diff --git a/shop.php b/shop.php index 326ab87..31fa763 100644 --- a/shop.php +++ b/shop.php @@ -8,6 +8,7 @@ require_once __DIR__ . '/includes/functions.php'; // Get filters $category = $_GET['category'] ?? ''; +$subcat = $_GET['subcat'] ?? ''; $search = $_GET['search'] ?? ''; $sort = $_GET['sort'] ?? 'newest'; $page = max(1, intval($_GET['page'] ?? 1)); @@ -21,6 +22,11 @@ if ($category) { $params['category'] = $category; } +if ($subcat) { + $where[] = 'product_type_id = :subcat'; + $params['subcat'] = $subcat; +} + if ($search) { $where[] = '(name LIKE :search OR description LIKE :search)'; $params['search'] = '%' . $search . '%'; @@ -42,7 +48,7 @@ $pagination = paginate($totalProducts, $page, 12); // Get products $products = db()->fetchAll( - "SELECT * FROM products WHERE {$whereClause} ORDER BY {$orderBy} LIMIT :limit OFFSET :offset", + "SELECT p.*, pt.name AS type_name, pt.type_id AS type_slug FROM products p LEFT JOIN product_types pt ON p.product_type_id = pt.type_id WHERE {$whereClause} ORDER BY {$orderBy} LIMIT :limit OFFSET :offset", array_merge($params, ['limit' => $pagination['per_page'], 'offset' => $pagination['offset']]) ); @@ -71,15 +77,29 @@ $productTypesList = db()->fetchAll("SELECT type_id, name, slug FROM product_type
    -
    -
    - All - - - - - +
    +
    +
    + All + + + + + +
    + +
    + Sub Categories: + All + + + + + +
    +
    @@ -87,24 +107,39 @@ $productTypesList = db()->fetchAll("SELECT type_id, name, slug FROM product_type - + + + - + $category, 'subcat' => $subcat])); + $filterQs = $filterQs ? '&' . $filterQs : ''; + ?>
    +

    Showing of products +

    @@ -132,8 +167,13 @@ $productTypesList = db()->fetchAll("SELECT type_id, name, slug FROM product_type
    - -
    + +
    + + + + +