Vendor Search
This commit is contained in:
parent
0f55521b19
commit
ab808d5228
|
@ -136,7 +136,41 @@ function searchProducts($query)
|
|||
$query = 'asus';
|
||||
$result = searchProducts($query);
|
||||
|
||||
function searchVendor($query)
|
||||
{
|
||||
$query = str_replace(" ", "+", $query);
|
||||
$url = "https://".$_SESSION["data_endpoint"]."/api/v1/vendors/search?q=$query";
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'X-Api-Key: {{apiKey}}'
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$data = json_decode($response, true);
|
||||
|
||||
// Check if there are no results
|
||||
if (empty($data['results'])) {
|
||||
// $data['message'] = 'No products available for the given query.';
|
||||
$data['results'] = [];
|
||||
}
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
|
||||
// Example usage:
|
||||
$query = 'asus';
|
||||
$result = searchProducts($query);
|
||||
|
||||
// function searchProducts($query)
|
||||
// {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This is more vendors page
|
|
@ -16,10 +16,15 @@
|
|||
$result = searchProducts( $category);
|
||||
} else {
|
||||
$result = searchProducts($_GET["searchText"]);
|
||||
$result2 = searchVendor($_GET["searchText"]);
|
||||
}
|
||||
|
||||
$array = json_decode($result,true);
|
||||
$array2 = json_decode($result2,true);
|
||||
|
||||
$_SESSION["productSearchResult"] = $array;
|
||||
$_SESSION["vendorSearchResult"] = $array2;
|
||||
|
||||
header("location: shop-list-left-sidebar.php");
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ if ($_SESSION["userId"] <> "") {
|
|||
$_SESSION["isLoggedIn"] = false;
|
||||
}
|
||||
$productSearchResult = $_SESSION["productSearchResult"];
|
||||
$vendorSearchResult = $_SESSION["vendorSearchResult"];
|
||||
|
||||
|
||||
|
||||
// 02-19-2024 Jun Jihad Search Filter
|
||||
$filteredProducts = [];
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
@ -257,7 +261,45 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
|
|||
</div>
|
||||
</div>
|
||||
<!-- Shop Top End -->
|
||||
<!-- 02-22-2024 Jun Jihad Vendor Search -->
|
||||
<?php if (!empty($vendorSearchResult['results'])) : ?>
|
||||
<div class="shop-pro-content" style="margin-bottom:40px;">
|
||||
<div class="ec-product-inner">
|
||||
<h5 class="ec-pro-title">Vendor Search Results</h5>
|
||||
<div class="row mt-4">
|
||||
<?php
|
||||
// Loop through each vendor in $vendorSearchResult
|
||||
$count = 0; // Initialize a counter
|
||||
foreach ($vendorSearchResult['results'] as $vendor) {
|
||||
if ($count < 2) { // Limit to two cards
|
||||
?>
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="ec-pro-title"><?php echo $vendor['user_login']; ?></h6>
|
||||
<!-- You can access other fields here -->
|
||||
<!-- Add more fields as needed -->
|
||||
<a href="#" class="btn btn-primary">View Details</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
$count++; // Increment the counter
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php if (count($vendorSearchResult['results']) > 2) : ?>
|
||||
<div class="text-center">
|
||||
<a href="more-vendors.php" class="btn btn-primary">More Products</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<!-- 02-22-2024 Jun Jihad Vendor Search -->
|
||||
<!-- Shop content Start -->
|
||||
<div class="shop-pro-content">
|
||||
<div class="shop-pro-inner list-view">
|
||||
|
|
Loading…
Reference in New Issue