function addItem(cart, variant, product){
            // console.log(variant);
            variant.attribute_value_1 = variant.attribute_value_1.replace(/\s+/, "");
            variant.attribute_value_2 = variant.attribute_value_2.replace(/\s+/, "");
            variant.attribute_value_3 = variant.attribute_value_3.replace(/\s+/, "");
            let description = product.name;
            if (variant.attribute_value_1 != null && variant.attribute_value_1.length > 0) {
                description += '/' + variant.attribute_value_1;
            }

            if (variant.attribute_value_2 != null && variant.attribute_value_2.length > 0) {
                description += '/' + variant.attribute_value_2;
            }

            if (variant.attribute_value_3 != null && variant.attribute_value_3.length > 0) {
                description += '/' + variant.attribute_value_3;
            }

            for (var i = 0; i < cart.items.length; i++) {
                
                if (cart.items[i].variant.id == variant.id && cart.items[i].variant.product_id == variant.product_id) {
                    cart.items[i].quantity = cart.items[i].quantity + 1;
                    return;
                }
            }

            cart.items.push({
                //product_variant object 
                variant                 : variant, 
                //product object
                product                 : product, 
                quantity                : 1,
                //total price of item
                price                   : variant.retail_price,
                discount_percentage     : 0.0,
                discount_amount         : 0.0,
                discounted_amount       : 0.0,
                //discount_product        : 0.0,
                markup                  : 0.0,
                //binded with inut box under item in cart
                custom_price            : variant.retail_price,
                markup_percentage       : 0,
                notes                   : '',
                print                    :false,
                //unique id for view operations, like delete add edit etc
                id: Math.random(),
                description: description
            });

        }
/*
        * add new item in cart with product and variant
        */
add new item in cart with product and variant
add new item in cart with product and variant
function addItem(cart, variant, product){
            variant.attribute_value_1 = variant.attribute_value_1.replace(/\s+/, "");
            variant.attribute_value_2 = variant.attribute_value_2.replace(/\s+/, "");
            variant.attribute_value_3 = variant.attribute_value_3.replace(/\s+/, "");
            let description = product.name;
            if (variant.attribute_value_1 != null && variant.attribute_value_1.length > 0) {
                description += '/' + variant.attribute_value_1;
            }
            if (variant.attribute_value_2 != null && variant.attribute_value_2.length > 0) {
                description += '/' + variant.attribute_value_2;
            }
            if (variant.attribute_value_3 != null && variant.attribute_value_3.length > 0) {
                description += '/' + variant.attribute_value_3;
            }
            for (var i = 0; i < cart.items.length; i++) {
                if (cart.items[i].variant.id == variant.id && cart.items[i].variant.product_id == variant.product_id) {
                    cart.items[i].quantity = cart.items[i].quantity + 1;
                    return;
                }
            }
            cart.items.push({
                variant                 : variant, 
                product                 : product, 
                quantity                : 1,
                price                   : variant.retail_price,
                discount_percentage     : 0.0,
                discount_amount         : 0.0,
                discounted_amount       : 0.0,
                markup                  : 0.0,
                custom_price            : variant.retail_price,
                markup_percentage       : 0,
                notes                   : '',
                print                    :false,
                id: Math.random(),
                description: description
            });
        }
function addItem ( cart , variant , product ) { variant . attribute_value_1 = variant . attribute_value_1 . replace ( / \s+ / , "" ) ; variant . attribute_value_2 = variant . attribute_value_2 . replace ( / \s+ / , "" ) ; variant . attribute_value_3 = variant . attribute_value_3 . replace ( / \s+ / , "" ) ; let description = product . name ; if ( variant . attribute_value_1 != null && variant . attribute_value_1 . length > 0 ) { description += '/' + variant . attribute_value_1 ; } if ( variant . attribute_value_2 != null && variant . attribute_value_2 . length > 0 ) { description += '/' + variant . attribute_value_2 ; } if ( variant . attribute_value_3 != null && variant . attribute_value_3 . length > 0 ) { description += '/' + variant . attribute_value_3 ; } for ( var i = 0 ; i < cart . items . length ; i ++ ) { if ( cart . items [ i ] . variant . id == variant . id && cart . items [ i ] . variant . product_id == variant . product_id ) { cart . items [ i ] . quantity = cart . items [ i ] . quantity + 1 ; return ; } } cart . items . push ( { variant : variant , product : product , quantity : 1 , price : variant . retail_price , discount_percentage : 0.0 , discount_amount : 0.0 , discounted_amount : 0.0 , markup : 0.0 , custom_price : variant . retail_price , markup_percentage : 0 , notes : '' , print : false , id : Math . random ( ) , description : description } ) ; }
add new item in cart with product and variant
add new item in cart with product and variant
// console.log(variant); //product_variant object  //product object //total price of item //discount_product        : 0.0, //binded with inut box under item in cart //unique id for view operations, like delete add edit etc