I want to add popup notify after adding products Magento 2Adding a modal after adding to cartHow to add my custom popup form after adding the products in Shopping cart magento 2How to add “Add To Cart” Pop Up Magento 2 Custom theme?Magento 2 How to add Product Review Form to Popup?Product not showing after adding related products in Magento2How to add my custom popup form after adding the products in Shopping cart magento 2Mini cart is not working after adding custom themeMagento 2 - custom price can not add to subtotal and grand total after add to cartMagento2 : Add Simple Products to bundle product selectionHow to show popup for going to continue shop or checkout page after product adding to cart page?Adding CMS Blocks to a Products, not programatically - Magento 2

New order #4: World

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Are white and non-white police officers equally likely to kill black suspects?

What is the meaning of "of trouble" in the following sentence?

Why is the design of haulage companies so “special”?

Is this food a bread or a loaf?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Can I legally use front facing blue light in the UK?

Are cabin dividers used to "hide" the flex of the airplane?

Ideas for 3rd eye abilities

How to move the player while also allowing forces to affect it

How can I fix this gap between bookcases I made?

"listening to me about as much as you're listening to this pole here"

Does bootstrapped regression allow for inference?

Why was the "bread communication" in the arena of Catching Fire left out in the movie?

Need help identifying/translating a plaque in Tangier, Morocco

What do the Banks children have against barley water?

What are the advantages and disadvantages of running one shots compared to campaigns?

Where else does the Shulchan Aruch quote an authority by name?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Pristine Bit Checking

I see my dog run

Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?



I want to add popup notify after adding products Magento 2


Adding a modal after adding to cartHow to add my custom popup form after adding the products in Shopping cart magento 2How to add “Add To Cart” Pop Up Magento 2 Custom theme?Magento 2 How to add Product Review Form to Popup?Product not showing after adding related products in Magento2How to add my custom popup form after adding the products in Shopping cart magento 2Mini cart is not working after adding custom themeMagento 2 - custom price can not add to subtotal and grand total after add to cartMagento2 : Add Simple Products to bundle product selectionHow to show popup for going to continue shop or checkout page after product adding to cart page?Adding CMS Blocks to a Products, not programatically - Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I wanted to Add notify popup form after adding the products but I couldn't get the file in magento 2. I need someone help who already done this work.










share|improve this question
























  • Where I have add additional code to make this popup.

    – Shakib Rahman
    Dec 18 '16 at 7:42











  • Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

    – Khoa TruongDinh
    Dec 18 '16 at 7:44











  • @ShakibRahman check my answer, it is very easy and clear.

    – LucScu
    Mar 4 '18 at 10:55


















0















I wanted to Add notify popup form after adding the products but I couldn't get the file in magento 2. I need someone help who already done this work.










share|improve this question
























  • Where I have add additional code to make this popup.

    – Shakib Rahman
    Dec 18 '16 at 7:42











  • Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

    – Khoa TruongDinh
    Dec 18 '16 at 7:44











  • @ShakibRahman check my answer, it is very easy and clear.

    – LucScu
    Mar 4 '18 at 10:55














0












0








0


1






I wanted to Add notify popup form after adding the products but I couldn't get the file in magento 2. I need someone help who already done this work.










share|improve this question
















I wanted to Add notify popup form after adding the products but I couldn't get the file in magento 2. I need someone help who already done this work.







magento2 mini-cart






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 24 '18 at 5:09









Teja Bhagavan Kollepara

2,97341949




2,97341949










asked Dec 18 '16 at 7:40









Shakib RahmanShakib Rahman

67210




67210












  • Where I have add additional code to make this popup.

    – Shakib Rahman
    Dec 18 '16 at 7:42











  • Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

    – Khoa TruongDinh
    Dec 18 '16 at 7:44











  • @ShakibRahman check my answer, it is very easy and clear.

    – LucScu
    Mar 4 '18 at 10:55


















  • Where I have add additional code to make this popup.

    – Shakib Rahman
    Dec 18 '16 at 7:42











  • Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

    – Khoa TruongDinh
    Dec 18 '16 at 7:44











  • @ShakibRahman check my answer, it is very easy and clear.

    – LucScu
    Mar 4 '18 at 10:55

















Where I have add additional code to make this popup.

– Shakib Rahman
Dec 18 '16 at 7:42





Where I have add additional code to make this popup.

– Shakib Rahman
Dec 18 '16 at 7:42













Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

– Khoa TruongDinh
Dec 18 '16 at 7:44





Go to this file and see the Ajax Add to Cart vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js.

– Khoa TruongDinh
Dec 18 '16 at 7:44













@ShakibRahman check my answer, it is very easy and clear.

– LucScu
Mar 4 '18 at 10:55






@ShakibRahman check my answer, it is very easy and clear.

– LucScu
Mar 4 '18 at 10:55











3 Answers
3






active

oldest

votes


















4














You have to override vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js..



And you can add this below script in your override catalog-add-to-cart.js



 define([
'jquery',
'mage/translate',
'jquery/ui',
'Magento_Ui/js/modal/modal',
], function ($, $t, modal)
"use strict";
...
...
...
var popup = $('<div class="themecafe-free-popup"/>').html('<h1>HTML Content</h1>').modal(
modalClass: 'changelog',
title: $.mage.__("Model Title"),
buttons: [
text: 'Continue Shopping',
click: function ()
this.closeModal();

]
);
popup.modal('openModal');
...
...
...
);


EDIT



define([
'jquery',
'mage/translate',
'jquery/ui',
'Magento_Ui/js/modal/modal',
], function ($, $t, modal)
"use strict";
$.widget('mage.catalogAddToCart',
.....
ajaxSubmit: function (form)
var self = this;
$(self.options.minicartSelector).trigger('contentLoading');
self.disableAddToCartButton(form);
$.ajax(
url: form.attr('action'),
data: form.serialize(),
type: 'post',
dataType: 'json',
beforeSend: function ()
if (self.isLoaderEnabled())
$('body').trigger(self.options.processStart);

,
success: function (res)

if (self.isLoaderEnabled())
$('body').trigger(self.options.processStop);


if (res.backUrl)
window.location = res.backUrl;
return;

if (res.messages)
$(self.options.messagesSelector).html(res.messages);

if (res.minicart)
$(self.options.minicartSelector).replaceWith(res.minicart);
$(self.options.minicartSelector).trigger('contentUpdated');

if (res.product && res.product.statusText)
$(self.options.productStatusSelector)
.removeClass('available')
.addClass('unavailable')
.find('span')
.html(res.product.statusText);

self.enableAddToCartButton(form);
//popup code start

//for 2 option you can check you value is coming in `res` and get product name
var popup = $('<div class="themecafe-free-popup"/>').html($('.page-title span').text()).modal( //get product name from product view page only
modalClass: 'changelog',
title: $.mage.__("Model Title"),
buttons: [
text: 'Continue Shopping',
click: function ()
this.closeModal();

]
);
popup.modal('openModal');
//popup code end

);
,
....
);
return $.mage.catalogAddToCart;
);


or



Vendor/Module/etc/frontend/di.xml



<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutControllerCartAdd">
<plugin name="name.of.block" type="VendorModulePluginCartAdd" sortOrder="10" />
</type>
</config>


'Vendor/Module/Plugin/Cart/Add.php'



<?php
namespace VendorModulePluginCart;

use MagentoFrameworkAppObjectManager;

class Add

public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)


//Your customization is here for passing product name


$subject->getResponse()->representJson(
$objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result1)
);
return $result;







share|improve this answer

























  • Thanks a lot. But it didn't work.

    – Shakib Rahman
    Dec 19 '16 at 9:22











  • try my updated answer

    – chirag
    Dec 19 '16 at 9:27











  • Nothing is working. I don't have any idea how I can solve it.

    – Shakib Rahman
    Dec 19 '16 at 17:04











  • Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

    – chirag
    Dec 19 '16 at 18:27











  • How can we display product name in pop ?

    – Jai
    Feb 17 '17 at 6:12


















2














In product page you can obtain it with this code.



In vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml add at the end the modal div



<div id="addtocart_modal" style="display: none;"></div>


more, add the below attribute to the submit button with class="action primary tocart", so you could pass product name to the modal



data-name="<?php echo $_product->getName() ?>"


Now, in vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js after



self.enableAddToCartButton(form);


add the code to init the modal



var cartUrl = url.build('checkout/cart');
var modal_options =
type: 'popup',
buttons: [

text: "&laquo; Continue shopping",
class: 'primary btn-lg btn-info addtocart_modal_continue',
click: function ()
this.closeModal();
return false;

,

text: "Go to cart &raquo;",
class: 'primary btn-lg btn-success addtocart_modal_gotocart',
click: function ()
location.href = cartUrl;
return false;


]
;

var popup = $('#addtocart_modal');
var product_name = form.find("button").data("name");

// reset modal content every time
popup.html("");
popup.append("<div>The product " + product_name + " is added to your cart</div>");
popup.modal(modal_options);
popup.modal('openModal');


It's done! If you need this modal also in catalog page or everywhere there is an add to cart button keep this logic and adjust it.



PS: override core files is a bad practice, so take in mind to override the files in your module/theme






share|improve this answer
































    0














    you can try the free extension Shopping Cart Notifications Magento 2 by MageWorkshop. I hope that solve your issue in a simple way.



    https://mageworkshop.com/shopping-cart-notifications-magento-2.html






    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f150794%2fi-want-to-add-popup-notify-after-adding-products-magento-2%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      You have to override vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js..



      And you can add this below script in your override catalog-add-to-cart.js



       define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      ...
      ...
      ...
      var popup = $('<div class="themecafe-free-popup"/>').html('<h1>HTML Content</h1>').modal(
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      ...
      ...
      ...
      );


      EDIT



      define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      $.widget('mage.catalogAddToCart',
      .....
      ajaxSubmit: function (form)
      var self = this;
      $(self.options.minicartSelector).trigger('contentLoading');
      self.disableAddToCartButton(form);
      $.ajax(
      url: form.attr('action'),
      data: form.serialize(),
      type: 'post',
      dataType: 'json',
      beforeSend: function ()
      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStart);

      ,
      success: function (res)

      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStop);


      if (res.backUrl)
      window.location = res.backUrl;
      return;

      if (res.messages)
      $(self.options.messagesSelector).html(res.messages);

      if (res.minicart)
      $(self.options.minicartSelector).replaceWith(res.minicart);
      $(self.options.minicartSelector).trigger('contentUpdated');

      if (res.product && res.product.statusText)
      $(self.options.productStatusSelector)
      .removeClass('available')
      .addClass('unavailable')
      .find('span')
      .html(res.product.statusText);

      self.enableAddToCartButton(form);
      //popup code start

      //for 2 option you can check you value is coming in `res` and get product name
      var popup = $('<div class="themecafe-free-popup"/>').html($('.page-title span').text()).modal( //get product name from product view page only
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      //popup code end

      );
      ,
      ....
      );
      return $.mage.catalogAddToCart;
      );


      or



      Vendor/Module/etc/frontend/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutControllerCartAdd">
      <plugin name="name.of.block" type="VendorModulePluginCartAdd" sortOrder="10" />
      </type>
      </config>


      'Vendor/Module/Plugin/Cart/Add.php'



      <?php
      namespace VendorModulePluginCart;

      use MagentoFrameworkAppObjectManager;

      class Add

      public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)


      //Your customization is here for passing product name


      $subject->getResponse()->representJson(
      $objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result1)
      );
      return $result;







      share|improve this answer

























      • Thanks a lot. But it didn't work.

        – Shakib Rahman
        Dec 19 '16 at 9:22











      • try my updated answer

        – chirag
        Dec 19 '16 at 9:27











      • Nothing is working. I don't have any idea how I can solve it.

        – Shakib Rahman
        Dec 19 '16 at 17:04











      • Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

        – chirag
        Dec 19 '16 at 18:27











      • How can we display product name in pop ?

        – Jai
        Feb 17 '17 at 6:12















      4














      You have to override vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js..



      And you can add this below script in your override catalog-add-to-cart.js



       define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      ...
      ...
      ...
      var popup = $('<div class="themecafe-free-popup"/>').html('<h1>HTML Content</h1>').modal(
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      ...
      ...
      ...
      );


      EDIT



      define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      $.widget('mage.catalogAddToCart',
      .....
      ajaxSubmit: function (form)
      var self = this;
      $(self.options.minicartSelector).trigger('contentLoading');
      self.disableAddToCartButton(form);
      $.ajax(
      url: form.attr('action'),
      data: form.serialize(),
      type: 'post',
      dataType: 'json',
      beforeSend: function ()
      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStart);

      ,
      success: function (res)

      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStop);


      if (res.backUrl)
      window.location = res.backUrl;
      return;

      if (res.messages)
      $(self.options.messagesSelector).html(res.messages);

      if (res.minicart)
      $(self.options.minicartSelector).replaceWith(res.minicart);
      $(self.options.minicartSelector).trigger('contentUpdated');

      if (res.product && res.product.statusText)
      $(self.options.productStatusSelector)
      .removeClass('available')
      .addClass('unavailable')
      .find('span')
      .html(res.product.statusText);

      self.enableAddToCartButton(form);
      //popup code start

      //for 2 option you can check you value is coming in `res` and get product name
      var popup = $('<div class="themecafe-free-popup"/>').html($('.page-title span').text()).modal( //get product name from product view page only
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      //popup code end

      );
      ,
      ....
      );
      return $.mage.catalogAddToCart;
      );


      or



      Vendor/Module/etc/frontend/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutControllerCartAdd">
      <plugin name="name.of.block" type="VendorModulePluginCartAdd" sortOrder="10" />
      </type>
      </config>


      'Vendor/Module/Plugin/Cart/Add.php'



      <?php
      namespace VendorModulePluginCart;

      use MagentoFrameworkAppObjectManager;

      class Add

      public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)


      //Your customization is here for passing product name


      $subject->getResponse()->representJson(
      $objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result1)
      );
      return $result;







      share|improve this answer

























      • Thanks a lot. But it didn't work.

        – Shakib Rahman
        Dec 19 '16 at 9:22











      • try my updated answer

        – chirag
        Dec 19 '16 at 9:27











      • Nothing is working. I don't have any idea how I can solve it.

        – Shakib Rahman
        Dec 19 '16 at 17:04











      • Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

        – chirag
        Dec 19 '16 at 18:27











      • How can we display product name in pop ?

        – Jai
        Feb 17 '17 at 6:12













      4












      4








      4







      You have to override vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js..



      And you can add this below script in your override catalog-add-to-cart.js



       define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      ...
      ...
      ...
      var popup = $('<div class="themecafe-free-popup"/>').html('<h1>HTML Content</h1>').modal(
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      ...
      ...
      ...
      );


      EDIT



      define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      $.widget('mage.catalogAddToCart',
      .....
      ajaxSubmit: function (form)
      var self = this;
      $(self.options.minicartSelector).trigger('contentLoading');
      self.disableAddToCartButton(form);
      $.ajax(
      url: form.attr('action'),
      data: form.serialize(),
      type: 'post',
      dataType: 'json',
      beforeSend: function ()
      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStart);

      ,
      success: function (res)

      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStop);


      if (res.backUrl)
      window.location = res.backUrl;
      return;

      if (res.messages)
      $(self.options.messagesSelector).html(res.messages);

      if (res.minicart)
      $(self.options.minicartSelector).replaceWith(res.minicart);
      $(self.options.minicartSelector).trigger('contentUpdated');

      if (res.product && res.product.statusText)
      $(self.options.productStatusSelector)
      .removeClass('available')
      .addClass('unavailable')
      .find('span')
      .html(res.product.statusText);

      self.enableAddToCartButton(form);
      //popup code start

      //for 2 option you can check you value is coming in `res` and get product name
      var popup = $('<div class="themecafe-free-popup"/>').html($('.page-title span').text()).modal( //get product name from product view page only
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      //popup code end

      );
      ,
      ....
      );
      return $.mage.catalogAddToCart;
      );


      or



      Vendor/Module/etc/frontend/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutControllerCartAdd">
      <plugin name="name.of.block" type="VendorModulePluginCartAdd" sortOrder="10" />
      </type>
      </config>


      'Vendor/Module/Plugin/Cart/Add.php'



      <?php
      namespace VendorModulePluginCart;

      use MagentoFrameworkAppObjectManager;

      class Add

      public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)


      //Your customization is here for passing product name


      $subject->getResponse()->representJson(
      $objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result1)
      );
      return $result;







      share|improve this answer















      You have to override vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js..



      And you can add this below script in your override catalog-add-to-cart.js



       define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      ...
      ...
      ...
      var popup = $('<div class="themecafe-free-popup"/>').html('<h1>HTML Content</h1>').modal(
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      ...
      ...
      ...
      );


      EDIT



      define([
      'jquery',
      'mage/translate',
      'jquery/ui',
      'Magento_Ui/js/modal/modal',
      ], function ($, $t, modal)
      "use strict";
      $.widget('mage.catalogAddToCart',
      .....
      ajaxSubmit: function (form)
      var self = this;
      $(self.options.minicartSelector).trigger('contentLoading');
      self.disableAddToCartButton(form);
      $.ajax(
      url: form.attr('action'),
      data: form.serialize(),
      type: 'post',
      dataType: 'json',
      beforeSend: function ()
      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStart);

      ,
      success: function (res)

      if (self.isLoaderEnabled())
      $('body').trigger(self.options.processStop);


      if (res.backUrl)
      window.location = res.backUrl;
      return;

      if (res.messages)
      $(self.options.messagesSelector).html(res.messages);

      if (res.minicart)
      $(self.options.minicartSelector).replaceWith(res.minicart);
      $(self.options.minicartSelector).trigger('contentUpdated');

      if (res.product && res.product.statusText)
      $(self.options.productStatusSelector)
      .removeClass('available')
      .addClass('unavailable')
      .find('span')
      .html(res.product.statusText);

      self.enableAddToCartButton(form);
      //popup code start

      //for 2 option you can check you value is coming in `res` and get product name
      var popup = $('<div class="themecafe-free-popup"/>').html($('.page-title span').text()).modal( //get product name from product view page only
      modalClass: 'changelog',
      title: $.mage.__("Model Title"),
      buttons: [
      text: 'Continue Shopping',
      click: function ()
      this.closeModal();

      ]
      );
      popup.modal('openModal');
      //popup code end

      );
      ,
      ....
      );
      return $.mage.catalogAddToCart;
      );


      or



      Vendor/Module/etc/frontend/di.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutControllerCartAdd">
      <plugin name="name.of.block" type="VendorModulePluginCartAdd" sortOrder="10" />
      </type>
      </config>


      'Vendor/Module/Plugin/Cart/Add.php'



      <?php
      namespace VendorModulePluginCart;

      use MagentoFrameworkAppObjectManager;

      class Add

      public function afterExecute(MagentoCheckoutControllerCartAdd $subject, $result)


      //Your customization is here for passing product name


      $subject->getResponse()->representJson(
      $objectManager->get('MagentoFrameworkJsonHelperData')->jsonEncode($result1)
      );
      return $result;








      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jul 6 '18 at 5:40









      Nagaraju Kasa

      2,75821541




      2,75821541










      answered Dec 18 '16 at 12:38









      chiragchirag

      2,1511830




      2,1511830












      • Thanks a lot. But it didn't work.

        – Shakib Rahman
        Dec 19 '16 at 9:22











      • try my updated answer

        – chirag
        Dec 19 '16 at 9:27











      • Nothing is working. I don't have any idea how I can solve it.

        – Shakib Rahman
        Dec 19 '16 at 17:04











      • Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

        – chirag
        Dec 19 '16 at 18:27











      • How can we display product name in pop ?

        – Jai
        Feb 17 '17 at 6:12

















      • Thanks a lot. But it didn't work.

        – Shakib Rahman
        Dec 19 '16 at 9:22











      • try my updated answer

        – chirag
        Dec 19 '16 at 9:27











      • Nothing is working. I don't have any idea how I can solve it.

        – Shakib Rahman
        Dec 19 '16 at 17:04











      • Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

        – chirag
        Dec 19 '16 at 18:27











      • How can we display product name in pop ?

        – Jai
        Feb 17 '17 at 6:12
















      Thanks a lot. But it didn't work.

      – Shakib Rahman
      Dec 19 '16 at 9:22





      Thanks a lot. But it didn't work.

      – Shakib Rahman
      Dec 19 '16 at 9:22













      try my updated answer

      – chirag
      Dec 19 '16 at 9:27





      try my updated answer

      – chirag
      Dec 19 '16 at 9:27













      Nothing is working. I don't have any idea how I can solve it.

      – Shakib Rahman
      Dec 19 '16 at 17:04





      Nothing is working. I don't have any idea how I can solve it.

      – Shakib Rahman
      Dec 19 '16 at 17:04













      Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

      – chirag
      Dec 19 '16 at 18:27





      Check catalog-add-to-cart is successfully override or not and checm your updated code of js from opening js in browser through console.

      – chirag
      Dec 19 '16 at 18:27













      How can we display product name in pop ?

      – Jai
      Feb 17 '17 at 6:12





      How can we display product name in pop ?

      – Jai
      Feb 17 '17 at 6:12













      2














      In product page you can obtain it with this code.



      In vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml add at the end the modal div



      <div id="addtocart_modal" style="display: none;"></div>


      more, add the below attribute to the submit button with class="action primary tocart", so you could pass product name to the modal



      data-name="<?php echo $_product->getName() ?>"


      Now, in vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js after



      self.enableAddToCartButton(form);


      add the code to init the modal



      var cartUrl = url.build('checkout/cart');
      var modal_options =
      type: 'popup',
      buttons: [

      text: "&laquo; Continue shopping",
      class: 'primary btn-lg btn-info addtocart_modal_continue',
      click: function ()
      this.closeModal();
      return false;

      ,

      text: "Go to cart &raquo;",
      class: 'primary btn-lg btn-success addtocart_modal_gotocart',
      click: function ()
      location.href = cartUrl;
      return false;


      ]
      ;

      var popup = $('#addtocart_modal');
      var product_name = form.find("button").data("name");

      // reset modal content every time
      popup.html("");
      popup.append("<div>The product " + product_name + " is added to your cart</div>");
      popup.modal(modal_options);
      popup.modal('openModal');


      It's done! If you need this modal also in catalog page or everywhere there is an add to cart button keep this logic and adjust it.



      PS: override core files is a bad practice, so take in mind to override the files in your module/theme






      share|improve this answer





























        2














        In product page you can obtain it with this code.



        In vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml add at the end the modal div



        <div id="addtocart_modal" style="display: none;"></div>


        more, add the below attribute to the submit button with class="action primary tocart", so you could pass product name to the modal



        data-name="<?php echo $_product->getName() ?>"


        Now, in vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js after



        self.enableAddToCartButton(form);


        add the code to init the modal



        var cartUrl = url.build('checkout/cart');
        var modal_options =
        type: 'popup',
        buttons: [

        text: "&laquo; Continue shopping",
        class: 'primary btn-lg btn-info addtocart_modal_continue',
        click: function ()
        this.closeModal();
        return false;

        ,

        text: "Go to cart &raquo;",
        class: 'primary btn-lg btn-success addtocart_modal_gotocart',
        click: function ()
        location.href = cartUrl;
        return false;


        ]
        ;

        var popup = $('#addtocart_modal');
        var product_name = form.find("button").data("name");

        // reset modal content every time
        popup.html("");
        popup.append("<div>The product " + product_name + " is added to your cart</div>");
        popup.modal(modal_options);
        popup.modal('openModal');


        It's done! If you need this modal also in catalog page or everywhere there is an add to cart button keep this logic and adjust it.



        PS: override core files is a bad practice, so take in mind to override the files in your module/theme






        share|improve this answer



























          2












          2








          2







          In product page you can obtain it with this code.



          In vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml add at the end the modal div



          <div id="addtocart_modal" style="display: none;"></div>


          more, add the below attribute to the submit button with class="action primary tocart", so you could pass product name to the modal



          data-name="<?php echo $_product->getName() ?>"


          Now, in vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js after



          self.enableAddToCartButton(form);


          add the code to init the modal



          var cartUrl = url.build('checkout/cart');
          var modal_options =
          type: 'popup',
          buttons: [

          text: "&laquo; Continue shopping",
          class: 'primary btn-lg btn-info addtocart_modal_continue',
          click: function ()
          this.closeModal();
          return false;

          ,

          text: "Go to cart &raquo;",
          class: 'primary btn-lg btn-success addtocart_modal_gotocart',
          click: function ()
          location.href = cartUrl;
          return false;


          ]
          ;

          var popup = $('#addtocart_modal');
          var product_name = form.find("button").data("name");

          // reset modal content every time
          popup.html("");
          popup.append("<div>The product " + product_name + " is added to your cart</div>");
          popup.modal(modal_options);
          popup.modal('openModal');


          It's done! If you need this modal also in catalog page or everywhere there is an add to cart button keep this logic and adjust it.



          PS: override core files is a bad practice, so take in mind to override the files in your module/theme






          share|improve this answer















          In product page you can obtain it with this code.



          In vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml add at the end the modal div



          <div id="addtocart_modal" style="display: none;"></div>


          more, add the below attribute to the submit button with class="action primary tocart", so you could pass product name to the modal



          data-name="<?php echo $_product->getName() ?>"


          Now, in vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js after



          self.enableAddToCartButton(form);


          add the code to init the modal



          var cartUrl = url.build('checkout/cart');
          var modal_options =
          type: 'popup',
          buttons: [

          text: "&laquo; Continue shopping",
          class: 'primary btn-lg btn-info addtocart_modal_continue',
          click: function ()
          this.closeModal();
          return false;

          ,

          text: "Go to cart &raquo;",
          class: 'primary btn-lg btn-success addtocart_modal_gotocart',
          click: function ()
          location.href = cartUrl;
          return false;


          ]
          ;

          var popup = $('#addtocart_modal');
          var product_name = form.find("button").data("name");

          // reset modal content every time
          popup.html("");
          popup.append("<div>The product " + product_name + " is added to your cart</div>");
          popup.modal(modal_options);
          popup.modal('openModal');


          It's done! If you need this modal also in catalog page or everywhere there is an add to cart button keep this logic and adjust it.



          PS: override core files is a bad practice, so take in mind to override the files in your module/theme







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 10 '18 at 9:46

























          answered Feb 9 '18 at 18:31









          LucScuLucScu

          1,3731230




          1,3731230





















              0














              you can try the free extension Shopping Cart Notifications Magento 2 by MageWorkshop. I hope that solve your issue in a simple way.



              https://mageworkshop.com/shopping-cart-notifications-magento-2.html






              share|improve this answer



























                0














                you can try the free extension Shopping Cart Notifications Magento 2 by MageWorkshop. I hope that solve your issue in a simple way.



                https://mageworkshop.com/shopping-cart-notifications-magento-2.html






                share|improve this answer

























                  0












                  0








                  0







                  you can try the free extension Shopping Cart Notifications Magento 2 by MageWorkshop. I hope that solve your issue in a simple way.



                  https://mageworkshop.com/shopping-cart-notifications-magento-2.html






                  share|improve this answer













                  you can try the free extension Shopping Cart Notifications Magento 2 by MageWorkshop. I hope that solve your issue in a simple way.



                  https://mageworkshop.com/shopping-cart-notifications-magento-2.html







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 13 hours ago









                  Alex GrammAlex Gramm

                  12




                  12



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f150794%2fi-want-to-add-popup-notify-after-adding-products-magento-2%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

                      Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                      How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2