From 82627ff11c7e08012dad49923e96ff280b5aba62 Mon Sep 17 00:00:00 2001 From: landofcoder Date: Fri, 6 Sep 2019 11:42:44 +0700 Subject: [PATCH 1/4] updated --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c553b00 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# magento2-account-approval +###### What is this extension about? +Free magento 2 extension to add new custom fields for customer example: avatar, facebook link, twitter link, ... + + +###### Install Extension +``` +composer require landofcoder/module-custom-customer-info +php bin/magento module:enable Lof_CustomCustomerInfo +php bin/magento setup:upgrade +php bin/magento setup:static-content:deploy -f +php bin/magento cache:clean +``` + +###### Enable extension +Enable extension by navigation to ```Stores => Configuration => Landofcoder => Custom Customer Info``` From 42f0f4de671b3cb4ea2c058d6ce76c63cee72a45 Mon Sep 17 00:00:00 2001 From: landofcoder Date: Fri, 6 Sep 2019 14:19:02 +0700 Subject: [PATCH 2/4] updated files --- Helper/Data.php | 48 ++++++++++- .../Patch/Data/AddAvatarCustomerAttribute.php | 2 +- Setup/Patch/Data/AddBioCustomerAttribute.php | 2 +- .../Data/AddCustomerIdCustomerAttribute.php | 2 +- .../Data/AddFacebookCustomerAttribute.php | 2 +- Setup/Patch/Data/AddJobCustomerAttribute.php | 2 +- .../Data/AddTwitterCustomerAttribute.php | 2 +- etc/adminhtml/system.xml | 47 ++++++++++- etc/config.xml | 4 +- .../templates/additionalfieldregister.phtml | 62 ++++++++++----- view/frontend/templates/customeredit.phtml | 79 +++++++++++++------ 11 files changed, 198 insertions(+), 54 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 72debea..1e019e1 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -28,6 +28,12 @@ class Data extends AbstractHelper { + /** + * @param \Magento\Framework\App\Helper\Context $context + */ + + protected $scopeConfig; + const XML_PATH_TAG = 'lofcustomcustomerinfo/'; /** * @param \Magento\Framework\App\Helper\Context $context */ @@ -42,6 +48,46 @@ public function __construct( */ public function isEnabled() { - return true; + if($this->getGeneralConfig("enabled")){ + return true; + } + return false; + } + /** + * @return bool + */ + public function isEnabledOnRegister() + { + if($this->getGeneralConfig("enabled_customer_register_page")){ + return true; + } + return false; + } + /** + * @return bool + */ + public function isEnabledOnEditCustomer() + { + if($this->getGeneralConfig("enabled_edit_page")){ + return true; + } + return false; + } + /** + * @return bool + */ + public function getConfigValue($field, $storeId = null) + { + return $this->scopeConfig->getValue( + $field, ScopeInterface::SCOPE_STORE, $storeId + ); + } + public function getGeneralConfig($code, $storeId = null) + { + return $this->getConfigValue(self::XML_PATH_TAG .'general/'. $code, $storeId); } + public function getFieldConfig($code, $storeId = null) + { + return $this->getConfigValue(self::XML_PATH_TAG .'custom_fields/'. $code, $storeId); + } } diff --git a/Setup/Patch/Data/AddAvatarCustomerAttribute.php b/Setup/Patch/Data/AddAvatarCustomerAttribute.php index dae456e..054497c 100644 --- a/Setup/Patch/Data/AddAvatarCustomerAttribute.php +++ b/Setup/Patch/Data/AddAvatarCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'avatar', 'input' => 'text', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/Setup/Patch/Data/AddBioCustomerAttribute.php b/Setup/Patch/Data/AddBioCustomerAttribute.php index e1ca634..e6db80f 100644 --- a/Setup/Patch/Data/AddBioCustomerAttribute.php +++ b/Setup/Patch/Data/AddBioCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'bio', 'input' => 'textarea', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/Setup/Patch/Data/AddCustomerIdCustomerAttribute.php b/Setup/Patch/Data/AddCustomerIdCustomerAttribute.php index f0d601a..f3ed4ef 100644 --- a/Setup/Patch/Data/AddCustomerIdCustomerAttribute.php +++ b/Setup/Patch/Data/AddCustomerIdCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'customer_id', 'input' => 'text', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/Setup/Patch/Data/AddFacebookCustomerAttribute.php b/Setup/Patch/Data/AddFacebookCustomerAttribute.php index 1cfa29f..8c3c07f 100644 --- a/Setup/Patch/Data/AddFacebookCustomerAttribute.php +++ b/Setup/Patch/Data/AddFacebookCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'facebook', 'input' => 'text', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/Setup/Patch/Data/AddJobCustomerAttribute.php b/Setup/Patch/Data/AddJobCustomerAttribute.php index 2b32d98..769f37a 100644 --- a/Setup/Patch/Data/AddJobCustomerAttribute.php +++ b/Setup/Patch/Data/AddJobCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'job', 'input' => 'text', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/Setup/Patch/Data/AddTwitterCustomerAttribute.php b/Setup/Patch/Data/AddTwitterCustomerAttribute.php index 9bbeb65..937606b 100644 --- a/Setup/Patch/Data/AddTwitterCustomerAttribute.php +++ b/Setup/Patch/Data/AddTwitterCustomerAttribute.php @@ -71,7 +71,7 @@ public function apply() 'label' => 'twitter', 'input' => 'text', 'source' => '', - 'required' => true, + 'required' => false, 'visible' => true, 'position' => 333, 'system' => false, diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c368960..fb7350f 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -4,8 +4,8 @@ -
- +
+ landofcoder Lof_CustomCustomerInfo::config_lof_customcustomerinfo @@ -15,6 +15,49 @@ Magento\Config\Model\Config\Source\Yesno + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno +
diff --git a/etc/config.xml b/etc/config.xml index fd99bbf..f4a5e95 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,10 +1,10 @@ - + - + diff --git a/view/frontend/templates/additionalfieldregister.phtml b/view/frontend/templates/additionalfieldregister.phtml index f956466..9064e45 100644 --- a/view/frontend/templates/additionalfieldregister.phtml +++ b/view/frontend/templates/additionalfieldregister.phtml @@ -1,51 +1,75 @@ - + \ No newline at end of file diff --git a/view/frontend/templates/customeredit.phtml b/view/frontend/templates/customeredit.phtml index 7474f9b..d802f50 100644 --- a/view/frontend/templates/customeredit.phtml +++ b/view/frontend/templates/customeredit.phtml @@ -1,34 +1,65 @@ - -get('Magento\Customer\Model\Session'); ?> +get('Magento\Customer\Model\Session'); +$helper = $objm->get('Lof\CustomCustomerInfo\Helper\Data'); +if($helper->isEnabled() && $helper->isEnabledOnRegister()){ +$enabled_facebook = $helper->getFieldConfig("enabled_facebook"); +$enabled_twitter = $helper->getFieldConfig("enabled_twitter"); +$enabled_job = $helper->getFieldConfig("enabled_job"); +$enabled_custom_id = $helper->getFieldConfig("enabled_custom_id"); +$enabled_bio = $helper->getFieldConfig("enabled_bio"); +$enabled_avatar = $helper->getFieldConfig("enabled_avatar"); +?>
-?>"> -
- -
-
+ + +
+ +
+
+
-
- -
-
-

+ + +
+ +
+
+
+
+ + +
- -

+ +
+
+ + +
- -

+ +
+
+ + +
- -

+ +
+ + + +
- +
+ +
+
+ -
\ No newline at end of file + + \ No newline at end of file From 37e45e9fb12a7d7e8c22b61f6c6e4e9a96fb20c5 Mon Sep 17 00:00:00 2001 From: landofcoder Date: Fri, 6 Sep 2019 15:27:39 +0700 Subject: [PATCH 3/4] updated helper data --- Helper/Data.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Helper/Data.php b/Helper/Data.php index 1e019e1..ab3b66e 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -24,6 +24,9 @@ namespace Lof\CustomCustomerInfo\Helper; use Magento\Framework\App\Helper\AbstractHelper; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Store\Model\ScopeInterface; +use Magento\Framework\App\Helper\Context; class Data extends AbstractHelper { From 11427276538199d3bc217795637bab4956c529bf Mon Sep 17 00:00:00 2001 From: landofcoder Date: Fri, 6 Sep 2019 15:39:03 +0700 Subject: [PATCH 4/4] updated --- view/frontend/templates/additionalfieldregister.phtml | 4 ++-- view/frontend/templates/customeredit.phtml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/view/frontend/templates/additionalfieldregister.phtml b/view/frontend/templates/additionalfieldregister.phtml index 9064e45..7efcbde 100644 --- a/view/frontend/templates/additionalfieldregister.phtml +++ b/view/frontend/templates/additionalfieldregister.phtml @@ -47,9 +47,9 @@ $enabled_avatar = $helper->getFieldConfig("enabled_avatar"); - +