Production release
This commit is contained in:
102
functions.php
102
functions.php
@@ -311,7 +311,7 @@ function getAccessoiries($clientsecret, $categoryID){
|
||||
</form>
|
||||
<a href="'.$additional_product_url.'" id="'.$additional_product['rowID'].'A" class="product">
|
||||
<span class="add_name">'.$additional_product['productname'].'</span>
|
||||
<span class="add_price"> '.currency_code.'.'.number_format($additional_product['price'],2).'
|
||||
<span class="add_price"> '.currency_code.' '.number_format($additional_product['price'],2).'
|
||||
';
|
||||
if ($additional_product['rrp'] > 0){
|
||||
$output .='
|
||||
@@ -337,10 +337,13 @@ function getSamples($clientsecret, $categoryID){
|
||||
$additional_products = ioAPIv2('/v2/catalog/category='.$categoryID,'',$clientsecret);
|
||||
$additional_products = json_decode($additional_products,true);
|
||||
|
||||
// Generate unique ID for this samples carousel
|
||||
$samples_id = 'samples_' . $categoryID . '_' . time() . '_' . rand(1000, 9999);
|
||||
|
||||
$output ='<div class="content-wrapper">
|
||||
<h2 style="font-weight:normal;">'.($h2_cart_samples ?? 'Samples').'</h2>
|
||||
<div class="add_sample_button"><button id="slideLeft" class="scrollButton" type="button"><</button></div>
|
||||
<div id="add_samples_container" class="add_samples">
|
||||
<div class="add_sample_button"><button id="slideLeft_'.$samples_id.'" class="scrollButton" type="button" data-samples="'.$samples_id.'"><</button></div>
|
||||
<div id="add_samples_container_'.$samples_id.'" class="add_samples">
|
||||
|
||||
';
|
||||
|
||||
@@ -385,7 +388,7 @@ function getSamples($clientsecret, $categoryID){
|
||||
$output .='
|
||||
|
||||
</div>
|
||||
<div class="add_sample_button"><button id="slideRight" class="scrollButton" type="button">></button></div>
|
||||
<div class="add_sample_button"><button id="slideRight_'.$samples_id.'" class="scrollButton" type="button" data-samples="'.$samples_id.'">></button></div>
|
||||
</div>';
|
||||
|
||||
return $output;
|
||||
@@ -598,22 +601,40 @@ function getPictureID($pdo,$id,$config){
|
||||
//++++++++++++++++++++++++++++++++++++++++
|
||||
//HomePage Products
|
||||
//++++++++++++++++++++++++++++++++++++++++
|
||||
function highlightedProducts2($clientsecret,$categoryID,$range, $subtitle){
|
||||
function sortProducts(array $products, string $field, string $direction = 'asc'): array {
|
||||
if ($field === 'random') {
|
||||
shuffle($products);
|
||||
return $products;
|
||||
}
|
||||
usort($products, function($a, $b) use ($field, $direction) {
|
||||
$result = $a[$field] <=> $b[$field];
|
||||
return $direction === 'desc' ? -$result : $result;
|
||||
});
|
||||
return $products;
|
||||
}
|
||||
|
||||
function highlightedProducts($clientsecret,$categoryID,$range, $subtitle){
|
||||
|
||||
include './custom/translations/translations_'.strtoupper($_SESSION['country_code']).'.php';
|
||||
|
||||
//GET CATALOG DATA
|
||||
$products = ioAPIv2('/v2/catalog/category='.$categoryID,'',$clientsecret);
|
||||
$products = json_decode($products,true);
|
||||
|
||||
//RANDOM SORT
|
||||
$products = sortProducts($products, 'random');
|
||||
|
||||
// Generate unique ID for this carousel
|
||||
$carousel_id = 'carousel_' . $categoryID . '_' . time() . '_' . rand(1000, 9999);
|
||||
|
||||
$section = '
|
||||
<section class="watches-section">
|
||||
<div class="container">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">'.($range ?? 'Featured Timepieces').'</h2>
|
||||
<p class="section-subtitle">'.($subtitle ?? 'Explore our most popular and exquisite watch collections.').'</p>
|
||||
<h2 class="section-title">'.(!empty($range) ? $range : 'Featured Timepieces').'</h2>
|
||||
<p class="section-subtitle">'.(!empty($subtitle) ? $subtitle: 'Explore our most popular and exquisite watch collections.').'</p>
|
||||
</div>
|
||||
<div class="product-slider">
|
||||
<div class="product-slider" data-carousel="'.$carousel_id.'">
|
||||
<div class="product-container-slider">';
|
||||
|
||||
foreach ($products as $product){
|
||||
@@ -622,18 +643,19 @@ function highlightedProducts2($clientsecret,$categoryID,$range, $subtitle){
|
||||
|
||||
$section .= '
|
||||
<div class="product-card-slider">
|
||||
<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['rowID'])).'" id="'.$product['rowID'].'A" class="product">
|
||||
<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['rowID'])).(!empty($product['main_option_for_display']) ? '/'.$product['main_option_for_display']:'').'" id="'.$product['rowID'].'A" class="product">
|
||||
<img src="'.img_url.$product['full_path'].'" alt="'.(${$product['productname']} ?? $product['productname']).'" class="product-image-slider">
|
||||
<h3 class="product-name-slider">'.(${$product['productname']} ?? $product['productname']).'</h3>
|
||||
<p class="product-price-slider">'.(($product_price != 0.00) ? currency_code.number_format($product_price,2) : '').'</p>
|
||||
<p class="product-price-slider">'.(($product_price != 0.00) ? '<span class="price-from">'.$price_from.' </span>'.currency_code.number_format($product_price,2) : '').'</p>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$section .= '</div>
|
||||
<button class="slider-nav prev-btn"><i class="fas fa-chevron-left"></i></button>
|
||||
<button class="slider-nav next-btn"><i class="fas fa-chevron-right"></i></button>
|
||||
<button class="slider-nav prev-btn" data-carousel="'.$carousel_id.'"><i class="fas fa-chevron-left"></i></button>
|
||||
<button class="slider-nav next-btn" data-carousel="'.$carousel_id.'"><i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<div class="divider"></div>
|
||||
@@ -642,6 +664,62 @@ function highlightedProducts2($clientsecret,$categoryID,$range, $subtitle){
|
||||
return $section ;
|
||||
}
|
||||
|
||||
function highlightedProducts2($clientsecret,$categoryID,$range, $subtitle){
|
||||
|
||||
include './custom/translations/translations_'.strtoupper($_SESSION['country_code']).'.php';
|
||||
|
||||
//GET CATALOG DATA
|
||||
$products = ioAPIv2('/v2/catalog/category='.$categoryID,'',$clientsecret);
|
||||
$products = json_decode($products,true);
|
||||
|
||||
//RANDOM SORT
|
||||
$products = sortProducts($products, 'random');
|
||||
|
||||
// Generate unique ID for this carousel
|
||||
$carousel_id = 'carousel_' . $categoryID . '_' . time() . '_' . rand(1000, 9999);
|
||||
|
||||
$section = '
|
||||
<section class="watches-section">
|
||||
<div class="container">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">'.(!empty($range) ? $range : 'Featured Timepieces').'</h2>
|
||||
<p class="section-subtitle">'.(!empty($subtitle) ? $subtitle: 'Explore our most popular and exquisite watch collections.').'</p>
|
||||
</div>
|
||||
<div class="product-slider" data-carousel="'.$carousel_id.'">
|
||||
<div class="product-container-slider">';
|
||||
|
||||
foreach ($products as $product){
|
||||
|
||||
$product_price = isset($product['price']) && $product['price'] > 0 ? floatval($product['price']) : 0.00;
|
||||
|
||||
$section .= '
|
||||
<div class="product-card-slider">
|
||||
<a href="'.url('index.php?page=product&rowID=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['rowID'])).(!empty($product['main_option_for_display']) ? '/'.$product['main_option_for_display']:'').'" id="'.$product['rowID'].'A" class="product">
|
||||
<img src="'.img_url.$product['full_path'].'" alt="'.(${$product['productname']} ?? $product['productname']).'" class="product-image-slider">
|
||||
<h3 class="product-name-slider">'.(${$product['productname']} ?? $product['productname']).'</h3>
|
||||
<p class="product-price-slider">'.(($product_price != 0.00) ? '<span class="price-from">'.$price_from.' </span>'.currency_code.number_format($product_price,2) : '').'</p>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$section .= '</div>
|
||||
<button class="slider-nav prev-btn" data-carousel="'.$carousel_id.'"><i class="fas fa-chevron-left"></i></button>
|
||||
<button class="slider-nav next-btn" data-carousel="'.$carousel_id.'"><i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
<div class="section-footer">
|
||||
<a href="'.url(link_to_collection).'" class="hero-btn">
|
||||
'.($h2_brand_visit ?? 'View Collection').'
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<div class="divider"></div>
|
||||
';
|
||||
|
||||
return $section ;
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
//debuglog
|
||||
//---------------------------
|
||||
|
||||
Reference in New Issue
Block a user