ok
Direktori : /home2/selectio/public_html/thecomponents.in/ |
Current File : /home2/selectio/public_html/thecomponents.in/add-to-card.php |
<script> function remove_cart(card_id){ var cart_items_id = $(this).attr('id'); var element = $('[data-rowid="'+card_id+'"]'); console.log('count is delete is working'); $.ajax({ url: 'api/add-to-card.php', type: 'post', data:{type:'remove',card_id:card_id}, dataType: 'json', success: function (response) { console.log(response); if(response['status']==200){ alert(response['message']); element.remove(); cart_count(); cart_details(); view_cart_details(); grand_total(); }else{ alert(response['message']); cart_count(); cart_details(); view_cart_details(); grand_total(); } } }); } function cart_count(){ console.log('count is working'); $.ajax({ url: 'api/add-to-card.php', type: 'post', data:{type:'c_count'}, dataType: 'json', success: function (response) { console.log(response); if(response['status']==200){ $('.cart-count').text(response['cart_count']); $('#total-card-price').html(response['total_card_price']); cart_details(); }else{ $('.cart-count').text(response['cart_count']); $('#total-card-price').html(response['total_card_price']); cart_details(); } } }); } function cart_details(){ console.log('count is working'); $.ajax({ url: 'api/side-card-ui.php', type: 'post', data:{type:'product_details'}, dataType: 'json', success: function (response) { console.log(response); if(response['status']==200){ $('#header_canvas').append(response['total_card_price']); }else{ $('#header_canvas').append(response['total_card_price']); } } }); } $(document).ready(function(){ cart_count(); cart_details(); }); function Quick_AddToCart(pro_id){ <?php if(isset($_SESSION['caliber'])){ ?> var qty = $("#quantity_"+pro_id).val(); $.ajax({ url: 'api/cart.php', type: 'post', data:{product_id:pro_id,type:'add_to_cart',quantiy:qty}, dataType: 'json', success: function (response) { console.log(response['cart_count']); if(response['status']==200){ $('#items_'+pro_id).empty(); //$('#items_'+pro_id).append('<span class="btn btn-info btn-sm" style="background: green;"><i class="fi-rs-shopping-cart mr-5" style="color: white;"></i>Added</span>'); $('#items_'+pro_id).append(' <span class="btn-product btn-cart" style="color: green;">Added</span>'); $('#cart_items_count').text(response['cart_count']); alert(response['message']); //alert(response['message']); //$('#addon_loader').hide(); cart_count(); cart_details(); view_cart_details(); }else{ alert(response['message']); //alert(response['message']); //$('#addon_loader').hide(); } } }); <?php }else{ echo "alert('please Login...');"; echo "window.location.href = 'login.php';"; }?> } //function function view_cart_details(){ $("#view-cart-details").empty(); console.log('view cart details is working'); $.ajax({ url: 'api/view-cart.php', type: 'post', data:{type:'view_cart_details'}, dataType: 'json', success: function (response) { console.log(response); if(response['status']==200){ $('#view-cart-details').append(response['total_card_price']); grand_total(); }else{ $('#view-cart-details').append(response['total_card_price']); grand_total(); } } }); } function grand_total(){ console.log("total is workign"); var tot=0; $(".product_total_amount").each(function(){ tot+=Number($(this).text()); }); $(".summary-subtotal-price").text(tot); $(".summary-total-price").text(tot); } </script> <!--<script> function Quick_AddToCart(pro_id, variant_id){ <?php //if(isset($_SESSION['ramali_textiles'])){ ?> console.log('quick cart'); $.ajax({ url: 'api/cart.php', type: 'post', data:{product_id:pro_id,type:'add_to_cart',product_variant_id:variant_id}, dataType: 'json', success: function (response) { console.log(response); if(response['status']==200){ $('#items_'+pro_id).empty(); $('#items_'+pro_id).append(' <span class="btn-cart btn-product btn btn-icon-right btn-link btn-underline" style="color: green;">Added</span>') $('#cart_items_count').text(response['cart_count']); alert(response['message']); cart_count(); }else{ alert(response['message']); cart_count(); } } }); <?php //}else{ //echo "alert('please Login...')"; //} ?> }//function </script>-->