Skip to content

Commit eb05cc9

Browse files
committed
added files
0 parents  commit eb05cc9

File tree

8 files changed

+187
-0
lines changed

8 files changed

+187
-0
lines changed

Observer/NewChat.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Landofcoder
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Landofcoder.com license that is
8+
* available through the world-wide-web at this URL:
9+
* https://landofcoder.com/terms
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Landofcoder
17+
* @package Lof_ChatNotification
18+
* @copyright Copyright (c) 2022 Landofcoder (https://www.landofcoder.com/)
19+
* @license https://landofcoder.com/terms
20+
*/
21+
22+
namespace Lof\ChatNotification\Observer;
23+
use Magento\Framework\Event\ObserverInterface;
24+
25+
class NewContact implements ObserverInterface
26+
{
27+
28+
/**
29+
* @var Slack
30+
*/
31+
protected $slack;
32+
33+
/**
34+
* @var \Magento\Store\Model\StoreManagerInterface
35+
*/
36+
protected $storeManager;
37+
38+
public function __construct(
39+
Slack $slack,
40+
\Magento\Store\Model\StoreManagerInterface $storeManager
41+
) {
42+
$this->slack = $slack;
43+
$this->storeManager = $storeManager;
44+
}
45+
46+
/**
47+
* @inheritdoc
48+
*/
49+
public function execute(\Magento\Framework\Event\Observer $observer)
50+
{
51+
$event = $observer->getEvent();
52+
$data = $event->getData();
53+
$isNew = $event->getIsNew();
54+
if ($isNew && !empty($data)) {
55+
$chatData = [];
56+
$chatData['customerName'] = $data['customer_name'];
57+
$chatData['email'] = $data['customer_email'];
58+
$chatData['comment'] = $data['body_msg'];
59+
$chatData['store'] = $this->storeManager->getStore()->getName();
60+
$this->slack->sendMessage("new_chat", $chatData);
61+
}
62+
}
63+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Magento 2 Slack Integration FREE

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "landofcoder/module-chat-notification-slack",
3+
"description": "Magento 2 Notify New Chat to Slack Integration extension",
4+
"require": {
5+
"landofcoder/module-all": "^1.*",
6+
"landofcoder/module-slack-integration": "^2.*",
7+
"landofcoder/module-chat-system": "^1.*"
8+
},
9+
"type": "magento2-module",
10+
"version": "1.0.0",
11+
"license": "proprietary",
12+
"authors": [
13+
{
14+
"name": "Landofcoder",
15+
"email": "info@landofcoder.com",
16+
"homepage": "https://landofcoder.com",
17+
"role": "eCommerce Solution provider"
18+
}
19+
],
20+
"autoload": {
21+
"files": [
22+
"registration.php"
23+
],
24+
"psr-4": {
25+
"Lof\\ChatNotification\\": ""
26+
}
27+
}
28+
}

etc/adminhtml/system.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
4+
<system>
5+
<section id="lof_slack_integration" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
6+
<group id="new_chat_notification" translate="label" type="text" sortOrder="55" showInDefault="1" showInWebsite="0" showInStore="0">
7+
<label>New Chat Message Notification</label>
8+
<field id="enable" translate="label comment" type="checkbox" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
9+
<label>Enable</label>
10+
<frontend_model>Lof\SlackIntegration\Block\Adminhtml\System\Config\Checkbox</frontend_model>
11+
</field>
12+
<field id="channel" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
13+
<label>Channel</label>
14+
</field>
15+
<field id="color" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
16+
<label>Color</label>
17+
<frontend_model>Lof\SlackIntegration\Block\Adminhtml\System\Config\Form\Field\Color</frontend_model>
18+
</field>
19+
</group>
20+
</section>
21+
</system>
22+
</config>

etc/config.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Landofcoder
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Landofcoder.com license that is
9+
* available through the world-wide-web at this URL:
10+
* https://landofcoder.com/terms
11+
*
12+
* DISCLAIMER
13+
*
14+
* Do not edit or add to this file if you wish to upgrade this extension to newer
15+
* version in the future.
16+
*
17+
* @category Landofcoder
18+
* @package Lof_ChatNotification
19+
* @copyright Copyright (c) 2022 Landofcoder (https://www.landofcoder.com/)
20+
* @license https://landofcoder.com/terms
21+
*/
22+
-->
23+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
24+
<default>
25+
<lof_slack_integration>
26+
<new_chat_notification>
27+
<enable>1</enable>
28+
<color>#ff0000</color>
29+
</new_chat_notification>
30+
</lof_slack_integration>
31+
</default>
32+
</config>

etc/events.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
3+
<event name="lof_chatsystem_new_message">
4+
<observer name="lof_slack_integration_new_chat" instance="Lof\ChatNotification\Observer\NewChat" />
5+
</event>
6+
</config>

etc/module.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
4+
<module name="Lof_ChatNotification" setup_version="1.0.0">
5+
<sequence>
6+
<module name="Lof_ChatSystem"/>
7+
<module name="Lof_SlackIntegration"/>
8+
</sequence>
9+
</module>
10+
</config>

registration.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Landofcoder
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Landofcoder.com license that is
8+
* available through the world-wide-web at this URL:
9+
* https://landofcoder.com/terms
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Landofcoder
17+
* @package Lof_ChatNotification
18+
* @copyright Copyright (c) 2022 Landofcoder (https://www.landofcoder.com/)
19+
* @license https://landofcoder.com/terms
20+
*/
21+
\Magento\Framework\Component\ComponentRegistrar::register(
22+
\Magento\Framework\Component\ComponentRegistrar::MODULE,
23+
'Lof_ChatNotification',
24+
__DIR__
25+
);

0 commit comments

Comments
 (0)