Basically I have a checkbox on customer/account page adding via code below.


    <div class="col-12 col-sm-12">
                <div class="flex-card myaccount-block proofing-block">
                    <div class="col-lg-3 float-left">
                    <img src="/pub/media/images/myaccount/auto-proofing.png" alt="Automatic Proofing Approval Options" />
                    <div class="col-lg-6 float-left">
                        <strong class="box-title">
                            <span><?= $block->escapeHtml(__('Automatic Proofing Approval Options')) ?></span>
                        <div class="box-content">
                            <p><?= $block->escapeHtml(__('
                            By default, once your file is preflighted OK, you will have 1 hour to approve or make changes to your file. If no action is taken within this hour, your order will automatically go into production.')) ?>
                            <a href="#" id="proof-learnmore">Learn More..</a>
                    <div class="col-lg-3 float-left">
                        <span class="yesno-label">Yes</span>
                        <div class="box-actions">
                                <label class="proof-switch">
                                <input type="checkbox">
                                <span class="slider round"></span></label>
                        <span class="yesno-label">No</span>

How can I create a functionality so whenever user check/uncheck this checkbox it will call an observer/controller which will pass the value(customer_email) to Magento backend and change the newsletter subscription status?

I hope I am on the right track of understanding cause this is what I am planning to implement. I am still not sure whether I will need a block or not.

Please, anyone, guide me through this it would be really helpful for me to continue my learning and understand Magento 2. Thank you and cheers. Though I am trying my best to implement this and update here if something relevant enter image description here

  • app\code\Company\Customer\Controller\Account\Index.php is the file where I have created my custom function which will get called when the check box is checked or not and it will reload the page but for this function to get called how can I make an ajax request from app\design\frontend\Company\porto_base_child\Magento_Customer\templates\account\dashboard\info.phtml passing the checkbox value as parameter.
    – J. Doe
    Jul 8, 2020 at 13:37


Your Answer

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