how the make default color select on pdp and quickview page when page loads

To auto-select the default color on the pdp page and same, they can change the required color We need to pass the default color to set the option model; the sample code is added below.

pdp.on("afterShowContent", function () {
                                if (!self.model.get("custcol_jj_color")) {
                                    var firstColor = _.find(self.model.get("options").models, (option)=> option.get("cartOptionId") === "custcol_jj_color")?.get('values')[1]?.internalid;
                                    pdp.setOption("custcol_jj_color" ,firstColor)
                                }
})

Leave a comment

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