Add a success message when item add to cart

On the PDP page when we click the ‘Buy’ button,we need to add the message “Item Added to cart”

cart_promise.done(function () {

                        // Display “Item added to cart” message

                        var cartMessage = new GlobalViewsMessageView({

                            message: ‘item added to <a href=”/cart”><u>your basket</u></a>’,

                            type: ‘success’,

                            closable: true

                          }).render().$el;

                            if ($alert_placeholder.length) {

                                $alert_placeholder.empty().html(cartMessage);

                            } else {

                                var $productDetails = jQuery(‘.product-details-full-main’);

                                $productDetails.before(cartMessage);                                

                            }                                          

                        // Prevent redirection to the cart page on mobile devices

                        if (Utils.isPhoneDevice()) {

                            e.stopPropagation();

                        }

                    });

Leave a comment

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