assets/front/js/functions.js
//UPDATE TO CART - POPUP - CUSTOMIZE
UPDATE TO CART - POPUP - CUSTOMIZE
UPDATE TO CART - POPUP - CUSTOMIZE
function updateToCart() {
	var message  = "";
	var itemFrom   = 'items';
	var item_id	   = 0;
	var item_option_id=0;
	var itm_qty=1;
	var addon_ids = [];
	var index = 0;
	var modl = "#addons-options-modal";
	item_id 	= $(""+modl+" #selected_item_id").val();
	itm_qty 	= $(""+modl+" #itm_qty").val();
	var rowid 	= $(""+modl+" #rowid").val();
	if($(''+modl+' input[name="item_option_id"]:checked')) {
		item_option_id = $(''+modl+' input[name="item_option_id"]:checked').val();
	}
	$('.dm-add-qty input:checked').each(function() {
		addon_ids[index++] = $(this).attr('id');
	});
	if (rowid!='' && item_id>0 && item_option_id>=0 && itm_qty>0) {
	var token = '';
	if($('[name="csrf_digi_name"]').length)
		token = document.getElementsByName('csrf_digi_name')[0].value;
	var targeturl = add_cart_target_url;
	$("body").addClass("ajax-load");
	$.post(targeturl, { item_id: item_id, quantity: itm_qty, item_option_id: item_option_id, addon_ids: addon_ids, csrf_digi_name: token, ajax: '1',item_from:itemFrom,rowid:rowid },
		function(data) {
			$("body").removeClass("ajax-load");
		    if (data>0) {
				if( $('#addons-options-modal').hasClass('in') ) {
					$('#addons-options-modal').modal('hide');
				}
				load_cart_div();
				message = "Item successfully updated to your cart";
				checkNotify('CART',message,'success');
			} else {	
				message = "Item has not updated";
				checkNotify('CART',message,'error');
			}
		});  
	}
	else {
		message = "Invalid Operation";
		checkNotify('CART',message,'error');
	}
}
function updateToCart ( ) { var message = "" ; var itemFrom = 'items' ; var item_id = 0 ; var item_option_id = 0 ; var itm_qty = 1 ; var addon_ids = [ ] ; var index = 0 ; var modl = "#addons-options-modal" ; item_id = $ ( "" + modl + " #selected_item_id" ) . val ( ) ; itm_qty = $ ( "" + modl + " #itm_qty" ) . val ( ) ; var rowid = $ ( "" + modl + " #rowid" ) . val ( ) ; if ( $ ( '' + modl + ' input[name="item_option_id"]:checked' ) ) { item_option_id = $ ( '' + modl + ' input[name="item_option_id"]:checked' ) . val ( ) ; } $ ( '.dm-add-qty input:checked' ) . each ( function ( ) { addon_ids [ index ++ ] = $ ( this ) . attr ( 'id' ) ; } ) ; if ( rowid != '' && item_id > 0 && item_option_id >= 0 && itm_qty > 0 ) { var token = '' ; if ( $ ( '[name="csrf_digi_name"]' ) . length ) token = document . getElementsByName ( 'csrf_digi_name' ) [ 0 ] . value ; var targeturl = add_cart_target_url ; $ ( "body" ) . addClass ( "ajax-load" ) ; $ . post ( targeturl , { item_id : item_id , quantity : itm_qty , item_option_id : item_option_id , addon_ids : addon_ids , csrf_digi_name : token , ajax : '1' , item_from : itemFrom , rowid : rowid } , function ( data ) { $ ( "body" ) . removeClass ( "ajax-load" ) ; if ( data > 0 ) { if ( $ ( '#addons-options-modal' ) . hasClass ( 'in' ) ) { $ ( '#addons-options-modal' ) . modal ( 'hide' ) ; } load_cart_div ( ) ; message = "Item successfully updated to your cart" ; checkNotify ( 'CART' , message , 'success' ) ; } else { message = "Item has not updated" ; checkNotify ( 'CART' , message , 'error' ) ; } } ) ; } else { message = "Invalid Operation" ; checkNotify ( 'CART' , message , 'error' ) ; } }
UPDATE TO CART - POPUP - CUSTOMIZE
UPDATE TO CART - POPUP - CUSTOMIZE
//Prepare Add-ons array