5

I am trying to add Captcha inside product review form. For that i add

<referenceContainer name="form.additional.info">
            <block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
                <action method="setFormId">
                    <argument name="formId" xsi:type="string">user_login</argument>
                </action>
                <action method="setImgWidth">
                    <argument name="width" xsi:type="string">230</argument>
                </action>
                <action method="setImgHeight">
                    <argument name="width" xsi:type="string">50</argument>
                </action>
            </block>
        </referenceContainer>
        <referenceBlock name="head.components">
            <block class="Magento\Framework\View\Element\Js\Components" name="captcha_page_head_components" template="Magento_Captcha::js/components.phtml"/>
        </referenceBlock>

in theme/Magento_Review/layout/catalog_product_view.xml file. and after that i am calling it in /theme/Magento_review/template/form.phtml file like

<?php echo $block->getLayout()->getBlock('form.additional.info')->toHtml(); ?> But after that no captcha is showing in the review form. Please help me to do it. Thanks

13
  • 1
    May be you can find answer here: magento.stackexchange.com/questions/133238/… Commented Nov 26, 2016 at 6:21
  • are there any way to implement it without creating custom module?
    – Yudi
    Commented Nov 26, 2016 at 6:22
  • No magento not providing inbuilt captcha for product review form. You can see config at stores/config/customers/customer config in admin panel Commented Nov 26, 2016 at 6:32
  • You need to see how it works Commented Nov 26, 2016 at 6:32
  • @Yudi can you tell the solution ? I am struggling not getting clear idea how it works. Commented Jan 10, 2017 at 18:25

2 Answers 2

1

To use google reCaptch : Go to Admin -> Store -> Configuration -> Security Tab -> Google reCaptcha -> Frontend -> Enabled = Yes

Use in Review = select Yes

Add getChildHtml('form.additional.info') ?> in your theme's Magento_Review /templates/form.phtml file.

0

To add google reCaptcha in the product review form please check the following steps:

  • Step 1: Go to Admin > Stores > Settings > Configuration > Security Tab > Google reCaptcha Storefront
  • Step 2: Fill out the section of reCAPTCHA type(s) as per your requirement, you can check about this in detail from https://docs.magento.com/user-guide/stores/security-google-recaptcha.html
  • Step 3: From Storefront section, uncheck the Use system value checkbox for Enable for Product Review location field and set it to the reCAPTCHA type that you have configured in the last step.
  • Step 4: After Completion, Save Config and Check.
  • Magento 2 have added 'recaptcha' block in 'product.review.form.fields.before' container of product review form's block and it's called from \vendor\magento\module-review\view\frontend\templates\form.phtml file as 'getChildHtml('form_fields_before') ?>'

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.