Delivery location

Need to set up a dropdown on every page with the different locations provided on NetSuite. Need to show the products depending on the product availability at each location. Mainly we showing products on PLP, PDP and recently items. 

Sample extending for disabling and showing item depends on the location. 

var sale = fn.apply(this, _.toArray(arguments).slice(1))              

                        var available = this.model.attributes.quantityavailable_detail; 

                        var condition2 = false; 

                        var seltd = this.getCookie('selectedLocation'); 

                        var confgid; 

                        var quantityavailable; 

                        var locid = SC.CONFIGURATION.popup.data; 

                        var eta = this.model.attributes.custitem62; 

                        _.each(SC.CONFIGURATION.popup.data, function (eachResult) { 

                            var text2 = JSON.stringify(eachResult.text2); 

                            if (text2 == JSON.stringify(seltd)) { 

                                confgid = eachResult.text1; 

                            } 

                        }); 

                        if (available && available.locations) { 

                            _.each(available.locations, function (eachResult) { 

                                if (eachResult.internalid == confgid) { 

                                    condition2 = true; 

                                    quantityavailable = eachResult.quantityavailable; 

                                } 

                            }); 

                        } 

                        sale.quantityavailable = quantityavailable; 

                        sale.condition2 = condition2; 

                        if (eta) { 

                            sale.eta = eta; 

                        } else { 

                            sale.eta = "TBA"; 

                        } 

                        return sale; 

Creating cookies

                    getCookie: function (name) {
                        var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
                        return v ? v[2] : null;
                    },

Location setup

            var self = this
            var conceptName = $('#location').find(":selected").text();
            document.cookie = "selectedLocation =" + conceptName + ";path=/";
            //$('#locationheader').val(conceptName)
            this.$("#myModal").hide();
            var promise = jQuery.Deferred();
            this.deliveryloc = conceptName;
            var Profile = ProfileModel.getInstance();
            var id = Profile.get("internalid");
            this.model.fetch({
                data: {
                    internalid: id,
                    locationselected: conceptName
                }
            }).done(function (result) {
                promise.resolve();
                console.log(result)
                location.reload()
            });

Leave a comment

Your email address will not be published. Required fields are marked *