|
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/rabbithabit.com/public_html/application/views/ajax/ |
Upload File : |
<style>
.btn {
border-radius: 5px !important;
}
.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>
<?php
/* echo '<pre>';
print_r($this->session->userdata('shipping_cart'));
echo '</pre>'; */
$condition_freeshipping = $this->session->userdata('condition_freeshipping');
if(!$condition_freeshipping){
$condition_freeshipping = false;
}
?>
<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++; ?>
<tr>
<td class="hidden-xs-down" style="width: 26%;">
<?php
$q_product_images = $this->db->order_by('priority','asc')->get_where("product_images",array(
"product_details_id"=>$item['id'],
"product_id"=>$item['product_id'],
))->row();
$img_thumbnail = base_url()."uploads/image_not_available.jpg";
if ($q_product_images != null) {
$img_thumbnail = base_url()."uploads/product/small/".$q_product_images->image;
}
?>
<div style="display: inline-flex;align-items: center;">
<div style="height: 100px;width: 100px; margin-right: 7px;">
<img src="<?= $img_thumbnail; ?>" class="img-fluid" alt="">
</div>
<div>
<?= strtoupper($item['name']); ?><br>
<?= get_attribute_name($item['attribute_detail_ids']); ?><br><span style="font-size: 12px;"><?= $item['sku']; ?></span>
</div>
</div>
</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;">
<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>
<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>
<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>
</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']); ?><br>
<span id="spinner<?= $count; ?>"><img width="40" class="img_nowidth" src="<?= base_url('uploads/spinner.gif'); ?>"></span>
</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'];
if($shipping_id == 3){
$shipping_name = 'Regular';
}
?>
<?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) : ?>
(<?= ucwords(lang('free'))?>)
<?php else: ?>
<?php if($total_shipping_fee == 0) : ?>
(<?= ucwords(lang('free'))?>)
<?php else : ?>
<?php if($shipping_id == 5) : ?>
(TBC)
<?php else : ?>
(IDR <span id="shippingFee<?= $count_shipping; ?>"><?= number_format($total_shipping_fee); ?></span>)
<?php endif; ?>
<?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'];*/ ?> -->
<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='';
}
});
}
}
jQuery(document).on('click', '.shipping_method<?= $rowid; ?>', function(){
// alert('abc');
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);
});
});
</script>
<?php $grand_total = $grand_total + $item['subtotal']; ?>
<?php endforeach; ?>
</form>
</tbody>
</table>
</div>
<div class="row">
<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; ?> <?= ucwords(lang('points'))?>. 1 <?= ucwords(lang('points'))?> <?= ucwords(lang('can_redeem'))?> IDR <?= $point_rewards->conversion;?></p>
</div>
<?php endif; ?>
<div class="col-sm-6 col-6">
<input class="form-control" type="number" id="point" placeholder="<?= ucwords(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>
</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;"><?= ucwords(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>
<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>
</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="redeemVoucher" style="width: 150px;float: none;"><?= ucwords(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><a href="<?= base_url('login'); ?>" style="text-decoration: none; font-weight: bold; color:#CAA677;"><?= ucwords(lang('signin'))?></a> <?= ucwords(lang('to_enjoy'))?>.</p>
</div>
<?php endif; ?>
</div>
<input type="hidden" id="voucherprice_input">
<input type="hidden" id="pointrewards_input">
</div>
<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;">
<p><span><?= ucwords(lang('point_rewards'))?> :</span></p>
</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>
<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) : ?>
<?= ucwords(lang('free'))?>
<?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>
<?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">
<hr class="tk_line">
</div>
</div>
<div class="row" style="font-weight: bold;text-align: right;padding-top: 5px;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">
<br>
<p><span style="font-size:100%;">IDR
<span id="grandTotal">
<?php if($condition_freeshipping == true) : ?>
<?php
$finalshippingfee = 0;
$total_indent_shipping_fee = 0;
?>
<?php endif; ?>
<?= number_format($grand_total + $finalshippingfee - $total_indent_shipping_fee - $total_indent_amount + $total_downpayment); ?>
</span>
</p>
</div>
</div>
<p style="margin-top: 35px;margin-bottom: 50px;font-size: 15px;font-weight: bold;" class="clearfix">
<style>
.btn-buy{
width:250px;
float: right;
margin-right: 0px;
margin-top: 0px;
}
</style>
<br>
<button id="lanjutPembayaran" name="lanjutPembayaran" type="submit" class="btn btn-primary buyButton btn-buy hidden-xs-down"><?= ucwords(lang('payment'))?></button>
<img style="display: none;float: right;" class="img_nowidth lanjutPembayaran_spinner" width="40" src="<?= base_url('uploads/spinner.gif'); ?>">
</p>
<script>
/* jQuery(document).on('click', '.buyButton', function(e){
if (!jQuery('#completeAddress').val(e)) {
e.preventDefault();
jQuery('#addressMessage').html('Alamat kirim harus diisi');
jQuery('#completeAddress').focus();
}
if (!jQuery('#shipping_district').val(e)) {
e.preventDefault();
jQuery('#addressMessage').html('Mohon memilih Kota/Kabupaten');
jQuery('#shipping_district').focus();
}
if (!jQuery('#shipping_subdistrict').val(e)) {
e.preventDefault();
jQuery('#addressMessage').html('Mohon memilih Kecamatan');
jQuery('#shipping_subdistrict').focus();
}
}); */
/* jQuery('#lanjutPembayaran').click(function() {
jQuery('#lanjutPembayaran').hide("fast");
jQuery('.lanjutPembayaran_spinner').show("fast");
}); */
</script>
</div>
</div>
<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();
});
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);
if (data != 'Not Enough Stock') {
ajax_change_shipping_fee<?= $count; ?>(qty);
}else{
Swal.fire({
position: 'center',
// position: 'top',
icon: 'error',
text: data,
// showConfirmButton: false,
confirmButtonText: 'OK',
timer: 3000,
customClass: {
confirmButton: 'btn-swal-confirm',
}
}).then((result) => {
if (result.value) {
// window.location.href = "<?= base_url('wishlist'); ?>";
}
});
}
};
}
});
}
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);
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_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'));?>");
}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();
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("#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_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)
}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; ?>