Commit bff42af5 by lmf

移除fb聊天插件

parent 9115ed68
<?php
/**
* Provider: Meetanshi.
* Package: Meetanshi Messenger
* Support: support@meetanshi.com (https://meetanshi.com/)
*/
namespace Meetanshi\FacebookChat\Block;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Color extends Field {
protected $_coreRegistry;
public function __construct(
Context $context,
Registry $coreRegistry,
array $data = []
) {
$this->_coreRegistry = $coreRegistry;
parent::__construct($context, $data);
}
protected function _getElementHtml(AbstractElement $element) {
$html = $element->getElementHtml();
$cpPath=$this->getViewFileUrl('Meetanshi_FacebookChat::js');
if (!$this->_coreRegistry->registry('colorpicker_loaded')) {
$html .= '<script type="text/javascript" src="' . $cpPath.'/'.'jscolor.js"></script>';
$this->_coreRegistry->registry('colorpicker_loaded', 1);
}
$html .= '<script type="text/javascript">
var el = document.getElementById("' . $element->getHtmlId() . '");
el.className = el.className + " jscolor{hash:true}";
</script>';
return $html;
}
}
<?php
namespace Meetanshi\FacebookChat\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Meetanshi\FacebookChat\Helper\Data;
class Messenger extends Template
{
protected $helperData;
public function __construct(
Context $context,
Data $helperData
)
{
parent::__construct($context);
$this->helperData = $helperData;
}
}
<?php
namespace Meetanshi\FacebookChat\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\ScopeInterface;
class Data extends AbstractHelper
{
const XML_FB_MESSENGER_ENABLE = 'messenger/general/enable';
const XML_FB_APP_ID = 'messenger/general/app_id';
const XML_FB_PAGE_ID = 'messenger/general/page_id';
const XML_FB_COLOR = 'messenger/general/color_option';
const XML_FB_LOGIN_TEXT = 'messenger/general/login_message';
const XML_FB_LOGOUT_TEXT = 'messenger/general/logout_message';
public function isEnable($storeId = null)
{
return $this->scopeConfig->getValue(
self::XML_FB_MESSENGER_ENABLE,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
public function getFBAppId($storeId = null){
return $this->scopeConfig->getValue(
self::XML_FB_APP_ID,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
public function getFBPageId($storeId = null){
return $this->scopeConfig->getValue(
self::XML_FB_PAGE_ID,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
public function getFBColor($storeId = null){
return $this->scopeConfig->getValue(
self::XML_FB_COLOR,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
public function getFBLoginText($storeId = null){
return $this->scopeConfig->getValue(
self::XML_FB_LOGIN_TEXT,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
public function getFBLogoutText($storeId = null){
return $this->scopeConfig->getValue(
self::XML_FB_LOGOUT_TEXT,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
}
# Magento 2 Facebook Chat
Ever since Facebook has introduced its independent messaging app, i.e., Messenger, it has served an increasing number of people, reaching 1.3 billion users every month! It is beneficial to make the most out of such a popular messaging app in Magento 2 store. Meetanshi's [***Magento 2 Facebook Chat***](https://meetanshi.com/magento-2-facebook-chat.html) extension allows integrating messenger with Magento 2 for live chat support via messenger.
Improve communication with customers. Offer excellent live chat support via the popular platform, i.e., Facebook. Solve customers’ queries quickly. Everything with Magento 2 Facebook Chat!
Offer improved customer experience with the help of the Facebook Messenger Live Support for Magento 2. Chat with your customers in their preferred platform, i.e., Facebook Messenger! With the friendly app for direct communication, build better customer relationship and earn their trust!
## Benefits of choosing Meetanshi's Magento 2 Facebook Chat extension:
* Direct communication with customers.
* Offer a quick solution to customers’ queries.
* Add Facebook App ID and Page ID to enable the messenger.
* Set theme color of the FB chat icon and chat window.
* Customize the message for the FB messenger login and logout greeting text.
* Allow customers to use their own Facebook account for contacting for the solution to their queries.
Visit, to know more: [https://meetanshi.com/magento-2-facebook-chat.html](https://meetanshi.com/magento-2-facebook-chat.html)
{
"name": "meetanshi/magento2-facebook-chat",
"description": "Magento 2 Facebook Chat",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.0"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"authors": [
{
"name": "Meetanshi",
"email": "support@meetanshi.com",
"homepage": "https://meetanshi.com"
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Meetanshi\\FacebookChat\\": ""
}
}
}
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Meetanshi_FacebookChat::messenger_config" title="FaceBook Chat" sortOrder="10"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="meetanshi" translate="label" sortOrder="100">
<label>FacebookChat</label>
</tab>
<section id="messenger" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Facebook Chat</label>
<tab>meetanshi</tab>
<resource>Meetanshi_FacebookChat::messenger_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Configuration</label>
<field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Facebook Chat</label>
<source_model>Magento\Config\Model\Config\Source\Enabledisable</source_model>
</field>
<field id="app_id" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Facebook App ID</label>
<validate>required-entry</validate>
<comment><![CDATA[Generate App Id using : <a href="https://developers.facebook.com/apps" target="_blank">https://developers.facebook.com/apps</a>]]></comment>
<depends>
<field id="enable">1</field>
</depends>
</field>
<field id="page_id" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Facebook Page ID</label>
<validate>required-entry</validate>
<comment><![CDATA[Generate Page Id : GoTo Page -> Setting -> Page info]]></comment>
<depends>
<field id="enable">1</field>
</depends>
</field>
<field id="color_option" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Theme Color</label>
<frontend_model>Meetanshi\FacebookChat\Block\Color</frontend_model>
<validate>color</validate>
<comment><![CDATA[]]></comment>
<depends>
<field id="enable">1</field>
</depends>
</field>
<field id="login_message" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Login Greeting Text</label>
<comment><![CDATA[]]></comment>
<depends>
<field id="enable">1</field>
</depends>
</field>
<field id="logout_message" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Logout Greeting Text</label>
<comment><![CDATA[]]></comment>
<depends>
<field id="enable">1</field>
</depends>
</field>
</group>
</section>
</system>
</config>
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<messenger>
<general>
<enable>0</enable>
</general>
</messenger>
</default>
</config>
\ No newline at end of file
<?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="Meetanshi_FacebookChat" setup_version="1.0.0">
</module>
</config>
<?php
/**
* Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
*
* Glory to Ukraine! Glory to the heroes!
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Meetanshi_FacebookChat',
__DIR__
);
<referenceContainer name="footer-container">
<container name="footer" as="footer" label="Page Footer" htmlTag="div" htmlClass="footer content">
<block class="Meetanshi\FacebookChat\Block\Messenger" name="custom_block" as="custom_block" template="Meetanshi_FacebookChat::messenger_script.phtml"/>
</container>
</referenceContainer>
<?php
$helper = $this->helper('Meetanshi\FacebookChat\Helper\Data');
$enable = $helper->isEnable();
$appId = $helper->getFBAppId();
$pageId = $helper->getFBPageId();
$color = $helper->getFBColor();
$loginText = $helper->getFBLoginText();
$logoutText = $helper->getFBLogoutText();
if($enable){
if (empty($loginText)){
$loginText = 'Hi! What can i Help you?';
}
if (empty($logoutText)){
$logoutText = 'Hi! What can i Help you?';
}
?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $appId;?>',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-customerchat"
attribution=setup_tool
page_id="<?php echo $pageId;?>"
theme_color="<?php echo $color;?>"
logged_in_greeting="<?php echo $loginText;?>"
logged_out_greeting="<?php echo $logoutText;?>"
</div>
<?php
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment