|
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 : |
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QG3RS04MK3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-QG3RS04MK3');
</script>
<style>
/* Style for the validation message */
.error-popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: red;
color: white;
border-radius: 5px;
z-index: 1000;
}
/* Style for the overlay background */
.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
}
</style>
<script>
// Function to show the error popup
function showErrorPopup(message) {
// Set the error message
document.getElementById('error-message').innerText = message;
// Show the error popup and overlay
document.getElementById('error-popup').style.display = 'block';
document.getElementById('overlay').style.display = 'block';
}
// Function to hide the error popup
function hideErrorPopup() {
// Hide the error popup and overlay
document.getElementById('error-popup').style.display = 'none';
document.getElementById('overlay').style.display = 'none';
}
</script>
<!-- Error popup HTML -->
<div style="text-align: center;" id="error-popup" class="error-popup">
<p id="error-message"></p>
<button onclick="hideErrorPopup()">Close</button>
</div>
<!-- Overlay HTML -->
<div id="overlay" class="overlay" onclick="hideErrorPopup()"></div>
<style>
.card {
border: 1px solid black;
}
.table thead th {
border-bottom: unset;
}
.table td,
.table th {
border-top: 1px solid black;
border-bottom: 1px solid black;
}
@media (min-width: 768px) {
#redeemPoint,
#redeemVoucher {
float: none;
}
}
</style>
<script>
function remove_cart_shipping(rowid) {
if (confirm('Are you sure?')) {
$.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_remove_cart',
'type': 'POST',
'data': {
'rowid': rowid,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
/*---success----*/
window.location.href = '';
}
});
}
}
</script>
<?php if (base_url() == 'https://www.laciasmara.com/shop/') : ?>
<style>
/*@media only screen and (min-device-width : 320px) and (max-device-width : 568px) {
.myCart table, .myCart thead, .myCart tbody, .myCart th, .myCart td, .myCart tr {
display: ;
}
}*/
/*div#shipping_result{
overflow-x: auto;
}*/
</style>
<script>
$(document).ready(function() {
if (window.matchMedia('only screen and (min-device-width : 320px) and (max-device-width : 568px)').matches) {
$('div.myCart').removeClass('myCart');
$("table tr td.hidden-xs-down, table tr th.hidden-xs-down").removeClass('hidden-xs-down');
$("table.table").css({
// 'max-width':$("div.container").width()+'px',
// 'width':$("div.container").width()+'px',
'max-width': '558px',
'width': '558px',
});
} else {
//...
}
})
</script>
<?php endif; ?>
<div class="customer_info_box container" style="padding-top: 55px;">
<div class="row customer_info_box_head">
<div class="col-sm-12">
<?php $attributes = [
'name' => 'shipping_post',
]; ?>
<?= form_open('payment/post_payment', $attributes) ?>
<?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?>
<div class="row" style="padding-top: 30px;">
<div class="col-sm-12" style="vertical-align: center; text-align: center;">
<p style="font-size: 16px; vertical-align: center"><a href="<?= base_url(
'register'
) ?>"><strong style="color:<?= $primary_colortheme ?>"><?php if ($this->session->userdata('site_lang') == 'english') {
echo "Sign up";
} else {
echo 'Klik disini';
} ?></strong></a> <?php if ($this->session->userdata('site_lang') == 'english') {
echo 'to be our Friend with Benefits for discounts, points, rewards, special news and tips. Never regret it!';
} else {
echo 'untuk bergabung menjadi FWB. Nikmati potongan diskon, vouchers, rewards, tips dan berita spesial lainnya.';
} ?></p>
</div>
</div>
<?php endif; ?>
<div class="myCart">
<h3><?= ucwords(lang('shippingsubject')) ?></h3>
<?php
/* echo '<pre>';
print_r($this->session->userdata('shipping_cart'));
echo '</pre>'; */
?>
<?php if ($this->session->userdata('shipping_cart')) : ?>
<!-- <p><span id="addressMessage" style="color: red;"></span></p> -->
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('destination')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-4">
<?php
$get_grand_total = 0;
foreach ($this->session->userdata('shipping_cart') as $item) {
$get_grand_total += $item['subtotal'];
}
$q_config_cond = $this->db
->select(
'type_cond_prov_free_shipping, cond_more_prov_free_shipping, cond_less_prov_free_shipping'
)
->from('configuration')
->where('id_configuration', 1)
->get()
->row();
$free_shipping_type = $this->db
->select('free_shipping_type')
->from('configuration')
->where('id_configuration', 1)
->get()
->row()->free_shipping_type;
$condition_freeshipping = false;
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == null) {
if ($this->session->userdata('cart_has_discounted_items') == 'no') {
if ($free_shipping_type == 'region') {
$selected_region_province = $this->db
->select('*')
->from('free_shipping_region')
->where('configuration_id', 1)
->where('province_id', $shipping->shipping_id_province)
->get();
if ($selected_region_province->num_rows() > 0) {
switch ($q_config_cond->type_cond_prov_free_shipping) {
case 'more_than':
if (
$get_grand_total >= $q_config_cond->cond_more_prov_free_shipping
) {
$condition_freeshipping = true;
} else {
$condition_freeshipping = false;
}
break;
case 'less_than':
if (
$get_grand_total <= $q_config_cond->cond_less_prov_free_shipping
) {
$condition_freeshipping = true;
} else {
$condition_freeshipping = false;
}
break;
default:
$condition_freeshipping = true;
break;
}
}
}
}
if ($this->session->userdata('cart_has_discounted_items') == 'yes') {
if ($free_shipping_type == 'region') {
$selected_region_province = $this->db
->select('*')
->from('free_shipping_region')
->where('configuration_id', 1)
->where('province_id', $shipping->shipping_id_province)
->get();
if ($selected_region_province->num_rows() > 0) {
switch ($q_config_cond->type_cond_prov_free_shipping) {
case 'more_than':
if (
$get_grand_total >= $q_config_cond->cond_more_prov_free_shipping
) {
$condition_freeshipping = true;
} else {
$condition_freeshipping = false;
}
break;
case 'less_than':
if (
$get_grand_total <= $q_config_cond->cond_less_prov_free_shipping
) {
$condition_freeshipping = true;
} else {
$condition_freeshipping = false;
}
break;
default:
$condition_freeshipping = true;
break;
}
}
}
}
}
?>
<select style="border-radius: 0;" required id="shipping_province" name="shipping_province" class="form-control" oninvalid="showErrorPopup('<?= ucwords(lang('choose_province')) ?>')">
<option value=""><?= ucwords(lang('choose_province')) ?></option>
<?php foreach ($shipping_provinces as $shipping_province) : ?>
<option value="<?= $shipping_province->rajaongkir_province_id ?>" <?php if (
$shipping_province->rajaongkir_province_id ==
$shipping->shipping_id_province
) : ?> selected <?php endif; ?>><?= ucwords($shipping_province->province) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-sm-4">
<select style="border-radius: 0;" required id="shipping_district" name="shipping_district" class="form-control" oninvalid="this.setCustomValidity('<?= ucwords(lang('choose_district')) ?>')">
<option value=""><?= ucwords(lang('choose_district')) ?>...</option>
<?php if (isset($shipping_district_lists)) : ?>
<?php foreach (
$shipping_district_lists
as $shipping_district
) : ?>
<option value="<?= $shipping_district->rajaongkir_id_district ?>" <?php if (
$shipping_district->rajaongkir_id_district ==
$shipping->shipping_id_district
) : ?> selected <?php endif; ?>><?= ucwords($shipping_district->district) ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
<?php echo '<span style="font-size:10px;">' .
form_error('shipping_district') .
'</span>'; ?>
</div>
<div class="col-sm-4">
<select style="border-radius: 0;" required id="shipping_subdistrict" name="shipping_subdistrict" class="form-control" oninvalid="this.setCustomValidity('<?= ucwords(lang('choose_subdistrict')) ?>')">
<option value=""><?= ucwords(lang('choose_subdistrict')) ?>...</option>
<?php if (isset($shipping_subdistrict_lists)) : ?>
<?php foreach (
$shipping_subdistrict_lists
as $shipping_subdistrict
) : ?>
<option value="<?= $shipping_subdistrict->rajaongkir_id_subdistrict ?>" <?php if (
$shipping_subdistrict->rajaongkir_id_subdistrict ==
$shipping->shipping_id_subdistrict
) : ?> selected <?php endif; ?>><?= ucwords(
$shipping_subdistrict->subdistrict
) ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
<?php echo '<span style="font-size:10px;">' .
form_error('shipping_subdistrict') .
'</span>'; ?>
</div>
</div>
</div>
</div>
<div id="spinnerShipping" style="text-align:center;">
<img width="40" src="<?= base_url(
'uploads/spinner.gif'
) ?>"><br />
Please wait. Reload page...
</div>
<script>
jQuery(document).ready(function() {
jQuery('#spinnerShipping').hide();
jQuery('#shipping_province').change(function() {
jQuery('#shipping_subdistrict').empty(); //to empty select box
var id_shipping_province = jQuery(this).val();
load_shipping_district_ajax(id_shipping_province);
});
jQuery('#shipping_district').change(function() {
var id_shipping_district = jQuery(this).val();
load_shipping_subdistrict_ajax(id_shipping_district);
});
jQuery('#shipping_subdistrict').change(function() {
var id_shipping_province = jQuery('#shipping_province').val();
var id_shipping_district = jQuery('#shipping_district').val();
var id_shipping_subdistrict = jQuery(this).val();
jQuery('#spinnerShipping').show();
reload_shipping_result(id_shipping_province, id_shipping_district, id_shipping_subdistrict);
location.reload();
});
});
function formatIDR(angka, prefix) {
var number_string = angka.toString().replace(/[^,\ ]/g, '').toString(),
split = number_string.split(','),
sisa = split[0].length % 3,
rupiah = split[0].substr(0, sisa),
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
// tambahkan titik jika yang di input sudah menjadi angka ribuan
if (ribuan) {
separator = sisa ? '.' : '';
rupiah += separator + ribuan.join('.');
}
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
return prefix == undefined ? rupiah : (rupiah ? 'IDR ' + rupiah : '');
}
function load_shipping_district_ajax(id_shipping_province) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax' + '/ajax_get_shipping_district',
'type': 'POST',
'data': {
'id_shipping_province': id_shipping_province,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
jQuery('#shipping_district').html(data).focus();
}
});
}
function load_shipping_subdistrict_ajax(id_shipping_district) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax' + '/ajax_get_shipping_subdistrict',
'type': 'POST',
'data': {
'id_shipping_district': id_shipping_district,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
jQuery('#shipping_subdistrict').html(data).focus();
}
});
}
function reload_shipping_result(id_shipping_province, id_shipping_district, id_shipping_subdistrict) {
<?php if ($condition_freeshipping == true) { ?>
var condition_freeshipping = true;
<?php } else { ?>
var condition_freeshipping = false;
<?php } ?>
jQuery.ajax({
'url': '<?= base_url() ?>' + 'shipping' + '/ajax_reload_shipping_result',
'type': 'POST',
'data': {
'id_shipping_province': id_shipping_province,
'condition_freeshipping': condition_freeshipping,
'id_shipping_district': id_shipping_district,
'id_shipping_subdistrict': id_shipping_subdistrict,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
jQuery('#shipping_result').empty();
// console.log(data);
jQuery('#shipping_result').html(data);
jQuery('#spinner<?= $count ?>').hide();
}
});
}
</script>
<?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('name')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<input type="text" id="shippingName" name="name" required style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('fullname')
) ?>*">
</div>
</div>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('phone')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<?php
$data = [
'name' => 'phone',
'class' => 'form-control',
'required' => 'required',
'type' => 'number',
'id' => 'shippingPhone',
'placeholder' => ucwords(lang('phone_number')),
];
echo form_input($data);
echo '<span style="font-size:12px;">' . form_error('phone') . '</span>';
?>
</div>
</div>
<!--<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p>Tanggal Lahir dan Gender <sup>*</sup></p>
</div>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-6">
// <?php
// $data = [
// 'name' => 'birthday',
// 'class' => 'form-control registerdatepicker',
//
// 'type' => 'date',
// 'required' => 'required',
// ];
// if(!empty($customers->birthday)) {
// $data['value'] = date('d-m-Y', strtotime($customers->birthday));
// }
// echo form_input($data);
//
?>
//<?= form_error('birthday') ?>
</div>
<div class="col-sm-6">
// <?php
// $options = [
// 'male' => 'Male',
// 'female' => 'Female',
//];
//echo form_dropdown('sex_type', $options, 'Male', 'class="form-control"');
//
?>
</div>
</div>
</div>
</div>-->
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('email')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<input type="text" id="email" name="email" required style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('emailadd')
) ?>*">
</div>
</div>
<?php endif; ?>
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
$customer_billing_address = $this->db->select('address')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->address;
$customer_billing_province_id = $this->db->select('id_province')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->id_province;
$customer_billing_district_id = $this->db->select('id_district')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->id_district;
$customer_billing_subdisctrict_id = $this->db->select('id_subdistrict')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->id_subdistrict;
$customer_billing_province = $this->db->select('province')->from('indonesia_provinces')->where('id_indonesia_provinces', $customer_billing_province_id);
$customer_billing_province = $this->db->get()->row()->province;
$customer_billing_district = $this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', $customer_billing_district_id);
$customer_billing_district = $this->db->get()->row()->district;
$customer_billing_subdisctrict = $this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', $customer_billing_subdisctrict_id);
$customer_billing_subdisctrict = $this->db->get()->row()->subdistrict;
if ($reseller_id == NULL) : ?>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('deliv_address')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<textarea name="address" id="shipping_address" required oninvalid="this.setCustomValidity('Insert <?= ucwords(lang('deliv_address')) ?>')" style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('deliv_address')
) ?>*"><?= $shipping->shipping_address ?></textarea>
<input type="checkbox" id="shipping_insurance" name="shipping_insurance"><label for="shipping_insurance"> <?= ucwords(lang('shipping_insurance')) ?></label>
<input name="insurance_cost" id="insurance_cost" type="hidden" value="<?= ($get_grand_total * 0.2 / 100) + 5000; ?>">
<input name="insurance_status" id="insurance_status" type="hidden" value="No">
</div>
</div>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p></p>
</div>
<div class="col-sm-8">
<p><?= ucwords(lang('for_gift')) ?> <input type="checkbox" id="gifts" name="gifts" onchange="toggleGiftInputs()"></p>
<input type="text" id="receiver_name" name="receiver_name" style="border-radius: 0; display: none;" class="form-control" placeholder="<?= ucwords(
lang('for_gift_name')
) ?>*">
<br>
<input type="text" id="receiver_phone" name="receiver_phone" style="border-radius: 0; display: none;" class="form-control" placeholder="<?= ucwords(
lang('for_gift_phone')
) ?>*">
</div>
</div>
<script>
function toggleGiftInputs() {
var giftsCheckbox = document.getElementById('gifts');
var receiverNameInput = document.getElementById('receiver_name');
var receiverPhoneInput = document.getElementById('receiver_phone');
if (giftsCheckbox.checked) {
receiverNameInput.style.display = 'block';
receiverPhoneInput.style.display = 'block';
} else {
receiverNameInput.style.display = 'none';
receiverPhoneInput.style.display = 'none';
}
}
</script>
<?php else : ?>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('deliv_address')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<textarea name="address" id="shipping_address" required style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('deliv_address')
) ?>*"><?= $shipping->shipping_address ?></textarea>
<input type="checkbox" id="shipping_insurance" name="shipping_insurance"><label for="shipping_insurance"> <?= ucwords(lang('shipping_insurance')) ?></label>
<input name="insurance_cost" id="insurance_cost" type="hidden" value="<?= ($get_grand_total * 0.2 / 100) + 5000; ?>">
<input name="insurance_status" id="insurance_status" type="hidden" value="No">
</div>
</div>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('billing_address')) ?><sup>*</sup></p>
</div>
<div class="col-sm-8">
<textarea readonly name="billing address" id="billing_address" required style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('deliv_address')
) ?>*"><?= $customer_billing_address ?>, Kec.<?= $customer_billing_subdisctrict ?>, <?= $customer_billing_district ?>, <?= $customer_billing_province ?></textarea> *<strong> Alamat Penagihan Bisa di edit di pengaturan akun.</strong>
</div>
</div>
<?php endif; ?>
<div class="row" style="padding-top: 20px;">
<div class="col-sm-2">
<p><?= ucwords(lang('customer_note')) ?></p>
</div>
<div class="col-sm-8">
<textarea name="customer_note" id="customer_note" style="border-radius: 0; min-height:50px;" class="form-control" placeholder="<?= ucwords(
lang('customer_note_text')
) ?>"></textarea>
</div>
</div>
<div class="row" style="padding-top: 20px; display: none;">
<div class="col-sm-2">
<p><?= ucwords(lang('postcode')) ?></p>
</div>
<div class="col-sm-8">
<input type="text" id="shipping_postcode" name="postcode" style="border-radius: 0;" class="form-control" placeholder="<?= ucwords(
lang('postcode_enter')
) ?>..." value="<?= $shipping->shipping_postcode ?>">
</div>
</div>
<br><br>
<div id="shipping_result">
<div class="table-responsive">
<table class="table" style="border-top:1px solid #999999; border-bottom:1px solid #999999; width: 100%;">
<thead>
<tr>
<th><?= ucwords(lang('product_name')) ?></th>
<th class="hidden-xs-down"><?= ucwords(lang('price')) ?></th>
<th class="hidden-xs-down"><?= ucwords(lang('quantity')) ?></th>
<th class="hidden-xs-down"><?= ucwords(lang('sent')) ?></th>
<th class="hidden-xs-down"><?= ucwords(lang('shipping_method')) ?></th>
<th class="hidden-xs-down">Sub Total</th>
<th class="hidden-xs-down"></th>
</tr>
</thead>
<tbody>
<?php $count = 0; ?>
<?php $grand_total = 0; ?>
<?php $total_shipping_fee = 0; ?>
<?php foreach ($this->session->userdata('shipping_cart') as $rowid => $item) : ?>
<?php $count++; ?>
<?php
$real_rowid = null;
foreach ($this->cart->contents() as $real_key) {
if ((int) $real_key['id'] == (int) $item['id']) {
$real_rowid = $real_key['rowid'];
}
}
?>
<tr>
<td class="hidden-xs-down">
<?= strtoupper($item['name']) ?><br>
<?= get_attribute_name(
$item['attribute_detail_ids']
) ?><br><span style="font-size: 12px;"><?= $item['sku'] ?></span>
</td>
<td class="hidden-xs-down">
IDR <?= number_format($item['price']) ?><br>
<?= $item['indent_message'] ?>
</td>
<td style="width: 14%;" class="hidden-xs-down">
<?php
error_reporting(0);
$fs_cek_product = $this->db
->select('id')
->from('flashsale_products')
->where('product_id', $item['id'])
->where(
'flashsale_id',
$this->session->userdata('flashsale_id_active')
)
->get()
->row()->id;
if ($fs_cek_product != null) : ?>
<div class="count-input space-bottom" style="display: inline-block;">
<input style="text-align: center;" readonly="readonly" class="quantity productQuantity<?= $count ?>" type="text" name="quantity" value="<?= $item['qty'] ?>" />
</div>
<?php else : ?>
<?php
$css_btn_incr = "margin-left:-9px;";
if ($this->session->userdata('customer')) :
$css_btn_incr = "margin-left:-17px;"; ?>
<?php
endif;
?>
<div class="root_incr-btn count-input space-bottom" style="display: flex; justify-content: space-between;position: relative;">
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == NULL) : ?>
<div class="div_incr-btn1" style="margin-top: 2px; z-index:1;position: absolute;margin-left: 8px;">
<a style="padding-bottom: 5px; padding-top: 2px;" class="incr-btn btnMin<?= $count ?>" data-action="decrease" href="#">–</a>
</div>
<?php else : ?>
<?php endif; ?>
<div class="div_incr-btn2" style="width: 100%;">
<input style="width: 104%; text-align: center;" readonly="readonly" class="quantity productQuantity<?= $count ?>" type="text" name="quantity" value="<?= $item['qty'] ?>" />
</div>
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == NULL) : ?>
<div class="div_incr-btn3" style="margin-top: 2px; <?= $css_btn_incr ?>">
<a style="padding-bottom: 5px; padding-top: 2px;" class="incr-btn btnAdd<?= $count ?>" data-action="increase" href="#">+</a>
</div>
<?php else : ?>
<?php endif; ?>
</div>
<?php endif;
?>
<p class="noStock<?= $count ?>" style="color:red;"><?= $this->session->flashdata(
'no_stock' . $rowid
) ?></p>
</td>
<td class="hidden-xs-down"><?= ucwords($item['warehouse_name']) ?>
</td>
<td>
<ul id="shippingNameBlock<?= $count ?>" style="list-style: none; padding-left: 0;">
<?php $count_shipping = 0; ?>
<?php foreach ($item['shipping_method_ids'] as $shipping_id) : ?>
<?php $count_shipping = $count_shipping + 1; ?>
<?php if ($shipping_id == 2) : ?>
<?php
//get self delivery fee from configuration table
$this->db
->select('shopdelivery_fee')
->from('configuration')
->where('id_configuration', 1);
$shopdelivery_fee = $this->db->get()->row()->shopdelivery_fee;
$shipping_name = 'Express Courier';
// $shipping_name = '2 Hour Delivery';
$total_shipping_fee = $shopdelivery_fee;
?>
<?php else : ?>
<?php
$shipping_info = calculate_shipping_fee(
$shipping_id,
$item['warehouse_id'],
$item['product_id'],
$item['id'],
$item['qty'],
$shipping->shipping_id_subdistrict
);
$shipping_name = $shipping_info['shipping_name'];
$total_shipping_fee = $shipping_info['total_shipping_fee'];
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($shipping_id == 3) {
if ($reseller_id == null) {
$shipping_name = 'Regular';
} else {
$customer_id = $this->db->select('id_customers')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->id_customers;
switch ($customer_id) {
case 2619:
$shipping_name_byuser = 'Gosend Instant';
break;
case 2618:
$shipping_name_byuser = 'Private Courier';
break;
case 2617:
$shipping_name_byuser = 'Kurir Test';
break;
case 2010:
$shipping_name_byuser = 'Private Courier';
break;
case 2288:
$shipping_name_byuser = 'Gosend Instant';
break;
case 2620:
$shipping_name_byuser = 'Trucking';
break;
case 2530:
$shipping_name_byuser = 'Trucking';
break;
default:
$shipping_name_byuser = 'Reguler';
break;
}
$shipping_name = $shipping_name_byuser;
}
}
?>
<?php endif; ?>
<?php if (
$total_shipping_fee > 0 ||
isset($shipping_info['free_shipping_applied'])
) : ?>
<li>
<input type="radio" class="shipping_method<?= $rowid ?>" name="shipping_method<?= $rowid ?>" value="<?= $shipping_id ?>" <?php if ($item['chosen_shipping_id'] == $shipping_id) : ?> <?php $active_shipping_fee = $total_shipping_fee; ?> checked <?php endif; ?>> <?= ucwords($shipping_name) ?>
<?php if (($condition_freeshipping == true)) :
$penampungan = $total_shipping_fee;
$max_shipping_free = 100000;
$total_shipping_fee = $total_shipping_fee - $max_shipping_free; ?>
<?php if (($total_shipping_fee <= 0)) : ?>
(<?= ucwords(lang('free')) ?>)
<?php else : ?>
(IDR <?=
number_format(
$total_shipping_fee
)
?>)
<?php endif; ?>
<?php else : ?>
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == NULL) : ?>
<?php if ($shipping_id == 5) : ?>
(TBC)
<?php else : ?>
(IDR <span id="shippingFee<?= $count_shipping ?>"><?= number_format(
$total_shipping_fee
) ?></span>)
<?php endif; ?>
<?php else : ?>
(IDR <span id="shippingFee<?= $count_shipping ?>"><?= number_format(
$final_total_shipping_fee
) ?></span>)
<?php endif; ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</td>
<td class="hidden-xs-down">
IDR <span id="subTotal<?= $count ?>"><?php echo number_format(
$item['price'] * $item['qty']
); ?></span>
</td>
<td class="hidden-xs-down" style="padding-left: 0px;">
<a title="Hapus" onclick="remove_cart_shipping('<?= $real_rowid ?>');" href="#">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>
<!-- <?php
/*$total_shipping_fee = $total_shipping_fee + $item['shipping_fee'];*/
?> -->
<?php $grand_total = $grand_total + $item['subtotal']; ?>
<?php endforeach; ?>
</form>
</tbody>
</table>
</div>
<div class="row">
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == NULL) : ?>
<div class="col-sm-6" style="padding-bottom: 15px;">
<div class="row">
<?php if (
$this->session->userdata('customer') &&
$this->session->userdata('customer')['customer_type'] == 'regular'
) : ?>
<div class="col-sm-12">
<p><? ucwords(lang('you_have')) ?> <?= $current_point ?> points. 1 point redeem IDR <?= $point_rewards->conversion ?></p>
</div>
<?php endif; ?>
<!-- Input Point -->
<div class="col-sm-6 col-6">
<input class="form-control" type="number" id="point" placeholder="<?= strtoupper(
lang('point_rewards')
) ?>" <?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?> readonly disabled <?php endif; ?>>
<p id="error_point" style="color: red"></p>
<p id="error_point" style="color: red"></p>
</div>
<div class="col-sm-6 col-6">
<a <?php if (
$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?> readonly disabled <?php endif; ?> class="btn btn-primary btn-buy" id="redeemPoint" style="width: 150px;float: none;"><?= strtoupper(
lang('redeem')
) ?></a>
<?php if (
$this->session->userdata('customer') &&
$this->session->userdata('customer')['customer_type'] == 'regular'
) : ?>
<span id="spinnerPoint" style="position: absolute;"><img width="40" src="<?= base_url(
'uploads/spinner.gif'
) ?>"></span>
<?php endif; ?>
</div>
</div>
<!-- Input Voucher -->
<?php
// Ambil customer_id dan status is_first
$id = $this->session->userdata('customer')['customer_id'];
$userfirst = $this->db->select('is_first')->from('customers')->where('id_customers', $id)->get()->row()->is_first;
?>
<div class="row">
<div class="col-sm-6 col-6">
<input class="form-control" type="text" id="voucher" placeholder="VOUCHER" <?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?> readonly disabled <?php endif; ?>>
<p id="error_voucher" style="color: red"></p>
<p id="alert_sale_item" style="color: red"></p>
</div>
<div class="col-sm-6 col-6">
<script>
console.log('<?= $this->session->userdata('cart_has_discounted_items') ?>')
</script>
<a <?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?> readonly disabled <?php endif; ?> <?php if ($this->session->userdata('cart_has_discounted_items') == 'no' || $this->session->userdata('cart_has_discounted_items') == NULL) : ?> class="btn btn-primary btn-buy" id="redeemVoucher" style="width: 150px;float: none;" <?php endif ?> <?php if ($this->session->userdata('cart_has_discounted_items') == 'yes') : ?> class="btn btn-primary btn-buy" id="alertsale" style="width: 150px;float: none;" <?php endif ?>><?= strtoupper(
lang('redeem')
) ?>
</a>
<?php if (
$this->session->userdata('customer') &&
$this->session->userdata('customer')['customer_type'] == 'regular'
) : ?>
<span id="spinnerVoucher" style="position: absolute;"><img width="40" src="<?= base_url(
'uploads/spinner.gif'
) ?>"></span>
<?php endif; ?>
</div>
<?php if (
!$this->session->userdata('customer') ||
$this->session->userdata('customer')['customer_type'] == 'guest'
) : ?>
<div class="col-sm-12">
<p> <?php if ($this->session->userdata('site_lang') == 'english') {
echo "Sign up now to use voucher and enjoy exclusive benefits!";
} else {
echo 'Daftar sekarang untuk menggunakan voucher dan menikmati keuntungan eksklusif! ';
} ?> <a href="<?= base_url(
'register'
) ?>" style="text-decoration: none; font-weight: bold; color:<?= $primary_colortheme ?>"><?php if ($this->session->userdata('site_lang') == 'english') {
echo "Sign up here";
} else {
echo 'Gabung sekarang';
} ?></a> </p>
</div>
<?php endif; ?>
</div>
<input type="hidden" id="voucherprice_input">
<input type="hidden" id="pointrewards_input">
</div>
<?php else : ?>
<div class="col-sm-6" style="padding-bottom: 15px;">
<div class="row">
<div class="col-sm-12">
<p>Credit : IDR. <?= number_format($current_point, 0, ',', '.'); ?> </p>
</div>
<div class="col-sm-6 col-6">
<input class="form-control" type="number" id="point" placeholder="<?= ucwords(lang('credit_placeholder')) ?>">
<p id="error_point" style="color: red"></p>
<p id="error_point" style="color: red"></p>
</div>
<div class="col-sm-6 col-6">
<a class="btn btn-primary btn-buy" id="redeemPoint" style="width: 150px;float: none;"><?= strtoupper(
lang('redeem')
) ?></a>
</div>
</div>
</div>
<?php endif; ?>
<div class="col-sm-6">
<style type="text/css">
.tk_line {
float: right;
width: 70%;
border-top: 1px solid black;
}
@media screen and (max-width: 768px) {
.tk_line {
width: 100%;
}
}
</style>
<div class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span><?= ucwords(lang('product_total')) ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<p><span>IDR </span><span id="totalItemAmount"><?= number_format(
$grand_total
) ?></span></p>
</div>
</div>
<div id="voucherBlock" class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span>Voucher <span id="voucherdiscount"></span>:</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<p><span>IDR </span><span id="voucherprice"><?= number_format(0) ?></span></p>
</div>
</div>
<div id="pointrewardBlock" class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<?php if ($reseller_id == NULL) : ?>
<p><span><?= ucwords(lang('point_rewards')) ?> :</span></p>
<?php else : ?>
<p><span>Credit :</span></p>
<?php endif ?>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<p><span>IDR </span><span id="pointrewards"><?= number_format(0) ?></span></p>
</div>
</div>
<?php
$id = $this->session->userdata('customer')['customer_id'];
$userfirst = $this->db->select('is_first')->from('customers')->where('id_customers', $id)->get()->row()->is_first;
// Inisialisasi diskon default 5%
$disc_first = 0.05;
// Cek referral dari data customer
$customer_referral = $this->db->select('refferal')
->from('customers')
->where('id_customers', $id)
->get()
->row()->refferal;
// Cek kategori affiliator berdasarkan referral customer
if (!empty($customer_referral)) {
$affiliator = $this->db->select('kategori')
->from('affiliator_register')
->where('referral', $customer_referral)
->get()
->row();
if ($affiliator) {
if ($affiliator->kategori == 'asmaradoor') {
$disc_first = 0.1; // Diskon 10% untuk kategori asmaradoor
} elseif ($affiliator->kategori == 'asmarasana') {
$disc_first = 0.05; // Diskon 5% untuk kategori asmarasana
}
}
}
// Jika tidak ada referral di data customer, cek referral dari link
if (empty($customer_referral) && !empty($this->session->userdata('referral'))) {
$referral_code = $this->session->userdata('referral');
$referral_affiliator = $this->db->select('kategori')
->from('affiliator_register')
->where('referral', $referral_code)
->get()
->row();
if ($referral_affiliator) {
if ($referral_affiliator->kategori == 'asmaradoor') {
$disc_first = 0.1; // Diskon 10% untuk kategori asmaradoor
} elseif ($referral_affiliator->kategori == 'asmarasana') {
$disc_first = 0.05; // Diskon 5% untuk kategori asmarasana
}
}
}
$get_grand_total = 0;
foreach ($this->session->userdata('shipping_cart') as $item) {
$get_grand_total += $item['subtotal'];
}
// if (empty($this->session->userdata('referral'))) {
// $disc_first = 0.05;
// } else {
// if ($this->session->userdata('referral') == 'laciput') {
// $disc_first = 0.05;
// } else {
// $disc_first = 0.1;
// }
// }
if (($this->session->userdata('cart_has_discounted_items') == 'no' || $this->session->userdata('cart_has_discounted_items') == NULL) && $userfirst == '0') {
$first_purchase = $get_grand_total * $disc_first;
$discount_label = ucwords(lang('firstpur'));
?>
<div id="firstpurchase" class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span><?= $discount_label ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<p><span>IDR -<?= number_format($first_purchase); ?></span></p>
</div>
</div>
<?php
}
?>
<div class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span><?= ucwords(lang('shipping_fee')) ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<?php if ($condition_freeshipping == true) :
$penampungan2 = $penampungan;
$max_shipping_free = 100000;
$penampungan2 = $penampungan2 - $max_shipping_free; ?>
<?php if (($penampungan2 <= 0)) : ?>
<?= ucwords(lang('free')) ?>
<?php else : ?>
<p><span id="spn_totalshipping">IDR </span><span id="totalShippingFee"><?= number_format(
$penampungan2
) ?></span></p>
<?php endif; ?>
<?php else : ?>
<?php if ($no_of_indent > 0 && $no_of_instock == 0) : ?>
<?php if ($total_shipping_fee == 0) : ?>
<p><?= ucwords(lang('free')) ?></p>
<?php else : ?>
<p>TBC</p>
<?php endif; ?>
<?php else : ?>
<p><span id="spn_totalshipping">IDR </span><span id="totalShippingFee"><?= number_format(
$final_total_shipping_fee - $total_indent_shipping_fee
) ?></span></p>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<div id="freeshippingBlock" class="row" style="height: 25px;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span><?= ucwords(lang('free_ship')) ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<?php if ($free_shipping_fee >= 0) : ?>
<?php if (isset($min_transaction)) : ?>
<?php if ($grand_total >= $min_transaction) : ?>
<?php $free_shipping_fee = $free_shipping_fee; ?>
<?php else : ?>
<?php $free_shipping_fee = 0; ?>
<?php endif; ?>
<?php endif; ?>
<p><span>IDR -</span><span id="totalFreeShippingFee"><?= number_format(
$free_shipping_fee
) ?></span></p>
<?php endif; ?>
</div>
</div>
<div id="shippinginsuranceBlock" class="row" style="height: 25px; display: none;">
<div class="col-md-8 col-sm-6 col-6" style="text-align: right;">
<p><span><?= ucwords(lang('shipping_insurance')) ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;">
<p><span>IDR
<?= number_format(($get_grand_total * 0.2 / 100) + 5000) ?></span></p>
</div>
</div>
<?php
$finalshippingfee = 0;
$calculate_finalshippingfee =
$final_total_shipping_fee - $free_shipping_fee;
if ($calculate_finalshippingfee > 0) {
$finalshippingfee = $calculate_finalshippingfee;
}
?>
<div class="row indentInformation" style="font-weight: bold;text-align: right;padding-top: 5px;height: 45px">
<div class="col-md-8 col-sm-6 col-6">
<p><?= ucwords(lang('downpayment')) ?> :</p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;font-weight: bold;">
<p><span style="font-size:100%;">IDR <span id="indentRemaining"><?= number_format(
$total_downpayment
) ?></span></p>
</div>
</div>
<div class="row" style="height: 5px;">
<div class="col-sm-12"> <br>
<hr class="tk_line">
</div>
</div>
<span id="firsttotal" style="display: none;"></span>
<span id="finalshippingfee" style="display: none;"></span>
<?php
$css_padding = '5px';
if (
base_url() == "https://www.demo2.tokodaku.com/" ||
base_url() == "https://www.demo3.tokodaku.com/"
) {
$css_padding = '15px';
}
?>
<div class="row" style="
font-weight: bold;
text-align: right;
padding-top: <?= $css_padding ?>;
height: 25px;
font-size:1.2rem">
<div class="col-md-8 col-sm-6 col-6">
<br>
<p><span><?= ucwords(lang('total_price')) ?> :</span></p>
</div>
<div class="col-md-4 col-sm-6 col-6" style="text-align: right;font-weight: bold;">
<br>
<p><span style="font-size:100%;">IDR</span> <span id="grandTotal">
<?php if ($condition_freeshipping == true) : ?>
<?php
$finalshippingfee = $penampungan - 100000;
$total_indent_shipping_fee = 0;
if (($finalshippingfee <= 0)) {
$finalshippingfee = 0;
} else {
$finalshippingfee = $finalshippingfee;
}
?>
<?php endif; ?>
<?= number_format(
$grand_total +
$finalshippingfee -
$total_indent_shipping_fee -
$total_indent_amount +
$total_downpayment - $first_purchase
) ?>
</span>
</p>
</div>
</div>
<p style="margin-top: 35px; margin-bottom: 50px; font-size: 15px; font-weight: bold; text-align: right;" class="clearfix">
<style>
.btn-buy {
width: 250px;
float: right;
margin-right: 0px;
margin-top: 0px;
}
input[type=checkbox] {
align-items: right;
}
</style>
<br>
<?php
$reseller_id = $this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id'])->get()->row()->reseller_id;
if ($reseller_id == NULL) : ?>
<input type="checkbox" id="terms" name="terms" required> <label for="terms"><a href="#myModalTOC" data-toggle="modal" style="color:<?= $primary_colortheme; ?>"><?= ucwords(lang('term_condition')); ?></a></label>
<br>
<button id="lanjutPembayaran" name="lanjutPembayaran" type="submit" class="btn btn-primary buyButton btn-buy"><?= ucwords(lang('payment')) ?></button>
<img style="display: none; float: right;" class="lanjutPembayaran_spinner" width="40" src="<?= base_url('uploads/spinner.gif') ?>">
<?php else : ?>
<?php
$get_grand_total = 0;
$reseller_tier_config = $this->db->select('minimum_order')->from('resellers')->where('id_resellers', $reseller_id)->get()->row()->minimum_order;
foreach ($this->session->userdata('shipping_cart') as $item) {
$get_grand_total += $item['subtotal'];
}
if ($get_grand_total >= $reseller_tier_config) : ?>
<input type="checkbox" id="terms" name="terms" required title="<?= ucwords(lang('required_term_condition')) ?>"> <label for="terms"><a href="#myModalTOC" data-toggle="modal" style="color:<?= $primary_colortheme; ?>"><?= ucwords(lang('term_condition')); ?></a></label>
<br>
<button id="lanjutPembayaran" name="lanjutPembayaran" type="submit" class="btn btn-primary buyButton btn-buy"><?= ucwords(lang('payment')) ?></button>
<img style="display: none; float: right;" class="lanjutPembayaran_spinner" width="40" src="<?= base_url('uploads/spinner.gif') ?>">
<?php else : ?>
<input type="checkbox" id="terms" name="terms" required> <label for="terms"><a href="#myModalTOC" data-toggle="modal" style="color:<?= $primary_colortheme; ?>"><?= ucwords(lang('term_condition')); ?></a></label>
<br>
<button id="minimal8juta" name="minimal8juta" type="button" class="btn btn-primary btn-buy"><?= ucwords(lang('payment')) ?></button>
<?php endif; ?>
<?php endif; ?>
</p>
</div>
</div>
</div>
<!-- Modal Minimal Belanja -->
<div class="modal fade" id="ModalMinimalBelanja" tabindex="-1" aria-labelledby="ModalMinimalBelanjaLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalMinimalBelanjaLabel">Belanja Minimal 8 Juta Rupiah</h5>
</div>
<div class="modal-body">
<p>Silakan kembali berbelanja untuk mencapai minimal pembelian sebesar 8 juta rupiah.</p>
</div>
<div class="modal-footer">
<a href="<?= base_url(); ?>"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Kembali Berbelanja</button></a>
</div>
</div>
</div>
</div>
<script>
document.getElementById("minimal8juta").addEventListener("click", function() {
$('#ModalMinimalBelanja').modal('show');
});
</script>
<script>
jQuery(document).ready(function() {
<?php if ($contain_indent_product == 'no') : ?>
jQuery('.indentInformation').hide();
<?php endif; ?>
//initially hide point reward and voucher block...
jQuery('#pointrewardBlock').hide();
jQuery('#voucherBlock').hide();
<?php if ($free_shipping_fee == 0) : ?>
jQuery('#freeshippingBlock').hide();
<?php endif; ?>
});
</script>
<?php $count = 0; ?>
<?php foreach ($this->session->userdata('shipping_cart') as $rowid => $item) : ?>
<?php $count++; ?>
<script>
jQuery(document).ready(function() {
jQuery('#spinner<?= $count ?>').hide();
//dont use click, use .on to handle dynamic elements loaded by ajax
<?php if ($fs_cek_product == null) : ?>
jQuery(document).on('click', '.btnMin<?= $count ?>', function(e) {
e.preventDefault();
jQuery('.buyButton').attr('disabled', true);
jQuery('.btnMin<?= $count ?>').attr('disabled', true);
jQuery('.btnAdd<?= $count ?>').attr('disabled', true);
jQuery('#spinner<?= $count ?>').show();
var qty = jQuery('.productQuantity<?= $count ?>').val();
qty--;
if (qty == 0) {
qty = 1;
}
jQuery('.productQuantity<?= $count ?>').val(qty);
ajax_check_stock<?= $count ?>(qty);
ajax_change_shipping_fee<?= $count ?>(qty);
ajax_get_subtotal<?= $count ?>(qty, function() {
var province = jQuery('#shipping_province').val();
var subdistrict = jQuery('#shipping_subdistrict').val();
ajax_get_grandtotal<?= $count ?>(qty, subdistrict, province);
});
});
jQuery(document).on('click', '.btnAdd<?= $count ?>', function(e) {
e.preventDefault();
jQuery('.buyButton').attr('disabled', true);
jQuery('.btnMin<?= $count ?>').attr('disabled', true);
jQuery('.btnAdd<?= $count ?>').attr('disabled', true);
jQuery('.shipping_method<?= $rowid ?>').attr('disabled', true);
jQuery('#spinner<?= $count ?>').show();
var qty = jQuery('.productQuantity<?= $count ?>').val();
qty++;
jQuery('.productQuantity<?= $count ?>').val(qty);
ajax_check_stock<?= $count ?>(qty);
ajax_change_shipping_fee<?= $count ?>(qty);
ajax_get_subtotal<?= $count ?>(qty, function() {
var province = jQuery('#shipping_province').val();
var subdistrict = jQuery('#shipping_subdistrict').val();
ajax_get_grandtotal<?= $count ?>(qty, subdistrict, province);
});
});
<?php endif; ?>
jQuery(document).on('click', '.shipping_method<?= $rowid ?>', function() {
jQuery('.buyButton').attr('disabled', true);
jQuery('.btnMin<?= $count ?>').attr('disabled', true);
jQuery('.btnAdd<?= $count ?>').attr('disabled', true);
jQuery('.shipping_method<?= $rowid ?>').attr('disabled', true);
jQuery('#spinner<?= $count ?>').show();
var qty = jQuery('.productQuantity<?= $count ?>').val();
//jQuery('.productQuantity<?= $count ?>').val(qty);
ajax_get_subtotal<?= $count ?>(qty, function() {
var province = jQuery('#shipping_province').val();
var subdistrict = jQuery('#shipping_subdistrict').val();
ajax_get_grandtotal<?= $count ?>(qty, subdistrict, province);
});
});
});
function ajax_check_stock<?= $count ?>(qty) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_check_stock_shipping',
'type': 'POST',
'data': {
'qty': qty,
'warehouse_id': <?= $item['warehouse_id'] ?>,
'item_id': <?= $item['id'] ?>,
'product_id': <?= $item['product_id'] ?>,
'is_backorder': '<?= $item['is_backorder'] ?>',
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
if (data) {
/*---if stock not enough----*/
jQuery('.noStock<?= $count ?>').html(data);
};
}
});
}
function ajax_change_shipping_fee<?= $count ?>(qty) {
//check selected shipping method
var selected_shipping_method_id;
selected_shipping_method_id = jQuery('input[name=shipping_method<?= $rowid ?>]:checked').val();
var province = jQuery('#shipping_province').val();
var currentRequest1 = null;
currentRequest1 = jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_change_shipping_fee',
'type': 'POST',
'data': {
// 'no_of_indent' : <?= $no_of_indent ?>,
// 'no_of_instock' : <?= $no_of_instock ?>,
// 'shipping_id' : <?= $shipping_id ?>,
'province': province,
'qty': qty,
'price': <?= $item['price'] ?>,
'rowid': '<?= $rowid ?>',
'shipping_method_ids': '<?= implode(
",",
$item["shipping_method_ids"]
) ?>',
'selected_shipping_method_id': selected_shipping_method_id,
'warehouse_id': <?= $item['warehouse_id'] ?>,
'shipping_id_subdistrict': <?= $shipping->shipping_id_subdistrict ?>,
'sub_total': <?= $item['subtotal'] ?>,
'product_id': <?= $item['product_id'] ?>,
'item_id': <?= $item['id'] ?>,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
beforeSend: function() {
if (currentRequest1 != null) {
currentRequest1.abort();
}
},
'success': function(data) {
if (data) {
jQuery('#shippingNameBlock<?= $count ?>').html(data);
};
}
});
}
function ajax_get_subtotal<?= $count ?>(qty, grand_total) {
//check selected shipping method
var selected_shipping_method_id;
selected_shipping_method_id = jQuery('input[name=shipping_method<?= $rowid ?>]:checked').val();
//check selected shipping method
var currentRequest2 = null;
currentRequest2 = jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_get_subtotal',
'type': 'POST',
'data': {
'qty': qty,
'price': <?= $item['price'] ?>,
'rowid': '<?= $rowid ?>',
'selected_shipping_method_id': selected_shipping_method_id,
'warehouse_id': <?= $item['warehouse_id'] ?>,
'shipping_id_subdistrict': <?= $shipping->shipping_id_subdistrict ?>,
'product_id': <?= $item['product_id'] ?>,
'item_id': <?= $item['id'] ?>,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
beforeSend: function() {
if (currentRequest2 != null) {
currentRequest2.abort();
}
},
'success': function(data) {
if (data) {
jQuery('#subTotal<?= $count ?>').html(data);
grand_total();
};
}
});
}
function ajax_get_grandtotal<?= $count ?>(qty, subdistrict, province) {
//check selected shipping method
var currentRequest3 = null;
currentRequest3 = jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_get_grandtotal',
'type': 'POST',
'data': {
'using_ajax': true,
'province': province,
'subdistrict': subdistrict,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
beforeSend: function() {
if (currentRequest3 != null) {
currentRequest3.abort();
}
},
'success': function(data) {
if (data) {
var total = JSON.parse(data);
var indent_remaining = total.indent_remaining.toString().replace('-', '');
jQuery('#totalItemAmount').html(total.total_item_amount);
jQuery('#firsttotal').html(total.total_item_amount);
if (total.condition_freeshipping == true) {
jQuery('#spn_totalshipping').html('');
jQuery('#totalShippingFee').html("<?= ucwords(lang('free')), ucwords(lang('max_shipping_disc')) ?>");
} else {
jQuery('#totalShippingFee').html(total.total_shipping_fee);
}
jQuery('#totalFreeShippingFee').html(total.total_free_shipping_fee);
jQuery('#finalshippingfee').html(total.finalshippingfee);
jQuery('#grandTotal').html(total.grand_total);
jQuery('#indentRemaining').html(indent_remaining);
jQuery('#indentShippingFee').html(total.indent_shipping_fee);
jQuery('.buyButton').attr('disabled', false);
jQuery('.btnMin<?= $count ?>').attr('disabled', false);
jQuery('.btnAdd<?= $count ?>').attr('disabled', false);
jQuery('.shipping_method<?= $rowid ?>').attr('disabled', false);
jQuery('#spinner<?= $count ?>').hide();
jQuery('#voucher').val('');
jQuery('#voucherprice_input').val(0);
jQuery('#point').val('');
jQuery('#pointrewards_input').val(0);
jQuery('#voucherdiscount').html('')
jQuery('#voucherprice').html('0');
jQuery('#pointrewards').html('0');
};
}
});
}
</script>
<?php endforeach; ?>
<?php if (
$this->session->userdata('customer') &&
$this->session->userdata('customer')['customer_type'] == 'regular'
) : ?>
<script>
jQuery(document).ready(function() {
jQuery('#spinnerVoucher').hide();
jQuery('#spinnerPoint').hide();
jQuery("#redeemVoucher").click(function() {
jQuery('#spinnerVoucher').show();
var voucher = jQuery("#voucher").val();
var isFirst = <?= $userfirst ?>;
if (isFirst == 0) {
jQuery('#error_voucher').html('Kamu sudah mendapatkan potongan untuk pembelian pertama');
jQuery('#spinnerVoucher').hide();
return;
}
if (voucher == '') {
jQuery('#error_voucher').html('Insert Voucher First !!!');
jQuery('#spinnerVoucher').hide();
} else {
var pointprice = jQuery('#pointrewards_input').val();
if (pointprice == '') {
pointprice = 0;
} else {
pointprice = pointprice;
}
var id_customer = <?= $shipping->id_customers ?>;
var province = jQuery('#shipping_province').val();
var subdistrict = jQuery('#shipping_subdistrict').val();
jQuery('.buyButton').attr('disabled', true);
ajax_set_voucher(voucher, pointprice, id_customer, province, subdistrict);
}
});
jQuery("#alertsale").click(function() {
jQuery('#spinnerVoucher').hide();
jQuery('.buyButton').attr('disabled', false);
jQuery('#alert_sale_item').html('<?= ucwords(lang('sale_item_coupon')) ?>');
});
jQuery("#redeemPoint").click(function() {
jQuery('#spinnerPoint').show();
var point = jQuery("#point").val();
if (point == '') {
jQuery('#error_point').html('Insert Point First !!!');
jQuery('#spinnerPoint').hide();
} else if (point < 0) {
jQuery('#error_point').html('Wrong Format Point !!!');
jQuery('#spinnerPoint').hide();
} else {
var voucherprice = jQuery('#voucherprice_input').val();
if (voucherprice == '') {
voucherprice = 0;
} else {
voucherprice = voucherprice;
}
var id_customer = <?= $shipping->id_customers ?>;
var province = jQuery('#shipping_province').val();
var subdistrict = jQuery('#shipping_subdistrict').val();
jQuery('.buyButton').attr('disabled', true);
ajax_set_point_rewards(voucherprice, point, id_customer, province, subdistrict);
}
});
});
function ajax_set_discounted_items_voucher(voucher, id_customer) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_set_discounted_items_voucher',
'type': 'POST',
'data': {
'voucher': voucher,
'id_customer': id_customer,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function() {
jQuery('#spinnerVoucher').hide();
jQuery('.buyButton').attr('disabled', false);
jQuery('#alert_sale_item').html('<?= ucwords(lang('sale_item_coupon')) ?>');
}
});
}
function ajax_set_voucher(voucher, pointprice, id_customer, province, subdistrict) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_set_voucher',
'type': 'POST',
'data': {
'voucher': voucher,
'pointprice': pointprice,
'id_customer': id_customer,
'province': province,
'subdistrict': subdistrict,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
if (data) {
var total = JSON.parse(data);
// jQuery('.indentInformation').show();
if (total.voucherprice_input > 0) {
jQuery('#voucherBlock').show();
}
if (total.voucherprice_input == 0) {
jQuery('#error_voucher').html(total.alert)
jQuery('#voucherprice').html('');
jQuery('#voucherdiscount').html('');
return;
} else {
jQuery('#error_voucher').html('')
}
// jQuery('#freeshippingBlock').show();
jQuery('#totalItemAmount').html(total.total_item_amount);
jQuery('#voucherdiscount').html(total.voucher_discount)
jQuery('#voucherprice').html(total.voucherprice);
jQuery('#voucherprice_input').val(total.voucherprice_input);
// plus
var totalItemAmount = parseInt(jQuery("span#totalItemAmount").html().split(",").join(''));
var totalShippingFee = parseInt(0);
if (jQuery("span#totalShippingFee").html() != undefined) {
totalShippingFee = parseInt(jQuery("span#totalShippingFee").html().split(",").join(''));
}
// min
var voucherprice = parseInt(jQuery("span#voucherprice").html().split(",").join('').replace("-", ""));
var pointrewards = parseInt(jQuery("span#pointrewards").html().split(",").join('').replace("-", ""));
var totalFreeShippingFee = parseInt(jQuery("span#totalFreeShippingFee").html().split(",").join('').replace("-", ""));
var indent_remaining = parseInt(jQuery('#indentRemaining').html().split(",").join('').replace("-", ""));
var grand_total =
(totalItemAmount +
totalShippingFee) -
(voucherprice +
pointrewards +
totalFreeShippingFee) - indent_remaining;
jQuery('#grandTotal').html(
formatIDR(grand_total)
);
jQuery('#spinnerVoucher').hide();
jQuery('.buyButton').attr('disabled', false);
};
}
});
}
function ajax_set_point_rewards(voucherprice, point, id_customer, province, subdistrict) {
jQuery.ajax({
'url': '<?= base_url() ?>' + 'ajax/ajax_set_point_rewards',
'type': 'POST',
'data': {
'voucherprice': voucherprice,
'point': point,
'id_customer': id_customer,
'province': province,
'subdistrict': subdistrict,
'<?= $this->security->get_csrf_token_name() ?>': '<?= $this->security->get_csrf_hash() ?>'
},
'success': function(data) {
if (data) {
var total = JSON.parse(data);
// jQuery('.indentInformation').show();
if (total.pointrewards_input > 0) {
jQuery('#pointrewardBlock').show();
}
// jQuery('#voucherBlock').show();
// jQuery('#freeshippingBlock').show();
jQuery('#totalItemAmount').html(total.total_item_amount);
jQuery('#pointrewards').html(total.pointrewards);
jQuery('#pointrewards_input').val(total.pointrewards_input);
// plus
var totalItemAmount = parseInt(jQuery("span#totalItemAmount").html().split(",").join(''));
var totalShippingFee = parseInt(0);
if (jQuery("span#totalShippingFee").html() != undefined) {
totalShippingFee = parseInt(jQuery("span#totalShippingFee").html().split(",").join(''));
}
// min
var voucherprice = parseInt(jQuery("span#voucherprice").html().split(",").join('').replace("-", ""));
var pointrewards = parseInt(jQuery("span#pointrewards").html().split(",").join('').replace("-", ""));
var totalFreeShippingFee = parseInt(jQuery("span#totalFreeShippingFee").html().split(",").join('').replace("-", ""));
var indent_remaining = parseInt(jQuery('#indentRemaining').html().split(",").join('').replace("-", ""));
var grand_total =
(totalItemAmount +
totalShippingFee) -
(voucherprice +
pointrewards +
totalFreeShippingFee) - indent_remaining;
jQuery('#grandTotal').html(
formatIDR(grand_total)
);
jQuery('#error_point').html(total.alert);
jQuery('#spinnerPoint').hide();
jQuery('.buyButton').attr('disabled', false);
};
}
});
}
</script>
<?php endif; ?>
<?php else : ?>
<!--- cart no content-->
<p>YOUR CART IS EMPTY.</p>
<?php endif; ?>
</div><!-- end myCart -->
</div>
</div>
</div>
<?= form_close() ?>
<div class="modal fade" id="myModalTOC" role="dialog" style="display: none;">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?= ucwords(lang('term_condition')); ?></h4>
<button type="button" class="btn btn-danger" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">X</span></button>
</div>
<div class="modal-body">
<?php
if ($this->session->userdata('site_lang') == 'english') {
$this->db->select('toc')->from('toc')->where('id_toc', 4);
$toc = $this->db->get()->row()->toc;
echo $toc;
} else {
$this->db->select('toc')->from('toc')->where('id_toc', 5);
$toc = $this->db->get()->row()->toc;
echo $toc;
}
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" style="color:white;"><?= ucwords(lang('close')); ?></button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var checkbox = document.getElementById('shipping_insurance');
var grandTotalElement = document.getElementById('grandTotal');
var shippingInsuranceBlock = document.getElementById('shippinginsuranceBlock');
var insurance_status = document.getElementById('insurance_status');
var insuranceFee = <?php echo ($get_grand_total * 0.2 / 100) + 5000; ?>;
checkbox.addEventListener('change', function() {
var grandTotal = parseFloat(grandTotalElement.innerText.replace(/[^0-9.-]+/g, ''));
if (checkbox.checked) {
grandTotal += insuranceFee;
shippingInsuranceBlock.style.display = '';
insurance_status.value = 'Yes';
} else {
grandTotal -= insuranceFee;
shippingInsuranceBlock.style.display = 'none';
insurance_status.value = 'No';
}
grandTotalElement.innerText = 'IDR ' + grandTotal.toLocaleString();
});
});
</script>