0

I would like to change the text and button value of the Mage2's default cookie policy popup.

See how it looks now: https://i.stack.imgur.com/hWWmp.jpg

I would like it to read some different text and have a different button text.

How would I do this?

Thanks!

3 Answers 3

9

Try following:

Copy file to your frontend theme and update text as you want.

FROM: 
vendor/magento/module-cookie/view/frontend/templates/html/notices.phtml

TO: 
app/design/frontend/[VendorName]/[themename]/Magento_Cookie/templates/html/notices.phtml
1
  • how to do it by custom module can u please provide me the steps plz Feb 4, 2020 at 13:40
1

You can find text in below template location :

/app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml

To change that you should copy notices.phtml file and save this in your theme folder and update as you want.

0

for future coders: you need to override the notices.phtml file in your custom Module or custom theme and to do that you need two steps:

  1. in view/frontend/layout/default.xml you reference the cookie container and the notice block ,and through the method setTemplate, you specify your own new notices.phtml like this:

                <referenceBlock name="cookie_notices">
                    <action method="setTemplate">
                        <argument name="template" xsi:type="string">
         Vendor_CustomModule::folder name/notices.phtml
                        </argument>
                    </action>
                </referenceBlock>
     </referenceContainer>
    
  2. now you can copy the notices.phmtl contents from the Magento Module "module-cookie/view/frontend/templates/html/notices.phtml" into your own overriden notices.phtml and change the text and button as you wish.

P.S. as your setting the template in default.xml the starting point is your templates folder, so if we take as an example the magento phtml file the folder name would be html.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.