| Server IP : 46.202.172.170 / Your IP : 216.73.216.59 Web Server : LiteSpeed System : Linux fr-int-web1904.main-hosting.eu 5.14.0-503.34.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 27 06:00:50 EDT 2025 x86_64 User : u627918583 ( 627918583) PHP Version : 8.2.28 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/u627918583/domains/rokamaksa.com/public_html/ar2/ |
Upload File : |
<?php
session_start();
include "connection.php";
global $connection;
include "function.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$submit = isset($_POST["submit"]) ? $_POST["submit"] : null;
$id = isset($_POST["id"]) ? $_POST["id"] : null;
$coupons = 0;
if ($submit == "plus") {
$update_stmt = $connection->prepare("UPDATE cart SET quantity = (quantity + 1) WHERE id = ?");
$update_stmt->bind_param("i" ,$id);
$update_stmt->execute();
} elseif ($submit == "minus") {
$stmt = $connection->prepare("SELECT quantity FROM cart WHERE id = $id");
$stmt->execute();
$row = $stmt->get_result();
while ($data = $row->fetch_assoc()){
$quantity = $data["quantity"];
}
if ($quantity > 1) {
$update_stmt = $connection->prepare("UPDATE cart SET quantity = (quantity - 1) WHERE id = ?");
$update_stmt->bind_param("i" ,$id);
$update_stmt->execute();
}else {
$stmt = $connection->prepare("DELETE FROM cart WHERE id = ?");
$stmt->bind_param("i" , $id);
$stmt->execute();
}
}elseif ($submit == "coupon") {
$coupon_input = $_POST['coupon-input'];
$stmt = $connection->prepare("SELECT price FROM coupons WHERE coupon = ?");
$stmt->bind_param("s" , $coupon_input);
$stmt->execute();
$row = $stmt->get_result();
while ($data = $row->fetch_assoc()){
$coupons = $data["price"];
}
}
$itemKey = isset($_POST["itemKey"]) ? $_POST["itemKey"] : null;
$stmt = $connection->prepare("DELETE FROM cart WHERE id = ?");
$stmt->bind_param("i" , $itemKey);
$stmt->execute();
}
$stmt_delivarycompany = $connection->prepare("SELECT price FROM delivarycompany WHERE id = (SELECT MIN(id) FROM delivarycompany);");
$stmt_delivarycompany->execute();
$result_delivarycompany = $stmt_delivarycompany->get_result();
$checked = 0;
if ($result_delivarycompany->num_rows > 0) {
$row_delivarycompany = $result_delivarycompany->fetch_assoc();
$price_delivarycompany = $row_delivarycompany['price'];
}
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<?php include "head.php"; ?>
<title>سلة المشتريات - <?= $webname; ?></title>
<meta property="og:title" content="سلة المشتريات" />
<meta property="og:url" content="<?= $webLink ?>/ar/cart.php" />
<link rel="canonical" href="<?= $webLink ?>/ar/cart.php" />
<link rel="alternate" hreflang="ar" href="<?= $webLink ?>/ar/cart.php" />
<link rel="alternate" hreflang="en" href="<?= $webLink ?>/ar/cart.php" />
<style>
.list--vertical {
flex-direction: column;
flex-wrap: wrap;
}
.list--horizontal, .list--vertical {
align-items: center;
display: flex;
justify-content: flex-start;
}
.list, .list--clear {
list-style: none;
margin: 0;
padding: 0;
}
.list {
flex-wrap: wrap;
}
.list--product-fields {
margin-bottom: 25px!important;
}
.list--product-fields li.form-group:first-child {
margin-top: 20px;
}
.list--product-fields li.form-group {
margin: 0px 0 5px;
}
.list>li:first-child {
margin-top: 0;
}
.list--product-fields li.form-group {
align-items: flex-start;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
margin: 0 0 25px;
position: relative;
width: 100%;
}
.product-options .form-group {
margin-bottom: 15px;
}
.product-options .form-group {
margin-bottom: 0;
min-height: 55px;
padding-bottom: 0;
}
.product-options .form-group {
margin-bottom: 0;
min-height: 55px;
padding-bottom: 0;
}
.list>li, .list>li .list>li {
margin-top: 7px;
}
.form-group {
margin-bottom: 20px;
position: relative;
}
.form-group {
margin-bottom: 15px;
}
.list--product-fields li.form-group>label {
font-size: 15px;
margin: 0;
padding: 0 0 0 10px;
}
.list--product-fields li.form-group>div, .list--product-fields li.form-group>label {
flex: 0 0 50%;
}
.product-option-name {
font-size: 15px;
color: #555;
}
.list--product-fields li.form-group>label.required:after {
color: #f55157;
content: "*";
font-size: 15px;
}
input[type=checkbox], input[type=radio] {
margin: 4px 0 0;
line-height: normal;
}
.text-warning {
color: #000 !important
}
.list--product-fields li.form-group .bootstrap-select>.btn.btn-default, .list--product-fields li.form-group .btn, .list--product-fields li.form-group .form-control:not(textarea) {
height: 40px!important;
min-height: unset!important;
width: 100%;
}
.list--product-fields li.form-group .bootstrap-select>.btn.btn-default, .list--product-fields li.form-group .btn, .list--product-fields li.form-group .form-control, .list--product-fields li.form-group textarea {
border-color: #dcdcdc;
border-radius: 3px;
box-shadow: none!important;
}
.form-control {
color: #000 ;
}
.list--product-fields li.form-group .bootstrap-select>.btn.btn-default, .list--product-fields li.form-group .btn, .list--product-fields li.form-group .form-control, .list--product-fields li.form-group textarea {
border-color: #dcdcdc;
border-radius: 3px;
box-shadow: none!important;
}
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
background-color: #eee;
opacity: 1;
}
</style>
</head>
<body id="app" class="cart salla-814202285 color-mode-dark rtl font-dinnextltarabic-regular bg-white topnav-is-dark mainbar-is-dark mainmenu-is-dark footer-is-dark has-breadcrumbs">
<div class="app-inner flex flex-col min-h-screen relative">
<?php include "header.php"; ?>
<div class="container page-container px-3 sm:px-5">
<nav class="breadcrumbs w-full py-3 sm:py-5">
<ol class="flex items-center flex-wrap text-sm">
<li class="whitespace-nowrap"><a href="../ar/" class="fix-align text-primary">الرئيسية</a></li>
<li><i class="sicon-keyboard_arrow_left ltr:-scale-x-100 inline-block arrow mx-2"></i></li>
<li><span class="fix-align opacity-70">سلة المشتريات</span></li>
</ol>
</nav>
<h1 class="sr-only">السلة</h1>
<?php
$user = isset($_SESSION["user"]) ? $_SESSION["user"] : false;
$query = "SELECT * FROM cart WHERE user = '$user'";
$result = mysqli_query($connection, $query);
$price = 0;
if (isset($_SESSION["user"])) {
if (mysqli_num_rows($result) > 0) {
$stmt = $connection->prepare("SELECT * FROM cart WHERE user = ?");
$stmt->bind_param("s" ,$user);
$stmt->execute();
$row = $stmt->get_result();
echo '<div class="flex flex-col items-start lg:flex-row">
<div class="main-content flex-1 w-full">';
while ($data = $row->fetch_assoc()){
$id = $data['product_id'];
if (!isset($id)) {
echo '<div class="flex flex-col items-start lg:flex-row">
<div class="main-content flex-1 w-full">
<div class="no-content-placeholder">
<i class="sicon-shopping-bag icon"></i>
<p>السلة فارغة</p>
<a href="../ar/" class="btn btn--outline-primary">عودة للرئيسية</a>
</div>
</div>
</div>';
}else {
$stmt_products = $connection->prepare("SELECT * FROM products WHERE id = $id");
$stmt_products->execute();
$row_products = $stmt_products->get_result();
while ($data_products = $row_products->fetch_assoc()){
$price += $data_products['decPrice'] > 0 ? ($data_products['decPrice'] * $data['quantity']) : ($data_products['price'] * $data['quantity']);
$decprice = $data_products['decPrice'] > 0 ? $data_products['decPrice'] : $data_products['price'];
echo '<form action="cart.php" method="POST">';
echo '<section class="cart-item bg-white border overflow-hidden p-5 sm:p-7 rounded mb-5 relative">
<input type="hidden" name="id" value="'.$data['id'].'" id="">
<div class="xl:flex rtl:space-x-reverse xl:space-x-8 items-start justify-between mb-8 last:mb-0">
<div class="flex flex-1 rtl:space-x-reverse space-x-4">
<a href="../ar/product.php?id='.$data_products['id'].'" class="shrink-0">
<img src="../BEqq'.$data_products['main_image'].'" data-src="../BEqq'.$data_products['main_image'].'" alt="'.$data_products['name'].'" class="flex-none w-24 h-20 border border-gray-200 bg-gray-100 rounded object-center object-cover loaded" loading="lazy" data-ll-status="loaded">
</a>
<div class="space-y-1">
<h3 class="text-gray-900 leading-6">
<a href="../ar/product.php?id='.$data_products['id'].'" class="text-base">'.$data_products['name'].'</a>
</h3>
<span class="text-sm text-gray-400 line-through item-regular-price hidden">'.$decprice.' ر.س</span>
<span class="item-price text-sm text-gray-400">'. $decprice.' ر.س</span>
<input type="hidden" value="'.$decprice.'" id="decPrice">
<i class="sicon-discount-calculator text-gray-400 offer-icon hidden"></i>
<span class="text-sm text-gray-400 offer-name hidden"></span>
</div>
<div class="w-10 xl:hidden"></div>
</div>
<div class="flex-1 border-t border-b py-3 xl:p-0 xl:border-none mt-5 xl:mt-0 w-full xl:w-auto flex justify-between items-center xl:items-start">
<div max="" class="transtion transition-color duration-300 s-quantity-input hydrated" value="1" name="quantity"><!---->
<div class="s-quantity-input-container">
<button class="s-quantity-input-increase-button s-quantity-input-button" type="submit" value="plus" name="submit">
<span><!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>add</title>
<path d="M26.667 14.667h-9.333v-9.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v9.333h-9.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h9.333v9.333c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-9.333h9.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
</svg>
</span>
</button>
<input type="number" class="s-quantity-input-input" value="'.$data['quantity'].'" max="" id="quantity" name="quantity" min="1">
<button class="s-quantity-input-decrease-button s-quantity-input-button" type="submit" value="minus" name="submit">
<span><!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>minus</title>
<path d="M26.667 14.667h-21.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h21.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
</svg>
</span>
</button>
</div>
</div>
<p class="flex-none font-bold text-sm rtl:xl:pl-12 ltr:xl:pr-12">
<span>المجموع:</span>
<span class="inline-block item-total" style="opacity: 1; transform: scale(1);" id="price">'.($decprice * $data['quantity']).' ر.س</span>
</p>
</div>
</div>
<span class="absolute top-1.5 rtl:left-1.5 ltr:right-1.5 sm:top-5 rtl:sm:left-5 ltr:sm:right-5">
<div type="button" shape="icon" size="small" color="danger" class="btn--delete s-button-wrap hydrated" fill="solid" width="normal">
<button type="submit" value="'.$data['id'].'" name="itemKey" shape="icon" class="btn--delete s-button-element s-button-icon s-button-solid s-button-small s-button-danger s-button-loader-center">
<span class="s-button-text">
<i class="sicon-cancel"></i>
</span>
</button>
</div>
</span>
</section>';
echo '</form>';
}
}
}
echo '</div>
<div class="sticky top-24 w-full lg:w-96 rtl:lg:mr-8 ltr:lg:ml-8">
<div class="bg-white border p-5 sm:p-7 pb-12 rounded mb-5 relative hidden" id="free-shipping">
<div class="flex rtl:space-x-reverse space-x-3 items-center">
<i class="bg-primary text-primary-reverse rounded-icon sicon-shipping-fast flip-x"></i>
<div class="flex-1">
<h4 class="shipping-item font-bold text-sm mb-1.5">شحن مجاني</h4>
<p class="shipping-item text-sm font- text-gray-400">
<span id="free-shipping-msg">مبروك عليك الشحن المجاني !</span>
<span class="emoji " id="free-shipping-applied">🎉</span>
</p>
</div>
</div>
<div class="mt-6 bg-border-color bg-gray-100 rounded-full hidden" id="free-shipping-bar">
<div class="transition-all duration-500 h-4 bg-primary relative rounded-full flex justify-end" style="width:100%">
<i class="inline-block sicon-shipping-fast text-sm absolute -bottom-5 rtl:left-0 ltr:right-0 flip-x"></i>
</div>
</div>
</div>
<div class="bg-white border p-5 sm:p-7 pb-12 rounded mb-5 relative hidden" id="free-shipping">
<div class="flex rtl:space-x-reverse space-x-3 items-center">
<i class="bg-primary text-primary-reverse rounded-icon sicon-shipping-fast flip-x"></i>
<div class="flex-1">
<h4 class="shipping-item font-bold text-sm mb-1.5">شحن مجاني</h4>
<p class="shipping-item text-sm font- text-gray-400">
<span id="free-shipping-msg">احصل على <b>شحن مجاني</b> عند إضافة <b>0 ر.س</b> للسلة</span>
<span class="emoji hidden" id="free-shipping-applied">🎉</span>
</p>
</div>
</div>
<div class="mt-6 bg-border-color bg-gray-100 rounded-full " id="free-shipping-bar">
<div class="transition-all duration-500 h-4 bg-primary relative rounded-full flex justify-end" style="width:%">
<i class="inline-block sicon-shipping-fast text-sm absolute -bottom-5 rtl:left-0 ltr:right-0 flip-x"></i>
</div>
</div>
</div>
<div class="bg-white border p-5 sm:p-7 rounded mb-5 relative transition-all duration-1000">
<h4 class="font-bold text-sm mb-5">ملخص الطلب</h4>
<div class="flex justify-between text-sm mb-5">
<span class="text-gray-400">مجموع المنتجات</span>
<b id="sub-total">'. $price .' ر.س</b>
</div>
<div id="shipping-cost" class="flex justify-between text-sm mb-5 hidden">
<span class="text-gray-400">تكلفة الشحن</span>
<b>0 ر.س</b>
</div>
<div class="border-t border-gray-200 border-b py-5 mb-5">
<label for="coupon" class="block text-sm ">هل لديك كود خصم</label>
<form action="'.$_SERVER["PHP_SELF"].'" method="POST" class="mt-2.5 relative">
<input placeholder="ادخل كود الخصم" class="rtl:pl-24 ltr:pr-24 form-input" id="coupon-input" name="coupon-input" type="text">
<salla-button1 class="btn--coupon has-not-coupon btn--default s-button-wrap hydrated" loader-position="center" id="coupon-btn" shape="btn" color="primary" fill="solid" size="medium" width="normal"><!---->
<button class="btn--coupon has-not-coupon btn--default s-button-element s-button-btn s-button-solid s-button-primary s-button-loader-center" loader-position="center" type="submit" value="coupon" name="submit" style="border-color: '.$color_button1.' ; background-color: '.$color_button1.'; color: #ffffff;" type="button">
<span class="s-button-text">
<span class="coupon-text">إضافة</span>
</span>
</button>
</salla-button1>
</form>
<span class="text-xs text-red-700" id="coupon-error"></span>
</div>
<div id="total-discount" class="flex justify-between text-sm hidden">
<span class="text-gray-400 block h-10">الخصم</span>
<b>- 0 ر.س</b>
</div>
<div class="product-options" style=" margin-top:20px;">
<ul class="list list--vertical list--product-fields mainData">
<li class="form-group qty-field-wrapper form-group--wide" style="margin:0 !important">
<label class="product-option-name required">التوصيل بواسطة</label>
</li>
<li class="form-group qty-field-wrapper form-group--wide" style="margin:0 !important">';
$stmt_delivarycompany = $connection->prepare("SELECT * FROM `delivarycompany`");
$stmt_delivarycompany->execute();
$row_delivarycompany = $stmt_delivarycompany->get_result();
$checked = 0;
while ($data_delivarycompany = $row_delivarycompany->fetch_assoc()){
echo '<label for="DelivaryCompany+1" class="product-option-name">
<input type="radio" id="DelivaryCompany+'.$data_delivarycompany['id'].'" onchange="handleRadioChange(event)" value="'.$data_delivarycompany['price'].'" name="delivaryCompanyId" ';
echo $checked == 0 ? "checked" : '';
echo '>
'.$data_delivarycompany['name'].'
</label>
<div>
<div>
<label for="DelivaryCompany+'.$data_delivarycompany['id'].'" class="product-option-name" style="float:left;">'.$data_delivarycompany['price'].' ر.س</label>
</div>
</div>';
$checked += 1;
}
echo '</li>
</ul>
</div>
<div class="flex justify-between text-sm mb-5">
<span class="text-gray-400">الإجمالي</span>
<b id="final-total">'. ((isset($coupons) ? ($price - $coupons) : $price )) + $price_delivarycompany.' ر.س</b>
</div>
<form action="checkout.php" method="POST" class="cart-submit-wrap">
<input type="hidden" name="delivarycompany" id="delivarycompany" value="'.$price_delivarycompany.'">
<input type="hidden" name="pricecheckout" id="pricecheckout" value="'. ((isset($coupons) ? ($price - $coupons) : $price )) + $price_delivarycompany.'">
<salla-button1 onclick="salla.cart.submit()" name="checkout" value="checkout" type="submit" loader-position="center" width="wide" class="s-button-wrap hydrated" shape="btn" color="primary" fill="solid" size="medium"><!---->
<button loader-position="center" name="checkout" value="checkout" type="submit" style="border-color: '.$color_button1.'; background-color: '.$color_button1.'; color: #ffffff;" class="undefined s-button-element s-button-btn s-button-solid s-button-wide s-button-primary s-button-loader-center">
<span class="s-button-text">
اتمام الطلب
</span>
</button>
</salla-button1>
</div>
</form>
</div>
</div>';
}else {
echo '<div class="flex flex-col items-start lg:flex-row">
<div class="main-content flex-1 w-full">
<div class="no-content-placeholder">
<i class="sicon-shopping-bag icon"></i>
<p>السلة فارغة</p>
<a href="../ar/" class="btn btn--outline-primary">عودة للرئيسية</a>
</div>
</div>
</div>';
}
}else {
echo '<div class="flex flex-col items-start lg:flex-row">
<div class="main-content flex-1 w-full">
<div class="no-content-placeholder">
<i class="sicon-shopping-bag icon"></i>
<p>السلة فارغة</p>
<a href="../ar/" class="btn btn--outline-primary">عودة للرئيسية</a>
</div>
</div>
</div>';
}
?>
</div>
<?php include "footer.php"; ?>
<div class="hidden grid-cols-4 h-fit self-end grayscale sm:items-start sm:items-end"></div>
<div class="overlay-layer has-overlay--after"></div>
</div>
<script>
function handleRadioChange(event) {
var highestPrice = <?php echo json_encode(((isset($coupons) ? ($price - $coupons) : $price ))); ?>;
document.getElementById("final-total").innerHTML = Number(highestPrice) + Number(event.target.value) + ' ر.س';
document.getElementById("pricecheckout").innerHTML = Number(highestPrice) + Number(event.target.value);
document.getElementById("pricecheckout").value = Number(highestPrice) + Number(event.target.value);
document.getElementById("delivarycompany").value = Number(event.target.value);
}
</script>
</body>
</html>