|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/laciasmara.com/public_html/shop/application/views/ |
Upload File : |
<style>
.container {
display: flex;
gap: 12px;
padding: 24px 60px;
min-height: 100vh;
}
.cart-section {
flex-grow: 1;
}
.cart-title {
font-size: 24px;
font-weight: bold;
margin-bottom: 16px;
}
.cart-container {
background: white;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 6px;
overflow: hidden;
}
.cart-header {
padding: 16px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #e2e8f0;
}
.select-all-container {
display: flex;
align-items: center;
gap: 8px;
}
.checkbox-input {
width: 20px;
height: 20px;
border-radius: 4px;
border: 1px solid #cbd5e1;
cursor: pointer;
}
.cart-item:last-child {
border-bottom: none;
}
.item-container {
padding: 12px;
display: flex;
gap: 12px;
align-items: flex-start;
width: 100%;
box-sizing: border-box;
}
.item-image-container {
position: relative;
flex-shrink: 0;
}
.item-image {
width: 70px;
height: 70px;
border-radius: 8px;
object-fit: cover;
}
.discount-badge {
position: absolute;
top: 4px;
left: 4px;
background: #ef4444;
color: white;
padding: 2px 6px;
border-radius: 4px;
font-size: 10px;
}
.item-details {
display: flex;
flex-direction: column;
gap: 4px;
flex-grow: 1;
min-width: 0;
/* Allow shrinking */
overflow: hidden;
}
.item-name {
font-size: 14px;
font-weight: 500;
margin-bottom: 4px;
color: #333;
margin-top: 0;
line-height: 1.3;
word-wrap: break-word;
}
.item-variant {
color: #64748b;
font-size: 12px;
margin-top: 4px;
word-wrap: break-word;
}
.item-actions {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
flex-shrink: 0;
min-width: fit-content;
}
.price-container {
text-align: right;
margin-bottom: 4px;
}
.current-price {
font-weight: 600;
font-size: 14px;
white-space: nowrap;
}
.original-price {
color: #636e72;
text-decoration: line-through;
font-size: 12px;
white-space: nowrap;
}
.controls-container {
display: flex;
align-items: center;
gap: 6px;
background: white;
flex-wrap: nowrap;
}
.remove-item {
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
color: white;
border: none;
width: 30px;
height: 30px;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
font-size: 12px;
flex-shrink: 0;
}
.remove-item::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
transition: left 0.5s ease;
}
.remove-item:hover::before {
left: 100%;
}
.remove-item:hover {
transform: translateY(-1px);
box-shadow: 0 3px 8px rgba(238, 90, 36, 0.4);
}
.remove-item:active {
transform: translateY(0px);
box-shadow: 0 2px 6px rgba(238, 90, 36, 0.3);
}
.quantity-controls {
display: flex;
align-items: center;
border-radius: 20px;
padding: 0.2rem;
gap: 0.4rem;
transition: all 0.3s ease;
flex-shrink: 0;
}
.quantity-controls:hover {
border-color: #7A4397;
box-shadow: 0 0 0 2px rgba(122, 67, 151, 0.1);
}
.quantity-button {
background-color: #7A4397;
color: white;
border: none;
width: 28px;
height: 28px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 600;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
flex-shrink: 0;
}
.quantity-button::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.4s ease;
}
.quantity-button:hover::before {
left: 100%;
}
.quantity-button:hover {
transform: scale(1.05);
box-shadow: 0 3px 8px rgba(122, 67, 151, 0.3);
}
.quantity-button:active {
transform: scale(1.02);
}
.quantity-button.minus-button:hover {
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}
.quantity-button.plus-button:hover {
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}
.quantity-display {
min-width: 32px;
text-align: center;
font-weight: 600;
font-size: 14px;
color: #333;
background: white;
border-radius: 6px;
padding: 0.2rem 0.4rem;
border: 1px solid #dee2e6;
flex-shrink: 0;
}
.empty-cart {
text-align: center;
font-weight: 600;
font-size: 14px;
color: #333;
padding: 0 16px;
}
.empty-cart img {
width: 250px;
height: 250px;
margin: 0 auto;
}
/* Mobile Responsive Styles */
@media (max-width: 768px) {
.cart-title {
font-size: 20px;
margin-bottom: 12px;
}
.cart-container {
padding: 4px;
margin: 0 -4px;
/* Extend to screen edges if needed */
}
.item-container {
padding: 10px 8px;
gap: 10px;
flex-wrap: nowrap;
}
.item-image {
width: 60px;
height: 60px;
}
.item-name {
font-size: 13px;
line-height: 1.2;
}
.item-variant {
font-size: 11px;
}
.current-price {
font-size: 13px;
}
.original-price {
font-size: 12px;
}
.controls-container {
gap: 4px;
flex-direction: row;
align-items: center;
}
.remove-item {
width: 28px;
height: 28px;
font-size: 11px;
order: 2;
/* Move remove button after quantity */
}
.quantity-controls {
gap: 0.3rem;
padding: 0.15rem;
order: 1;
}
.quantity-button {
width: 26px;
height: 26px;
font-size: 13px;
}
.quantity-display {
min-width: 28px;
font-size: 13px;
padding: 0.15rem 0.3rem;
}
}
@media (max-width: 480px) {
.item-container {
padding: 8px 6px;
gap: 8px;
}
.item-image {
width: 50px;
height: 50px;
}
.item-name {
font-size: 12px;
}
.item-variant {
font-size: 10px;
}
.current-price {
font-size: 12px;
}
.controls-container {
gap: 3px;
}
.remove-item {
width: 26px;
height: 26px;
font-size: 10px;
}
.quantity-button {
width: 24px;
height: 24px;
font-size: 12px;
}
.quantity-display {
min-width: 26px;
font-size: 12px;
padding: 0.1rem 0.25rem;
}
.quantity-controls {
gap: 0.25rem;
padding: 0.1rem;
}
}
/* Extra small screens */
@media (max-width: 360px) {
.item-container {
padding: 6px 4px;
gap: 6px;
}
.item-details {
gap: 2px;
}
.item-actions {
gap: 6px;
}
.controls-container {
flex-direction: column;
gap: 4px;
align-items: flex-end;
}
.quantity-controls {
order: 1;
}
.remove-item {
order: 2;
width: 24px;
height: 24px;
}
}
.summary-section {
width: 320px;
}
.summary-card {
background: white;
border-radius: 8px;
padding: 16px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
position: sticky;
top: 135px;
}
.summary-title {
font-weight: 600;
margin-bottom: 16px;
margin-top: 0;
}
.total-container {
display: flex;
justify-content: space-between;
margin-bottom: 24px;
}
.total-price {
font-weight: bold;
}
.promo-button {
display: flex;
align-items: center;
gap: 12px;
padding: 12px;
border: 1px solid #e2e8f0;
border-radius: 8px;
width: 100%;
background: white;
cursor: pointer;
margin-bottom: 16px;
}
.promo-button:hover {
background-color: #f8fafc;
}
.promo-icon {
width: 24px;
height: 24px;
}
.promo-text {
flex-grow: 1;
text-align: left;
color: #64748b;
font-size: 14px;
}
.checkout-cart-button {
width: 100%;
padding: 12px;
background-color: #7A4397;
color: white;
border: none;
border-radius: 8px;
font-weight: 500;
cursor: pointer;
font-size: 14px;
}
.checkout-button:hover {
background-color: #653680;
}
.checkout-button:disabled {
background-color: #94a3b8;
cursor: not-allowed;
}
.remove-item {
background: none;
border: none;
color: #dc3545;
cursor: pointer;
font-size: 16px;
}
.remove-item:hover {
color: #a71d2a;
}
.remove-item i {
pointer-events: none;
}
.free-shipping-message {
padding: 12px;
color: #333;
border-radius: 5px;
font-size: 14px;
text-align: center;
}
.free-shipping-message strong {
color: #FF5722;
}
@media (max-width: 768px) {
.container {
flex-direction: column;
padding: 20px;
}
.cart-section {
flex-grow: 0;
}
.cart-section,
.summary-section {
width: 100%;
margin-bottom: 16px;
}
.cart-header {
display: none;
}
.cart-item {
padding: 0;
}
.cart-title {
font-size: 20px;
}
.cart-container {
padding: 0px;
}
.total-container {
flex-direction: column;
gap: 8px;
align-items: flex-start;
}
.checkout-cart-button {
padding: 16px;
}
.free-shipping-message {
font-size: 13px;
}
}
.cart-cta {
display: inline-block;
background-color: #7A4397;
color: #ffffff;
padding: 12px 24px;
margin: 16px 0;
border-radius: 8px;
text-align: center;
font-size: 14px;
font-weight: 600;
text-decoration: none;
transition: all 0.3s ease;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.cart-cta:hover {
background-color: #653680;
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
transform: translateY(-2px);
}
.cart-cta:active {
background-color: #653680;
transform: translateY(0);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
/* Responsif */
@media (max-width: 768px) {
.cart-cta {
display: flex;
font-size: 12px;
justify-content: center;
padding: 10px 20px;
margin: 16px;
}
}
</style>
<div class="container">
<div class="cart-section">
<h1 class="cart-title"><?= ucfirst(lang('cart_title')); ?></h1>
<div class="cart-container">
<div class="cart-items">
</div>
</div>
<div class="cart-cta" id="cart-cta">
<?php if ($this->cart->total_items() == 0): ?>
<?= ucfirst(lang('cart_empty_button')) ?>
<?php else: ?>
<?= ucfirst(lang('cart_continue_shopping')) ?>
<?php endif; ?>
</div>
</div>
<div class="summary-section">
<div class="summary-card">
<h2 class="summary-title"><?= ucfirst(lang('cart_summary')) ?></h2>
<div class="total-container">
<span>Total</span>
<span class="total-price">Rp0</span>
</div>
<button class="checkout-cart-button" disabled><?= ucfirst(lang('cart_checkout')) ?></button>
<div class="free-shipping-message">
<p></p>
</div>
</div>
</div>
</div>
<script>
window.langStrings = {
'free_shipping_message_active': '<?= addslashes(lang("free_shipping_message_active")) ?>',
'free_shipping_message_achieved': '<?= addslashes(lang("free_shipping_message_achieved")) ?>',
'cart_checkout': '<?= addslashes(lang("cart_checkout")) ?>'
};
$(document).ready(function() {
const notyf = new Notyf({
duration: 2000,
position: {
x: 'center',
y: 'top'
},
ripple: false,
types: [{
type: 'success',
background: '#2e3137',
className: 'custom-notification',
icon: false
},
{
type: 'error',
background: '#2e3137',
className: 'custom-notification',
icon: false
}
]
});
const totalPriceElement = $('.total-price');
const checkoutButton = $('.checkout-cart-button');
function formatCurrency(amount) {
return `IDR ${amount.toLocaleString('id-ID', { minimumFractionDigits: 0 })}`;
}
function updateSummary() {
let totalPrice = 0;
$('.cart-item').each(function() {
const price = parseInt($(this).find('.current-price').text().replace(/[^0-9]/g, ''));
const qty = parseInt($(this).find('.quantity-display').text());
totalPrice += price * qty;
});
totalPriceElement.text(formatCurrency(totalPrice));
const targetAmount = 1500000;
const remainingAmount = targetAmount - totalPrice;
// Update pesan terkait gratis ongkir
const freeShippingMessage = $('.free-shipping-message p');
if (remainingAmount > 0) {
const formattedAmount = remainingAmount.toLocaleString('id-ID');
const message = window.langStrings.free_shipping_message_active.replace('%s', formattedAmount);
freeShippingMessage.html(message);
} else {
freeShippingMessage.html(window.langStrings.free_shipping_message_achieved);
}
if (totalPrice > 0) {
checkoutButton.prop('disabled', false);
checkoutButton.on('click', function() {
window.location.href = '<?= base_url("shipping") ?>';
});
} else {
checkoutButton.prop('disabled', true);
}
}
function loadCartItems() {
$.ajax({
url: '<?= base_url("cart/get_cart_items") ?>',
type: 'GET',
dataType: 'json',
success: function(response) {
if (response.status === 'success') {
const items = response.items;
const cartItemsContainer = $('.cart-items');
cartItemsContainer.empty();
if (items.length === 0) {
cartItemsContainer.append(`
<div class="empty-cart">
<img src="https://storage.googleapis.com/laciasmara-photos/laciaasmara_assets/laciasmara_404/undraw_empty_re_opql.svg" alt="Empty Cart">
<p><?= ucfirst(lang('cart_empty_header')) ?></p>
</div>
`);
checkoutButton.prop('disabled', true);
} else {
items.forEach(item => {
const itemHtml = `
<div class="cart-item" data-id="${item.rowid}" data-productid="${item.id}">
<div class="item-container">
<div class="item-image-container">
<img src="<?= base_url('uploads/product/') ?>${item.image}" alt="${item.name}" class="item-image">
</div>
<div class="item-details">
<h3 class="item-name">${item.name}</h3>
<p class="item-variant">${item.variant || ''}</p>
</div>
<div class="item-actions">
<div class="price-container">
<div class="current-price">${formatCurrency(item.price)}</div>
</div>
<div class="controls-container">
<button class="remove-item" data-id="${item.rowid}" title="Hapus">
<i class="fas fa-trash"></i>
</button>
<div class="quantity-controls">
<button class="quantity-button minus-button" data-id="${item.rowid}">-</button>
<span class="quantity-display">${item.qty}</span>
<button class="quantity-button plus-button" data-id="${item.rowid}">+</button>
</div>
</div>
</div>
</div>
</div>
`;
cartItemsContainer.append(itemHtml);
});
}
updateSummary();
bindCartActions();
}
},
error: function() {
console.error('Error loading cart items.');
}
});
}
function bindCartActions() {
$('.remove-item').on('click', function() {
const rowId = $(this).data('id');
removeCartItem(rowId);
});
$('.quantity-button').on('click', function() {
const rowId = $(this).data('id');
const action = $(this).hasClass('minus-button') ? 'decrease' : 'increase';
updateQuantity(rowId, action);
});
}
function updateQuantity(rowId, action) {
$.ajax({
url: '<?= base_url("cart/update_quantity") ?>',
type: 'POST',
data: {
rowid: rowId,
action: action,
'<?= $this->security->get_csrf_token_name(); ?>': '<?= $this->security->get_csrf_hash(); ?>'
},
dataType: 'json',
success: function(response) {
if (response.status === 'success') {
loadCartItems();
} else {
notyf.error(response.message);
}
},
error: function(xhr, status, error) {
let errorMessage = 'Error updating quantity.';
console.error(errorMessage, ', pkease contact our IT Support');
}
});
}
function removeCartItem(rowId) {
$.ajax({
url: '<?= base_url("cart/remove_item") ?>',
type: 'POST',
data: {
rowid: rowId,
'<?= $this->security->get_csrf_token_name(); ?>': '<?= $this->security->get_csrf_hash(); ?>'
},
dataType: 'json',
success: function(response) {
if (response.status === 'success') {
loadCartItems();
} else {
notyf.error('Gagal menghapus item.');
}
},
error: function() {
console.error('Error removing cart item.');
}
});
}
loadCartItems();
});
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('cart-cta').addEventListener('click', function() {
window.location.href = '<?= base_url("product") ?>';
})
});
</script>