2nd update

This commit is contained in:
“VeLiTi”
2025-05-26 15:07:22 +02:00
parent cd0e04981c
commit 580f835fff
46 changed files with 16006 additions and 952 deletions

View File

@@ -15,7 +15,7 @@ $categories = json_decode($categories,true);
//IF CATEGORY IS RECEIVED ONLY GET RELATED PRODUCTS
$url_input = '';
if(isset($_GET['category'])){
if(isset($_GET['category']) && !isset($_POST['category'])){
$url_input = 'category='.$_GET['category'];
}
@@ -38,221 +38,199 @@ if (isset($_POST['category'])){
//GET CATALOG DATA
$products = ioAPIv2('/v2/catalog/'.$url_input,'',$clientsecret);
$products = json_decode($products,true);
//Return QueryTotal from API
$total_products = ioAPIv2('/v2/products/'.$GET_VALUES.'&totals=&salesflag=1&status=1','',$clientsecret);
$total_products = json_decode($total_products,true);
$total_products = count($products);
//INCLUDE THE HEADER
template_header_top($products_text);
$view = template_header($products_text,'');
$view = '
<div class="featured" style="background-image:url('.base_url.featured_store_image.');background-position: center center;">';
//Include the menu
template_menu();
$view .=' <h2>'.$h1_content_top.'</h2>
<h2></h2>
<p></p>
</div>';
//SHOW OFFER
if(show_offer_product_page){
$view .= '
<div class="" style="text-align: center;">
<p class="p.paragraph.neutral-paragraph-text-1" style="font-family:\'gerb\';font-size: 15px;">'.(${show_offer_product_text} ?? show_offer_product_text).'</p>
<!-- Hero Section -->
<section class="hero" style="background-image:url('.base_url.featured_store_image.');">
<div class="hero-content">
<h1>'.$h1_content_top.'</h1>
</div>
';
}
</section>';
$view .= '
<div class="filtersection">
<!-- Filter Section -->
<div class="filter-section">
<form action="" method="post">
<h2>'.($products_filters_h2 ?? 'Filter Products').'</h2>';
<div class="container" style="padding: 20px;">
<button class="filter-button" id="filterToggle">'.($products_filters_h2 ?? 'Show filters').'</button>
<div class="filters-products-container">
<div class="filters" id="filters">
<form action="" method="post">';
if (count($categories) > 0){
//BUILD UP FILTERS BASED ON CATEGORY ASSIGNMENTS
foreach ($categories as $filters){
if ($filters['parent_id'] == '0' && $filters['status'] == 1 && $filters['filter'] == 1){
$view .= '<div class="filter-group">
<label>'.(${$filters['name']} ?? $filters['name']).'</label> ';
$view .= '<div class="filter-section">
<h3>'.(${$filters['name']} ?? $filters['name']).'</h3>
<div class="filter-options"> ';
//Iterate through categories for subfilters
foreach ($categories as $subfilter){
if ($filters['rowID'] == $subfilter['parent_id'] && $subfilter['status'] == 1 && $subfilter['filter'] == 1){
$view .= '<div>
<input type="checkbox" id="'.$subfilter['name'].'" name="category['.$subfilter['rowID'].']">
<label for="'.$subfilter['name'].'">'.(${$subfilter['name']} ?? $subfilter['name']).'</label>
</div>';
$view .= '
<div class="filter-option">
<input type="checkbox" id="'.$subfilter['name'].'" name="category['.$subfilter['rowID'].']">
<label for="'.$subfilter['name'].'">'.(${$subfilter['name']} ?? $subfilter['name']).'</label>
</div>';
}
}
$view .= '</div>';
$view .= '</div>
</div>';
}
}
$view .= '<input type="submit" value="'.($btn_filter ?? 'Filter').'" class="btn" >';
$view .= '
<div class="filter-option">
<input type="submit" value="'.($btn_filter ?? 'Filter').'" class="btn" >
</div>';
}
$view .= '</form>
</div>
<div class="products">
<div class="product-grid">';
<div class="products content-wrapper"> ';
foreach ($products as $product){
//ADD CATEGORIES
$view .= ' <div style="margin-top: 30px;display: flex;align-items: center;align-content: center;flex-wrap: nowrap;flex-direction: column;">
<div class="product_category_nav">
';
foreach ($categories as $categorie){
if ($categorie['parent_id'] == '0' && $categorie['status'] == 1 && $categorie['filter'] != 1){
$weburl = url('index.php?page=products&category='.$categorie['rowID'].'');
$view .= '<a href="'.$weburl.'">'.(${$categorie['name']} ?? $categorie['name']).'</a>';
}
}
$view .= '
</div>';
if (isset($_GET['category'])){
$view .= '<div class="product_category_nav">';
foreach ($categories as $categorie){
if ($categorie['parent_id'] == $_GET['category'] && $categorie['status'] == 1 && $categorie['filter'] != 1){
$weburl = url('index.php?page=productsnew&category='.$categorie['rowID'].'');
$view .= '<a href="'.$weburl.'" style="color: #fff;background-color: #555555;font-size: 10px;">'.(${$categorie['name']} ?? $categorie['name']).'</a>';
}
}
$view .= '</div>';
}
// Ensure product price is a numeric value
$product_price = isset($product['price']) && $product['price'] > 0 ? floatval($product['price']) : 0.00;
$view .= '
</div>';
$view .= '<div class="products-wrapper">';
foreach ($products as $product){
// Ensure product price is a numeric value
$product_price = isset($product['price']) && $product['price'] > 0 ? floatval($product['price']) : 0.00;
//SHOW LARGE PICTURE
$view .= '
<div class="product">
<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['rowID'])).'" id="'.$product['rowID'].'A" class="product">
<img src="'.img_url.$product['full_path'].'" id="'.$product['rowID'].'" width="" height="250" alt="'.(${$product['productname']} ?? $product['productname']).'">
</a>';
//CHECK IF CONFIGURATION SETTING IS FOUND AND NOT EMPTY => USE GROUP TO DISPLAY IMAGES
if (isset($product['configurations']) && isset($product['config_setting']) && $product['config_setting'] != ''){
//GET THE CONFIG_SETTING GROuP AND DISPLAY
foreach ($product['configurations'] as $config){
//MATCH ASSIGNMENT WITH CONFIG SETTING
if($config['assignment'] == $product['config_setting']){
$view .= '<div class="" style="display:flex;justify-content: center">';
//GET ALL RELATED ATTRIBUTES
foreach ($config['attributes'] as $attribute){
$option_id = $attribute['attribute_id']; // ID of the LARGE IMAGE
$IMG_small_id = img_url.$attribute['full_path']; //URL TO SMALL IMAGE
$IMG_large_id = img_url.$attribute['alternative_media_full_path']; //URL TO LARGE IMAGE
//SHOW LARGE PICTURE
$view .= '
<div class="product-card">
<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['rowID'])).'" id="'.$product['rowID'].'A" class="product">
<img src="'.img_url.$product['full_path'].'" id="'.$product['rowID'].'" width="" height="250" alt="'.(${$product['productname']} ?? $product['productname']).'">
</a>';
//CHECK IF CONFIGURATION SETTING IS FOUND AND NOT EMPTY => USE GROUP TO DISPLAY IMAGES
if (isset($product['configurations']) && isset($product['config_setting']) && $product['config_setting'] != ''){
// Ensure attribute price is a numeric value
$attribute_price = isset($attribute['price']) ? floatval($attribute['price']) : 0.00;
//GET THE CONFIG_SETTING GROuP AND DISPLAY
foreach ($product['configurations'] as $config){
//MATCH ASSIGNMENT WITH CONFIG SETTING
if($config['assignment'] == $product['config_setting']){
$view .= '<div class="" style="display:flex;justify-content: center">';
//GET ALL RELATED ATTRIBUTES
foreach ($config['attributes'] as $attribute){
$option_id = $attribute['attribute_id']; // ID of the LARGE IMAGE
$IMG_small_id = img_url.$attribute['full_path']; //URL TO SMALL IMAGE
$IMG_large_id = img_url.$attribute['alternative_media_full_path']; //URL TO LARGE IMAGE
// Ensure attribute price is a numeric value
$attribute_price = isset($attribute['price']) ? floatval($attribute['price']) : 0.00;
$option_price = isset($attribute['price'])
// If price modifier is 1, add prices; otherwise, subtract
? ((isset($attribute['price_modifier']) && $attribute['price_modifier'] == 1) ? currency_code . number_format(floatval($product_price + $attribute_price), 2) : currency_code . number_format(floatval($product_price - $attribute_price), 2))
// If product price is not zero, format it
: (($product_price != 0.00) ? currency_code . number_format(floatval($product_price), 2) : '');
$view .= '
<div>
<img class="img_config" src="'.$IMG_small_id.'" id="'.$attribute['item_media'].'" onclick="update(\''.$product['rowID'].'\',\''.$IMG_large_id.'\',\''.url('index.php?page=product&rowID=' . ($product['url_slug'] ? $product['url_slug'].'/'.$option_id : $product['rowID'].'/'.$option_id )).'\',\''.$option_price.'\')" />
</div>';
}
$view .= '</div>';
$option_price = isset($attribute['price'])
// If price modifier is 1, add prices; otherwise, subtract
? ((isset($attribute['price_modifier']) && $attribute['price_modifier'] == 1) ? currency_code . number_format(floatval($product_price + $attribute_price), 2) : currency_code . number_format(floatval($product_price - $attribute_price), 2))
// If product price is not zero, format it
: (($product_price != 0.00) ? currency_code . number_format(floatval($product_price), 2) : '');
$view .= '
<div>
<img class="img_config" src="'.$IMG_small_id.'" id="'.$attribute['item_media'].'" onclick="update(\''.$product['rowID'].'\',\''.$IMG_large_id.'\',\''.url('index.php?page=product&rowID=' . ($product['url_slug'] ? $product['url_slug'].'/'.$option_id : $product['rowID'].'/'.$option_id )).'\',\''.$option_price.'\')" />
</div>';
}
$view .= '</div>';
}
} else {
//SHOW SMALL IMAGE
$view .= '<div class="" style="display:flex;justify-content: center">
<div>
<img class="img_config" src="'.img_url.$product['full_path'].'"/>
</div>
</div>';
}
//Stock status
$stock_status = (isset($product['quantity']) && $product['quantity'] != 0) ? $product_on_stock : $out_of_stock;
$style = ($stock_status == $product_on_stock) ? 'style="color: green;"' : 'style="background-color:gray;font-weight: lighter;"';
$view .= '
<span class="stock">
<p '.$style.'> '.$stock_status.'</p>
</span>';
if (free_shipment_indicator){
$shipment = freeShipment($product_price,'span');
$view .= $shipment;
}
} else {
//SHOW SMALL IMAGE
$view .= '<div class="" style="display:flex;justify-content: center">
<div>
<img class="img_config" src="'.img_url.$product['full_path'].'"/>
</div>
</div>';
}
//Stock status
$stock_status = (isset($product['quantity']) && $product['quantity'] != 0) ? $product_on_stock : $out_of_stock;
$style = ($stock_status == $product_on_stock) ? 'style="background-color: green;"' : 'style="background-color:gray;font-weight: lighter;"';
$view .= '
<span class="stock">
<p '.$style.'> '.$stock_status.'</p>
</span>';
if (free_shipment_indicator){
$shipment = freeShipment($product_price,'span');
$view .= $shipment;
$option_id ='';
$view .='<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? $product['url_slug'].$option_id : $product['rowID'])).'" id="'.$product['rowID'].'B" class="product">
<span class="products_name">'.(${$product['productname']} ?? $product['productname']).'</span>';
if (isset($product_price)){
$view .= '<span class="products_price" id="'.$product['rowID'].'C">'.(($product_price != 0.00) ? currency_code.number_format($product_price,2) : '').'';
if (isset($product['rrp']) && $product['rrp'] > 0){
$view .= '<span class="products_rrp">'.currency_code.number_format($product['rrp'],2).'</span>';
}
$view .= '</span>';
}
$view .= '
</a>
</div>';
}
$option_id ='';
$view .='<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? $product['url_slug'].$option_id : $product['rowID'])).'" id="'.$product['rowID'].'B" class="product">
<span class="name">'.(${$product['productname']} ?? $product['productname']).'</span>';
if (isset($product_price)){
$view .= '<span class="price" id="'.$product['rowID'].'C">'.(($product_price != 0.00) ? currency_code.number_format($product_price,2) : '').'';
if (isset($product['rrp']) && $product['rrp'] > 0){
$view .= '<span class="rrp">'.currency_code.number_format($product['rrp'],2).'</span>';
}
$view .= '</span>';
}
$view .= '
</a>
</div>';
}
$view .= '
</div>';
$view .= '
$view .= '
</div>
<div class="buttons">';
if ($current_page > 1) {
$view .= '<a href="'.url('index.php?page=products&p=' . ($current_page-1) . '&category=' . $category . '&sort=' . $sort).'" class="btn">Prev</a>';
$view .= '<a href="'.url('index.php?page=products&p=' . ($current_page-1) . $url_input . '&sort=' . $sort).'" class="btn">Prev</a>';
}
if ($total_products > ($current_page * $num_products_on_each_page) - $num_products_on_each_page + count($products)){
$view .= '<a href="'.url('index.php?page=products&p=' . ($current_page+1) . '&category=' . $category . '&sort=' . $sort).'" class="btn">Next</a>';
if ($total_products > ($current_page * $num_products_on_each_page)){
$view .= '<a href="'.url('index.php?page=products&p=' . ($current_page+1) . $url_input . '&sort=' . $sort).'" class="btn">Next</a>';
}
$view .= '</div>
</div>
</div>';
$view .= '</div>';
$view .= '<script>
function update(id_large, IMG_large, option_id, price){
let url_id_a = id_large + \'A\';
let url_id_b = id_large + \'B\';
let url_id_c = id_large + \'C\';
//change picture
document.getElementById(id_large).src = IMG_large;
document.getElementById(url_id_a).href = option_id;
document.getElementById(url_id_b).href = option_id;
document.getElementById(url_id_c).innerHTML = price;
document.getElementById(url_id_c).style = price;
}
</script>';
$view .= '
</div>
</div>
</div>
</div>';
$view .= template_footer();
$view .= '
<script>
function update(id_large, IMG_large, option_id, price){
let url_id_a = id_large + \'A\';
let url_id_b = id_large + \'B\';
let url_id_c = id_large + \'C\';
//change picture
document.getElementById(id_large).src = IMG_large;
document.getElementById(url_id_a).href = option_id;
document.getElementById(url_id_b).href = option_id;
document.getElementById(url_id_c).innerHTML = price;
document.getElementById(url_id_c).style = price;
}
</script>
<script>
// Simple filter toggle for mobile
const filterToggle = document.getElementById(\'filterToggle\');
const filters = document.getElementById(\'filters\');
filterToggle.addEventListener(\'click\', () => {
filters.classList.toggle(\'show\');
filterToggle.textContent = filters.classList.contains(\'show\') ? \'Hide Filters\' : \'Show Filters\';
});
</script>
';
//OUTPUT
echo $view;
template_footer()
?>