- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023
02:38 AM
03-10-2023
02:38 AM
customizing the default magento 2 contact form department wise
Hi
my client has a team of 1000+ employees with minimum of 100+ employees in each department. i want to customize the contact form to add the department field selection, so that each department receives only related contact inquiries. I'm ready to pay for the readymade solution for this if available. I'm in a bit hurry to implement customization of the contact form, please help me with solution.
thanks in advance
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023
05:31 AM
03-10-2023
05:31 AM
Re: customizing the default magento 2 contact form department wise
There are some Magento Extensions that may be able to help you out with this feature set. Check out:
- https://marketplace.magento.com/meetanshi-magento-2-custom-contact-form.html
- https://marketplace.magento.com/zestardtech-module-advancedcontactform.html
- https://marketplace.magento.com/magezon-module-blueformbuilder-core.html
- https://marketplace.magento.com/aheadworks-module-helpdesk-subscription.html
Best of luck!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023
03:23 AM
12-18-2023
03:23 AM
Re: customizing the default magento 2 contact form department wise
Hi @hohodo40184672,
To customize the default Magento 2 contact form department-wise programmatically, The basic idea is that you can create a custom module and override the default behavior of the contact form. Here are the general steps you can follow:
Create a Magento 2 Module:
- Create a new module in your Magento 2 installation. Let's name it Custom_ContactForm.
Create the following directory structure:
app/code/Custom/ContactForm
Create Module Files:
Create the registration file:
app/code/Custom/ContactForm/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Custom_ContactForm', __DIR__ );
Create the module declaration file:
app/code/Custom/ContactForm/etc/module.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Custom_ContactForm" setup_version="1.0.0"> <sequence> <module name="Magento_Contact"/> </sequence> </module> </config>
Create A Plugin for the Contact Form:
Create a file for the plugin:
app/code/Custom/ContactForm/Plugin/ContactPost.php
<?php namespace Custom\ContactForm\Plugin; class ContactPost { public function aroundExecute( \Magento\Contact\Controller\Index\Post $subject, \Closure $proceed ) { // Your customization logic goes here // Call the original method $result = $proceed(); return $result; } }
Customize the Contact Form logic:
Update the aroundExecute method in the ContactPost plugin to customize the contact form logic based on departments. You can use the request data to identify the selected department and perform your customization.
// Inside the aroundExecute method $request = $subject->getRequest(); $department = $request->getParam('department'); // Implement your logic based on the selected department if ($department == 'sales') { // Customize for the Sales department } elseif ($department == 'support') { // Customize for the Support department } // Call the original method $result = $proceed(); return $result;
Configure the Plugin:
Create a configuration file for the module:
app/code/Custom/ContactForm/etc/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="Magento\Contact\Controller\Index\Post"> <plugin name="custom_contactform_contactpost" type="Custom\ContactForm\Plugin\ContactPost" sortOrder="1"/> </type> </config>
Run Setup Commands:
php bin/magento setup:upgrade php bin/magento cache:flush
Now, your custom module should override the default behavior of the Magento 2 contact form based on the selected department. Adjust the code in the ContactPost plugin according to your specific requirements and business logic.
If you have any question regarding this then please browse our Hire Magento Developer page we can discuss further in details.