Site icon Hip-Hop Website Design and Development

Detect Product List In Woocommerce [closed]

I am coding a tracking script for Woocommerce and I am making a data layer on the php side , I can detect product page example with if (is_product()) { , I have detected all the pages except product list

Example a code I have written for product page

if (is_product()) {
    $product = wc_get_product($post->ID);
    $currentPage = "Product Page";

    $productData = array('productID' => $product->get_id(), 'name' => $product->get_name(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(),
      'sale_price' => $product->get_sale_price(), 'categories' => $product->get_categories());

    return array_merge($productData, ['cartItems' => $cartItems], ['currentPage' => $currentPage]);
  }

Now i want to detect current product list that user is viewing and to retrive the products that are in that product list is that possible

Thanks