I need to change add to cart success message after adding product into cart through plugin.

Currently i have used below code for override cart method and its working fine.

<preference for="Magento\Checkout\Controller\Cart\Add" type="CustomPackage\Checkout\Controller\Magento\Checkout\Cart\Add" />

but i need to go through plugin so how can i do that ? I seen some documentation and in plugin its used aroundExecute method.

so i don't understand that how my code execute without use Add method ? and how can i edit success message ?

I need to below message :

    $message = __('This Product has been added to your Shopping Cart. 
    Click here to view your <a href="%1">Shopping Cart</a>. 
    or you can <a href="%2">Continue Shopping.</a> <a href="javascript:void(0);" class="close-message">close</span>', $this->_objectManager->get('Magento\Checkout\Helper\Cart')->getCartUrl(),$this->_storeManager->getStore()->getBaseUrl());

any idea please share.

  • what you want to change in message? – kunj Jun 5 '18 at 12:50
  • 1
    i need change some text in success message : $message = __('This Product has b......, $this->_objectManager->get('Magento\Checkout\Helper\Cart')->getCartUrl(),$this->_storeManager->getStore()->getBaseUrl() – Camit1dk Jun 5 '18 at 12:53
  • this message have one checkout url also. so can't use translation. – Camit1dk Jun 5 '18 at 12:54
  • Please share that message. so, you want to translate only message, right? – kunj Jun 5 '18 at 13:02
  • i updated my question. please check., – Camit1dk Jun 5 '18 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.