How to show image preview of a image updated from edit cart for items having personalisation

When we extend functionality of pdp extension on edit cart it will update only fields it will not update personalised image this is because of standard tpl file
For edit cart pop up fields will be displayed using standard tpl file upload function is not there on tpl it is created one so it will not update values
then we can use the following code sample to do so
Also when edited from cart and added any personalisation that item must be consider as a personalised if it is not personalised from pdp page
If not done it is not going to show personlised URL on sales order
EX:

imagePreview:function (e) {
                        var self = this;
                        self.pdp = container.getComponent('PDP');
                        var options = _.filter(self.model.get("item").attributes.options.models,function (element) {
                            var option = self.model.attributes[element.get("cartOptionId")];
                            if (option) {
                                return element;
                            }
                        }
                        );
                        let inModalLogoUrl = $('#in-modal-set-liquid-pixel-logo-url').text();
                        if (options.length > 1 || inModalLogoUrl) {
                            self.pdp.setOption("custcol_ag_havepersonalization", 'T'); 
                            if (inModalLogoUrl) {
                                self.pdp.setOption('custcol_ag_personlizationimgurl', inModalLogoUrl);
                            }
                        }
                        self.render();
                        $('button[data-type="add-to-cart"]').click();
                        $('.global-views-modal-content-header-close').click();
                    },

Leave a comment

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