CMXX - Updated Products page

This commit is contained in:
“VeLiTi”
2025-02-04 12:59:28 +01:00
parent 68a16e5419
commit fa09268cd8
9 changed files with 375 additions and 237 deletions

1
.gitignore vendored
View File

@@ -0,0 +1 @@
productold.php

View File

@@ -10,7 +10,7 @@ $base_url .= '/' . ltrim(substr(str_replace('\\', '/', realpath(__DIR__)), strle
define('base_url', rtrim($base_url, '/') . '/');
session_start();
// Include the configuration file, this contains settings you can change.
include '../config.php';
include '../custom/settings/config.php';
// Include functions and connect to the database using PDO MySQL
include '../functions.php';
// Connect to MySQL database

View File

@@ -1,7 +1,7 @@
<?php
defined('admin') or exit;
// Configuration file
$file = '../config.php';
$file = '../custom/settings/config.php';
// Open the configuration file for reading
$contents = file_get_contents($file);
// Format key function

View File

@@ -1827,3 +1827,47 @@ input.banner_deny:hover {
#banner hr {
margin: 15px 0;
}
/* Main Container */
.filtersection {
display: flex;
margin: 0 auto;
}
/* Filter Section */
.filter-section {
width: 250px;
padding: 20px;
border-right: 1px solid #e0e0e0;
}
.filter-section h2 {
margin-bottom: 15px;
color: #333;
}
.filter-group {
margin-bottom: 20px;
}
.filter-group label {
margin-bottom: 10px;
}
.filter-group input[type="checkbox"] {
margin-right: 10px;
}
/* Responsive Design */
@media (max-width: 768px) {
.filtersection {
flex-direction: column;
text-align: center;
}
.filter-section {
width: 100%;
border-right: none;
border-bottom: 1px solid #e0e0e0;
}
}

View File

@@ -110,7 +110,7 @@ if (veliti_analytics){
// Template Header (related to MENU function)
function template_header_top($title, $head = '') {
include './custom/translations/'.strtoupper(language_code).'.php';
include './custom/translations/translations_'.strtoupper(language_code).'.php';
// Get the amount of items in the shopping cart, this will be displayed in the header.
$num_items_in_cart = isset($_SESSION['cart']) ? array_sum(array_column($_SESSION['cart'], 'quantity')) : 0;
$home_link = url('index.php');

View File

@@ -156,6 +156,9 @@ define('db_user','morvalwatches');//morvalwatches_prod
define('db_pass','4~gv71bM6');
// Database name
define('db_name','shoppingcart_advanced'); //morvalwatches
// API BASE URL
define('api_url','https://dev.veliti.nl/api.php'); //morvalwatches
/* Payment options */
//Pay on Delivery
@@ -176,7 +179,7 @@ define('PAYPAL_CLIENT_SECRET','');
/* Admin modes */
//debug
define('debug',false);
define('debug',true);
// Default maintenance_mode
define('maintenanceMode',false);
?>

View File

@@ -556,10 +556,12 @@ function freeShipment($price, $type){
$delivery_status = ($price >= free_shipment_price) ? $free_delivery : $non_free_delivery.currency_code.free_shipment_price.',-';
$style = ($delivery_status == $free_delivery) ? 'style="color:green;font-weight: bold;"' : 'style="color:gray;font-weight: lighter;"';
echo '
$shipment = '
<'.$type.' class="delivery">
<p '.$style.'> '.$delivery_status.'</p>
</'.$type.'>';
return $shipment;
}
function consent()
@@ -781,4 +783,72 @@ function debuglog($error){
$filelocation = './log/log_'.date('m').'.txt';
error_log($test, 3, $filelocation);
}
//------------------------------------------
// Retrieve all $_GET from URL
//------------------------------------------
function urlGETdetails($input){
//GET Details from URL
if(isset($input) && !empty($input)){
$GET_VALUES = '';
foreach ($input as $KEY => $VALUE){
$GET_VALUES .= $KEY.'='.$VALUE;
$GET_VALUES .= '&';
}
return $GET_VALUES = rtrim($GET_VALUES, "&");
}
else {
return $GET_VALUES = '';
}
}
//------------------------------------------
// API TO API version 2
//------------------------------------------
function ioAPIv2($api_call, $data, $token){
$url = api_url.$api_call;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//SEND BEARER CODE WHEN TOKEN PROVIDED
if ($token != ''){
$headers = array(
"Authorization: Bearer $token",
"Content-Type: application/json",
);
} else {
$headers = array(
"Content-Type: application/json",
);
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//IF DATA PROVIDED CONSIDER POST
if (!empty($data)){
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
$resp = curl_exec($curl);
$http_status = curl_getinfo($curl) ?? '200';
curl_close($curl);
//Check If errorcode is returned
if($http_status['http_code'] == '403' || $http_status['http_code'] == '400') {$resp = json_encode('NOK');}
if (debug){
$message = date('Y-m-d H:i:s').';'.$api_call;
debuglog($message);
}
//Response
return $resp;
}
?>

View File

@@ -42,8 +42,8 @@ if (isset($_POST['banner_move'])){
// Define all the routes for all pages
$url = routes([
'/' => 'home.php',
'/about' => '/custom/pages/about.php',
'/about_morval' => '/custom/pages/about_morval.php',
'/about' => 'custom/pages/about.php',
'/about_morval' => 'custom/pages/about_morval.php',
'/product/{id}' => 'product.php',
'/product/{id}/{option_id}' => 'product.php',
'/products' => 'products.php',
@@ -60,14 +60,14 @@ $url = routes([
'/placeorder/{order_id}' => 'placeorder.php',
'/search/{query}' => 'search.php',
'/logout' => 'logout.php',
'/termsandconditions'=> '/custom/pages/termsandconditions.php',
'/termsandconditions/{download}'=> '/custom/pages/termsandconditions.php',
'/faq'=> '/custom/pages/faq.php',
'/privacy'=> '/custom/pages/privacy.php',
'/privacy/{download}'=> '/custom/pages/privacy.php',
'/instructions-for-use' => '/custom/pages/faq.php',
'/test' => 'test.php'
'/termsandconditions'=> 'custom/pages/termsandconditions.php',
'/termsandconditions/{download}'=> 'custom/pages/termsandconditions.php',
'/faq'=> 'custom/pages/faq.php',
'/privacy'=> 'custom/pages/privacy.php',
'/privacy/{download}'=> 'custom/pages/privacy.php',
'/instructions-for-use' => 'custom/pages/faq.php'
]);
// Check if route exists
if ($url) {
include $url;

View File

@@ -1,254 +1,274 @@
<?php
// Prevent direct access to file
defined(security_key) or exit;
// Get all the categories from the database
$stmt = $pdo->query('SELECT * FROM categories');
$stmt->execute();
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get the current category from the GET request, if none exists set the default selected category to: all
$category = isset($_GET['category']) ? $_GET['category'] : $main_category;
$category_sql = '';
if ($category != $main_category) {
$category_sql = 'JOIN products_categories pc ON pc.category_id = :category_id AND pc.product_id = p.id JOIN categories c ON c.id = pc.category_id';
}
// Get the sort from GET request, will occur if the user changes an item in the select box
$default_product_sort = default_product_sort;
$sort = isset($_GET['sort']) ? $_GET['sort'] : $default_product_sort;
// The amounts of products to show on each page
$num_products_on_each_page = 25;
// The current page, in the URL this will appear as index.php?page=products&p=1, index.php?page=products&p=2, etc...
//=====================================
// MOVE TO INDEX
//=====================================
//LOGIN TO API
$data = json_encode(array("username" => "paul@veliti.nl", "password" => "test1234"), JSON_UNESCAPED_UNICODE);
$responses = ioAPIv2('/v2/authorization', $data,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
$clientsecret = $responses['token'];
$img_url = substr(api_url, 0, -8);
//=====================================
//end move to index
//=====================================
//Pagination
$current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? (int)$_GET['p'] : 1;
// Select products ordered by the date added
if ($sort == 'sort1') {
// sort1 = Alphabetical A-Z
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.name ASC LIMIT :page,:num_products');
} elseif ($sort == 'sort2') {
// sort2 = Alphabetical Z-A
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.name DESC LIMIT :page,:num_products');
} elseif ($sort == 'sort3') {
// sort3 = Newest
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.date_added DESC LIMIT :page,:num_products');
} elseif ($sort == 'sort4') {
// sort4 = Oldest
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.date_added ASC LIMIT :page,:num_products');
} elseif ($sort == 'sort5') {
// sort5 = Highest Price
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.price DESC LIMIT :page,:num_products');
} elseif ($sort == 'sort6') {
// sort6 = Lowest Price
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 ORDER BY p.price ASC LIMIT :page,:num_products');
$num_products_on_each_page = 25;
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//Get all the categories from the database
$categories = ioAPIv2('/v2/categories/','',$clientsecret);
$categories = json_decode($categories,true);
//IF CATEGORY IS RECEIVED ONLY GET RELATED PRODUCTS
$url_input = '';
if(isset($_GET['category'])){
$url_input = 'category='.$_GET['category'];
}
if (isset($_POST['category'])){
$filter_input = '';
foreach (array_keys($_POST['category']) as $cat_filter){
$filter_input .= $cat_filter.',';
}
if ($url_input != ''){
$url_input = $url_input.','.substr($filter_input,0, -1);
} else {
// No sort was specified, get the products with no sorting
$stmt = $pdo->prepare('SELECT p.*, (SELECT m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id WHERE pm.product_id = p.id ORDER BY pm.position ASC LIMIT 1) AS img FROM products p ' . $category_sql . ' WHERE p.status = 1 LIMIT :page,:num_products');
$url_input = 'category='.substr($filter_input,0, -1);
}
// bindValue will allow us to use integer in the SQL statement, we need to use for LIMIT
if ($category != $main_category) {
$stmt->bindValue(':category_id', $category, PDO::PARAM_INT);
}
$stmt->bindValue(':page', ($current_page - 1) * $num_products_on_each_page, PDO::PARAM_INT);
$stmt->bindValue(':num_products', $num_products_on_each_page, PDO::PARAM_INT);
$stmt->execute();
// Fetch the products from the database and return the result as an Array
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get the total number of products
$stmt = $pdo->prepare('SELECT COUNT(*) FROM products p ' . $category_sql . ' WHERE p.status = 1');
if ($category != $main_category) {
$stmt->bindValue(':category_id', $category, PDO::PARAM_INT);
}
$stmt->execute();
$total_products = $stmt->fetchColumn();
//GET CATALOG DATA
$products = ioAPIv2('/v2/catalog/'.$url_input,'',$clientsecret);
$products = json_decode($products,true);
//get all media
$stmt = $pdo->query('SELECT id, full_path FROM media');
$stmt->execute();
$media = $stmt->fetchAll(PDO::FETCH_ASSOC);
//Return QueryTotal from API
$total_products = ioAPIv2('/v2/products/'.$GET_VALUES.'&totals=&salesflag=1&status=1','',$clientsecret);
$total_products = json_decode($total_products,true);
?>
<?=template_header_top($products_text)?>
//INCLUDE THE HEADER
template_header_top($products_text);
<div class="featured" style="background-image:url(<?= base_url.featured_store_image?>);background-position: center center;">
<?=template_menu()?>
<h2><?=$h1_content_top?></h2>
$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>';
</div>
<?php
//SHOW OFFER
if(show_offer_product_page){
echo '
$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.'</p>
</div>
';
}
?>
<div class="products content-wrapper">
<?php
echo '
<div style="margin-top: 30px;display: flex;align-items: center;align-content: center;flex-wrap: nowrap;flex-direction: column;">
$view .= '
<div class="filtersection">
<!-- Filter Section -->
<div class="filter-section">
<form action="" method="post">
<h2>'.($products_filters_h2 ?? 'Filter Products').'</h2>';
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> ';
//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>';
}
}
$view .= '<input type="submit" value="'.($btn_filter ?? 'Filter').'" class="btn" >';
}
$view .= '</form>
</div>
<div class="products content-wrapper"> ';
//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){
$weburl = url("index.php?page=products&category=".$categorie['id']."&sort=".$sort."");
echo '<a href="'.$weburl.'">'.$categorie['name'].'</a>';
if ($categorie['parent_id'] == '0' && $categorie['status'] == 1 && $categorie['filter'] != 1){
$weburl = url('index.php?page=test&category='.$categorie['rowID'].'');
$view .= '<a href="'.$weburl.'">'.$categorie['name'].'</a>';
}
}
echo '
$view .= '
</div>';
if (isset($_GET['category'])){
echo' <div class="product_category_nav">';
$view .= '<div class="product_category_nav">';
foreach ($categories as $categorie){
if ($categorie['parent_id'] == $_GET['category'] && $categorie['status'] == 1){
$weburl = url("index.php?page=products&category=".$categorie['id']."&sort=".$sort."");
echo '<a href="'.$weburl.'" style="color: #fff;background-color: #555555;font-size: 10px;">'.$categorie['name'].'</a>';
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'].'</a>';
}
}
echo '</div>';
$view .= '</div>';
}
echo'
$view .= '
</div>';
?>
<div class="products-header">
<?=$total_products?> <?=$product_count_1?><?=$total_products!=1? $product_count_2:''?></p>
<form action="" method="get" class="products-form">
<input type="hidden" name="page" value="products">
<label class="category">
<?=$main_filter_category?>
<select name="category">
<option value="<?=$main_category?>"<?=($category == $main_category ? ' selected' : '')?>><?=$main_category?></option>
<?=populate_categories($categories, $category)?>
</select>
</label>
<label class="sortby">
<?=$main_filter_sort?>
<select name="sort">
<option value="sort1"<?=($sort == 'sort1' ? ' selected' : '')?>><?=$sort1?></option>
<option value="sort2"<?=($sort == 'sort2' ? ' selected' : '')?>><?=$sort2?></option>
<option value="sort3"<?=($sort == 'sort3' ? ' selected' : '')?>><?=$sort3?></option>
<option value="sort4"<?=($sort == 'sort4' ? ' selected' : '')?>><?=$sort4?></option>
<option value="sort5"<?=($sort == 'sort5' ? ' selected' : '')?>><?=$sort5?></option>
<option value="sort6"<?=($sort == 'sort6' ? ' selected' : '')?>><?=$sort6?></option>
</select>
</label>
</form>
</div>
<div class="products-wrapper">
<?php
foreach ($products as $product): ?>
$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">
<?php
if (empty($product['product_config'])){
echo '<a href="'.url('index.php?page=product&id=' . ($product['url_slug'] ? ($product['url_slug'] ) : $product['id'])).'" id="'.$product['id'].'A" class="product">';
}
else{//ADD related optionID when configuration is found
$option_id = getPictureID($pdo,$product['id'],$product['product_config']);
<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="200" height="" alt="'.$product['productname'].'">
</a>';
echo '<a href="'.url('index.php?page=product&id=' . ($product['url_slug'] ? ($product['url_slug'].'/'.$option_id ) : $product['id'])).'" id="'.$product['id'].'A" class="product">';
}
?>
<?php if (!empty($product['img']) && file_exists($product['img'])): ?>
<?php if (empty($product['product_config'])): ?>
<img src="<?=base_url?><?=$product['img']?>" width="" height="250" alt="<?=$product['name']?>">
</a>
<!-- Show small image below main image in case of not configured -->
<div class="" style="display:flex;justify-content: center">
//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['alternative_media']; // 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'])) ? (currency_code.((isset($attribute['price_modifier']) && $attribute['price_modifier'] == 1) ? number_format(floatval($product_price+$attribute_price),2) : number_format(($product_price-$attribute_price),2))) : (($product_price != 0.00) ? currency_code.number_format($product_price,2) : '');
$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="<?=base_url?><?=$product['img']?>"/>
</div>
</div>
<?php else: ?>
<img src="<?=base_url?><?=$product['img']?>" id="<?=$product['id']?>" width="" height="250" alt="<?=$product['name']?>">
</a>
<div class="" style="display:flex;justify-content: center">
<?php
$option_profile = json_decode($product['product_config']);
foreach ($option_profile as $option){
foreach ($media as $media_item){
if ($media_item['id'] == $option->IMG_small_id){
$IMG_small_id = $media_item['full_path'];
}
if ($media_item['id'] == $option->IMG_large_id){
$IMG_large_id = $media_item['full_path'];
}
}
$option_id = ($option->option_id != '') ? $option->option_id : '';
$option_price = $option->option_price ?? 0;
$option_price = currency_code.number_format($product['price']+$option_price,2);
echo'
<div>
<img class="img_config" src="'.url($IMG_small_id).'" id="'.$option->IMG_small_id.'" onclick="update(\''.$product['id'].'\',\''.url($IMG_large_id).'\',\''.url('index.php?page=product&id=' . ($product['url_slug'] ? $product['url_slug'].'/'.$option_id : $product['id'].'/'.$option_id )).'\',\''.$option_price.'\')" />
</div>
';
}
?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php
//Stock status
$stock_status = ($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;"';
?>
<span class="stock">
<p <?=$style?>> <?=$stock_status?> </p>
</span>
<?php
if (free_shipment_indicator){
freeShipment($product['price'],'span');
<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>';
}
}
//ADD related optionID when configuration is found
if (empty($product['product_config'])){
$option_id = '';
} else {
$option_id = '/'.getPictureID($pdo,$product['id'],$product['product_config']);
//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>';
}
?>
<a href="<?=url('index.php?page=product&id=' . ($product['url_slug'] ? $product['url_slug'].$option_id : $product['id']))?>" id="<?=$product['id']?>B" class="product">
<span class="name"><?=$product['name']?></span>
<span class="price" id="<?=$product['id']?>C">
<?=currency_code?><?=number_format($product['price'],2)?>
<?php if ($product['rrp'] > 0): ?>
<span class="rrp"><?=currency_code?><?=number_format($product['rrp'],2)?></span>
<?php endif; ?>
</span>
//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="name">'.$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>
<?php endforeach; ?>
</div>
</div>';
}
<div class="buttons">
<?php if ($current_page > 1): ?>
<a href="<?=url('index.php?page=products&p=' . ($current_page-1) . '&category=' . $category . '&sort=' . $sort)?>" class="btn">Prev</a>
<?php endif; ?>
<?php if ($total_products > ($current_page * $num_products_on_each_page) - $num_products_on_each_page + count($products)): ?>
<a href="<?=url('index.php?page=products&p=' . ($current_page+1) . '&category=' . $category . '&sort=' . $sort)?>" class="btn">Next</a>
<?php endif; ?>
</div>
$view .= '
</div>';
$view .= '
<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>';
}
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>';
}
$view .= '</div>
</div>
<script>
</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';
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>
<?=template_footer()?>
</script>';
//OUTPUT
echo $view;
template_footer()
?>