CMXX - Placeorder initial version
This commit is contained in:
193
functions.php
193
functions.php
@@ -31,6 +31,7 @@ $dompdf = new Dompdf($options);
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
require dirname(__FILE__).'/lib/mail/PHPMailer.php';
|
||||
require dirname(__FILE__).'/lib/mail/SMTP.php';
|
||||
@@ -42,11 +43,13 @@ require dirname(__FILE__).'/lib/mail/Exception.php';
|
||||
function send_mail_by_PHPMailer($to, $subject, $message, $attachment, $attachment_name){
|
||||
|
||||
// SEND MAIL by PHP MAILER
|
||||
$mail = new PHPMailer();
|
||||
$mail = new PHPMailer(true);
|
||||
$mail->isSMTP(); // Use SMTP
|
||||
$mail->CharSet = 'UTF-8';
|
||||
//$mail->isSMTP(); // Use SMTP protocol
|
||||
$mail->Host = email_host_name; // Specify SMTP server
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Use TLS encryption
|
||||
$mail->SMTPAuth = true; // Auth. SMTP
|
||||
//$mail->SMTPDebug = 3; // To view debug output
|
||||
$mail->Username = email; // Mail who send by PHPMailer
|
||||
$mail->Password = email_outgoing_pw; // your pass mail box
|
||||
$mail->SMTPSecure = email_outgoing_security; // Accept SSL
|
||||
@@ -60,13 +63,12 @@ function send_mail_by_PHPMailer($to, $subject, $message, $attachment, $attachmen
|
||||
if (!empty($attachment) || $attachment != ''){
|
||||
$mail->AddStringAttachment($attachment, $attachment_name, 'base64', 'application/pdf');
|
||||
}
|
||||
|
||||
|
||||
// SEND
|
||||
if( !$mail->send() ){
|
||||
|
||||
// render error if it is
|
||||
$tab = array('error' => 'Mailer Error: '.$mail->ErrorInfo );
|
||||
echo json_encode($tab);
|
||||
debuglog(json_encode($tab));
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
@@ -137,8 +139,7 @@ function send_order_details_email($email, $products, $first_name, $last_name, $a
|
||||
include './custom/translations/translations_'.strtoupper(language_code).'.php';
|
||||
// Send payment notification to webmaster
|
||||
$address_name = htmlspecialchars($first_name ?? '', ENT_QUOTES).' '.htmlspecialchars($last_name ?? '', ENT_QUOTES);
|
||||
if (email_notifications) {
|
||||
|
||||
if (email_notifications) {
|
||||
$subject = $subject_order_notification;
|
||||
$headers = 'From: ' . mail_from . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'Return-Path: ' . mail_from . "\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: text/html; charset=UTF-8' . "\r\n";
|
||||
ob_start();
|
||||
@@ -664,113 +665,105 @@ function getPictureID($pdo,$id,$config){
|
||||
//++++++++++++++++++++++++++++++++++++++++
|
||||
//HomePage Products
|
||||
//++++++++++++++++++++++++++++++++++++++++
|
||||
function highlightedProducts($pdo,$categoryID,$range){
|
||||
function highlightedProducts($clientsecret,$categoryID,$range){
|
||||
|
||||
include './custom/translations/translations_'.strtoupper(language_code).'.php';
|
||||
|
||||
$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 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 WHERE p.status = 1');
|
||||
$stmt->bindValue(':category_id', $categoryID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//GET CATALOG DATA
|
||||
$products = ioAPIv2('/v2/catalog/category='.$categoryID,'',$clientsecret);
|
||||
$products = json_decode($products,true);
|
||||
|
||||
$view = '
|
||||
<h2>'.$range.'<span class="limited">Limited edition</span></h2>
|
||||
<div class="products">';
|
||||
foreach($products as $product){
|
||||
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">';
|
||||
if (empty($product['product_config'])){
|
||||
$view .= '<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']);
|
||||
|
||||
$view .= '<a href="'.url('index.php?page=product&id=' . ($product['url_slug'] ? ($product['url_slug'].'/'.$option_id ) : $product['id'])).'" id="'.$product['id'].'A" class="product">';
|
||||
}
|
||||
|
||||
if (!empty($product['img']) && file_exists($product['img'])){
|
||||
if (empty($product['product_config'])){
|
||||
$view .= '
|
||||
<img src="'.$product['img'].'" width="" height="250" alt="'.$product['name'].'">';
|
||||
$view .= '
|
||||
</a>
|
||||
<!-- Show small image below main image in case of not configured -->
|
||||
<div class="" style="display:flex;justify-content: center">
|
||||
<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="200" height="" 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
|
||||
|
||||
// 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="'.base_url.$product['img'].'"/>
|
||||
<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>';
|
||||
} else {
|
||||
}
|
||||
|
||||
//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']} ?? $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) : '').'';
|
||||
|
||||
$view .= '<img src="'.base_url.$product['img'].'" id="'.$product['id'].'" width="" height="250" alt="'.$product['name'].'">
|
||||
</a>';
|
||||
if (show_options_carrousel){
|
||||
$view .= '<div class="" style="display:flex;justify-content: center">';
|
||||
$option_profile = json_decode($product['product_config']);
|
||||
|
||||
foreach ($option_profile as $option){
|
||||
//get all media
|
||||
$stmt = $pdo->query('SELECT id, full_path FROM media');
|
||||
$stmt->execute();
|
||||
$media = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
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 : '';
|
||||
|
||||
$view .= '
|
||||
<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 )).'\')" />
|
||||
</div>
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
$view .= '</div>';
|
||||
if (isset($product['rrp']) && $product['rrp'] > 0){
|
||||
$view .= '<span class="rrp">'.currency_code.number_format($product['rrp'],2).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//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;"';
|
||||
$view .=' <span class="stock">
|
||||
<p '.$style.'> '.$stock_status.' </p>
|
||||
</span>';
|
||||
|
||||
|
||||
//Remove first characters from Productname
|
||||
if (product_truncate_text != ''){
|
||||
$productname = str_replace(product_truncate_text,'',$product['name']);
|
||||
$productname = (product_truncate !=0)? substr($productname,product_truncate):$productname;
|
||||
} else {
|
||||
$productname = $product['name'];
|
||||
}
|
||||
|
||||
//ADD related optionID when configuration is found
|
||||
if (empty($product['product_config'])){
|
||||
$option_id = '';
|
||||
}else {
|
||||
$option_id = '/'.getPictureID($pdo,$product['id'],$product['product_config']);
|
||||
}
|
||||
$view .= '
|
||||
<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="productname">'.$productname.'</span>
|
||||
<span class="productprice">'.currency_code.number_format($product['price'],2);
|
||||
if ($product['rrp'] > 0) {
|
||||
$view .= '<span class="productrrp">'.currency_code.number_format($product['rrp'],2).'</span>';
|
||||
}
|
||||
$view .= '
|
||||
</span>
|
||||
</a>
|
||||
</div>';
|
||||
$view .= '</span>';
|
||||
}
|
||||
$view .= '
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$view .= '</div>';
|
||||
|
||||
Reference in New Issue
Block a user