├── LICENSE ├── README.md ├── composer.json ├── docs ├── admin-follows-customer.png ├── admin-hello.png ├── admin-join-session.png ├── admin-joined-session.png ├── admin-list.png ├── admin-product-suggesion.png ├── awaiting-assistant-profile.png ├── awaiting-assistant.png ├── customer-assistant-arrived.png ├── customer-follow-admin.png └── request-assistant.png ├── modman └── src ├── app ├── code │ └── community │ │ └── Meanbee │ │ └── ShoppingAssistant │ │ ├── Block │ │ ├── Adminhtml │ │ │ ├── Request.php │ │ │ └── Request │ │ │ │ └── Grid.php │ │ └── Button.php │ │ ├── Helper │ │ ├── Config.php │ │ └── Data.php │ │ ├── Model │ │ ├── Request.php │ │ └── Resource │ │ │ ├── Request.php │ │ │ └── Request │ │ │ └── Collection.php │ │ ├── controllers │ │ ├── Adminhtml │ │ │ └── Shopping │ │ │ │ └── AssistantController.php │ │ └── RequestController.php │ │ ├── etc │ │ ├── adminhtml.xml │ │ ├── config.xml │ │ └── system.xml │ │ └── sql │ │ └── meanbee_shoppingassistant_setup │ │ ├── install-1.0.0.php │ │ └── upgrade-1.0.0-1.0.1.php ├── design │ └── frontend │ │ └── base │ │ └── default │ │ ├── layout │ │ └── meanbee │ │ │ └── shoppingassistant.xml │ │ └── template │ │ └── meanbee │ │ └── shoppingassistant │ │ ├── button.phtml │ │ └── scripts.phtml └── etc │ └── modules │ └── Meanbee_ShoppingAssistant.xml ├── js └── Meanbee │ └── ShoppingAssistant │ └── magentoShoppingAssistant.js └── skin └── frontend └── base └── default └── css └── meanbee └── shoppingassistant.css /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Meanbee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento Shopping Assistant 2 | 3 | 4 | This magento extensions uses TogetherJS to create a virtual shopping assistant. Provide customers with the ability to call over a virtual shopping asssistant. 5 | 6 | The store owner can then join the customer, follow them as they browse around the site, chat with text or voice (using WebRTC) and make suggestions. 7 | 8 | This is much more than a live chat client, it actually helps customers and sales advisors browse the site together and consider products. A much closer representation to the physical store experience. 9 | 10 | ## Demo 11 | 12 | A customer browsing a category page can click the "Request shopping assistant" button at the bottom of the page. 13 | 14 | ![Customer requests assistance](docs/request-assistant.png) 15 | 16 | Once clicked, the button updates to indicate that they are awaiting an assistant 17 | 18 | ![Customer view of awaiting assistant](docs/awaiting-assistant.png) 19 | 20 | As the customer is logged in, we have been able to set up the session with a gravatar from their email address and their name from their Magento account. 21 | 22 | ![Customer profile](docs/awaiting-assistant-profile.png) 23 | 24 | The store owner views the shopping assistant requets in admin. 25 | 26 | ![Admin view of shopping assistant requests](docs/admin-list.png) Once an admin clicks the link to attend a customer they are directed to the frontend to the same page as the customer. They should confirm to join the Shopping Assistant session. ![Admin joins shopping assistant session](docs/admin-join-session.png) 27 | First time the service is used the store owner should set their avatar and name. It's saved for later use in further sessions. 28 | ![Admin joined session](docs/admin-joined-session.png) 29 | The customer gets notified when the shopping assistant has arrived. ![Customer view of assistant arriving](docs/customer-assistant-arrived.png) 30 | Now that the shopping assistant is here, they can send a message to the customer to welcome them! 31 | ![Admin welcomes customers](docs/admin-hello.png) 32 | 33 | If the customer moves, the assistant can then follow 34 | 35 | ![Admin follows customer](docs/admin-follows-customer.png) The customer would like a product suggestion for an item that goes well with this t-shirt. The store owner can browse to another page on the site within the chinos category and tell them these would look great! ![Admin offers product suggestion](docs/admin-product-suggesion.png) 36 | The customer can see the message, they also see what page the shopping assistant is now viewing and can choose to follow them. 37 | 38 | ![Customer follows admin link](docs/customer-follow-admin.png) 39 | 40 | 41 | 42 | ## Assumptions 43 | 44 | - Shopping Assistants cannot make modifications to the customer's basket as sessions are unique to the browser 45 | 46 | ## To Do 47 | 48 | - Works best for logged in customers at the moment. Guests don't get a chance to choose their name and avatar before we've already sent the notification to admin. Would be nice to put this in the admin grid once we have it. 49 | - The customer could see the catalog in a different state than the admin, e.g. different prices due to price rules being applied 50 | - TURN server not provided by Mozilla so voice does not work out of the box. 51 | - Assign request to a admin user. 52 | - Use name and avatar of the assigned admin user when they join customer so that the setup process doesn't have to happen 53 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meanbee/shoppingassistant", 3 | "description": "This magento extensions uses TogetherJS to create a virtual shopping assistant. Provide customers with the ability to call over a virtual shopping asssistant.", 4 | "type": "magento-module", 5 | "homepage": "https://github.com/meanbee/magento-shopping-assistant", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Tom Robertshaw" 10 | }, 11 | { 12 | "name": "Tomas Gerulaitis" 13 | } 14 | ], 15 | "suggest": { 16 | "magento-hackathon/magento-composer-installer": "2.*" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/admin-follows-customer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-follows-customer.png -------------------------------------------------------------------------------- /docs/admin-hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-hello.png -------------------------------------------------------------------------------- /docs/admin-join-session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-join-session.png -------------------------------------------------------------------------------- /docs/admin-joined-session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-joined-session.png -------------------------------------------------------------------------------- /docs/admin-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-list.png -------------------------------------------------------------------------------- /docs/admin-product-suggesion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/admin-product-suggesion.png -------------------------------------------------------------------------------- /docs/awaiting-assistant-profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/awaiting-assistant-profile.png -------------------------------------------------------------------------------- /docs/awaiting-assistant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/awaiting-assistant.png -------------------------------------------------------------------------------- /docs/customer-assistant-arrived.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/customer-assistant-arrived.png -------------------------------------------------------------------------------- /docs/customer-follow-admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/customer-follow-admin.png -------------------------------------------------------------------------------- /docs/request-assistant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meanbee/magento-shopping-assistant/f5ec0200fc64e81d8324a927ea360d11bf947db1/docs/request-assistant.png -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | src/app/code/community/Meanbee/ShoppingAssistant app/code/community/Meanbee/ShoppingAssistant 2 | src/app/design/frontend/base/default/layout/meanbee/* app/design/frontend/base/default/layout/meanbee/ 3 | src/app/design/frontend/base/default/template/meanbee/shoppingassistant app/design/frontend/base/default/template/meanbee/shoppingassistant 4 | src/skin/frontend/base/default/css/meanbee/* skin/frontend/base/default/css/meanbee/ 5 | src/app/etc/modules/* app/etc/modules/ 6 | src/js/Meanbee/ShoppingAssistant js/Meanbee/ShoppingAssistant 7 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Block/Adminhtml/Request.php: -------------------------------------------------------------------------------- 1 | _blockGroup = "meanbee_shoppingassistant"; 10 | $this->_controller = "adminhtml_request"; 11 | $this->_headerText = $this->__("Shopping Assistant Requests"); 12 | 13 | $this->_removeButton('add'); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Block/Adminhtml/Request/Grid.php: -------------------------------------------------------------------------------- 1 | setId("meanbee_shoppingassistant_request_grid"); 9 | $this->setDefaultSort("created_at"); 10 | $this->setDefaultDir("DESC"); 11 | } 12 | 13 | protected function _prepareCollection() 14 | { 15 | $collection = Mage::getModel("meanbee_shoppingassistant/request")->getCollection(); 16 | 17 | $this->setCollection($collection); 18 | 19 | return parent::_prepareCollection(); 20 | } 21 | 22 | protected function _prepareColumns() 23 | { 24 | $this->addColumn("name", array( 25 | "header" => $this->__("Customer Name"), 26 | "index" => "name", 27 | "type" => "text", 28 | )); 29 | 30 | $this->addColumn("customer_id", array( 31 | "header" => $this->__("Customer ID"), 32 | "index" => "customer_id", 33 | "type" => "number", 34 | "width" => "50px", 35 | )); 36 | 37 | $this->addColumn("created_at", array( 38 | "header" => $this->__("Requested At"), 39 | "index" => "created_at", 40 | "type" => "datetime", 41 | "width" => "100px", 42 | )); 43 | 44 | $this->addColumn("action", array( 45 | "header" => $this->__("Action"), 46 | "type" => "action", 47 | "getter" => "getUrl", 48 | "actions" => array( 49 | array( 50 | "caption" => $this->__("Attend"), 51 | "title" => $this->__("Attend"), 52 | "url" => "", 53 | "target" => "_blank", 54 | ) 55 | ), 56 | "width" => "50px", 57 | "filter" => false, 58 | "sortable" => false, 59 | )); 60 | 61 | return parent::_prepareColumns(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Block/Button.php: -------------------------------------------------------------------------------- 1 | __('Shopping Assistant'); 16 | } 17 | 18 | /** 19 | * Get website name for use in the shopping assistant popup 20 | * 21 | * @return string 22 | */ 23 | public function getWebsiteName() 24 | { 25 | return Mage::app()->getWebsite()->getName(); 26 | } 27 | 28 | /** 29 | * Get email address of either the admin user or logged in customer. 30 | * 31 | * @return string 32 | */ 33 | public function getEmail() 34 | { 35 | if($user = $this->getCurrentUser()) { 36 | return $user->getEmail(); 37 | } 38 | 39 | return ''; 40 | } 41 | 42 | /** 43 | * Get name of user 44 | * 45 | * @return string 46 | */ 47 | public function getName() 48 | { 49 | if($user = $this->getCurrentUser()) { 50 | return sprintf("%s %s", $user->getFirstname(), $user->getLastname()); 51 | } 52 | 53 | return ''; 54 | } 55 | 56 | /** 57 | * Return hex code for user as user colour 58 | * 59 | * @return string 60 | */ 61 | public function getColour() 62 | { 63 | return "#" . substr(md5(rand()), 0, 6); 64 | } 65 | 66 | /** 67 | * Get URL of user avatar 68 | * 69 | * @return string 70 | */ 71 | public function getAvatarUrl() 72 | { 73 | if($user = $this->getCurrentUser()) { 74 | return sprintf("http://www.gravatar.com/avatar/%s", md5(strtolower($user->getEmail()))); 75 | } 76 | 77 | return ''; 78 | } 79 | 80 | /** 81 | * Return either customer user 82 | * 83 | * @return Mage_Customer_Model_Customer 84 | */ 85 | protected function getCurrentUser() 86 | { 87 | /** @var Mage_Customer_Model_Session $adminSession */ 88 | $customerSession = Mage::getSingleton('customer/session'); 89 | if ($customerSession->isLoggedIn()) { 90 | return $customerSession->getCustomer(); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Helper/Config.php: -------------------------------------------------------------------------------- 1 | _init("meanbee_shoppingassistant/request"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Model/Resource/Request.php: -------------------------------------------------------------------------------- 1 | _init("meanbee_shoppingassistant/request", "entity_id"); 8 | } 9 | 10 | protected function _prepareDataForSave(Mage_Core_Model_Abstract $object) 11 | { 12 | if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) { 13 | $object->setCreatedAt($this->formatDate(true)); 14 | } 15 | return parent::_prepareDataForSave($object); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/Model/Resource/Request/Collection.php: -------------------------------------------------------------------------------- 1 | _init("meanbee_shoppingassistant/request"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/controllers/Adminhtml/Shopping/AssistantController.php: -------------------------------------------------------------------------------- 1 | _title(Mage::helper("adminhtml")->__("Customers"))->_title($this->__("Shopping Assistant Requests")); 8 | $this->loadLayout(); 9 | 10 | $this->_setActiveMenu("customer/meanbee_shoppingassistant"); 11 | 12 | $this->_addContent( 13 | $this->getLayout()->createBlock("meanbee_shoppingassistant/adminhtml_request", "meanbee_shoppingassistant_request") 14 | ); 15 | 16 | $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Customers"), Mage::helper("adminhtml")->__("Customers")); 17 | $this->_addBreadcrumb($this->__("Manage Customers"), $this->__("Shopping Assistant Requests")); 18 | 19 | $this->renderLayout(); 20 | } 21 | 22 | protected function _isAllowed() 23 | { 24 | return Mage::getSingleton("admin/session")->isAllowed("customer/meanbee_shoppingassistant"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/controllers/RequestController.php: -------------------------------------------------------------------------------- 1 | "", 9 | 'errors' => array() 10 | ); 11 | 12 | if (!Mage::helper("meanbee_shoppingassistant/config")->isEnabled()) { 13 | $response['errors'][] = "Cannot submit shopping assistant requests at this time"; 14 | } else if ($this->getRequest()->isPost()) { 15 | $request = Mage::getModel("meanbee_shoppingassistant/request"); 16 | 17 | $request->setData(array( 18 | "name" => $this->getRequest()->getPost("name"), 19 | "url" => $this->getRequest()->getPost("url") 20 | )); 21 | 22 | if ($email = $this->getRequest()->getPost('email')) { 23 | $customer = Mage::getModel('customer/customer'); 24 | $customer->setWebsiteId(Mage::app()->getWebsite()->getId()); 25 | $customer->loadByEmail($email); 26 | 27 | if ($customer->getId()) { 28 | $request->setCustomerId($customer->getId()); 29 | } 30 | } 31 | 32 | $request->save(); 33 | 34 | $response['response'] = "Assistant on their way"; 35 | } else { 36 | $response['errors'][] = "Request not submitted through post"; 37 | } 38 | 39 | $this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true); 40 | $this->getResponse()->setBody(json_encode($response)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/etc/adminhtml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Shopping Assistant Requests 8 | adminhtml/shopping_assistant/ 9 | 200 10 | 11 | meanbee_shoppingassistant/general/enabled 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Shopping Assistant Requests 25 | 200 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Shopping Assistant Section 35 | 60 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0.1 6 | 7 | 8 | 9 | 10 | 11 | Meanbee_ShoppingAssistant_Helper 12 | 13 | 14 | 15 | 16 | Meanbee_ShoppingAssistant_Model 17 | meanbee_shoppingassistant_resource 18 | 19 | 20 | Meanbee_ShoppingAssistant_Model_Resource 21 | 22 | 23 | meanbee_shoppingassistant_request
24 |
25 |
26 |
27 |
28 | 29 | 30 | 31 | Meanbee_ShoppingAssistant 32 | Mage_Core_Model_Resource_Setup 33 | 34 | 35 | 36 | 37 | 38 | Meanbee_ShoppingAssistant_Block 39 | 40 | 41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | Meanbee_ShoppingAssistant_Adminhtml 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | standard 59 | 60 | Meanbee_ShoppingAssistant 61 | shopping_assistant 62 | 63 | 64 | 65 | 66 | 67 | 68 | meanbee/shoppingassistant.xml 69 | 70 | 71 | 72 | 73 |
74 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | customer 7 | text 8 | 110 9 | 1 10 | 1 11 | 1 12 | 13 | 14 | 15 | 1 16 | text 17 | 1 18 | 1 19 | 1 20 | 1 21 | 22 | 23 | 24 | select 25 | adminhtml/system_config_source_yesno 26 | 1 27 | 1 28 | 1 29 | 1 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/sql/meanbee_shoppingassistant_setup/install-1.0.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 7 | 8 | $main_table = $installer->getTable("meanbee_shoppingassistant/request"); 9 | 10 | if ($installer->tableExists($main_table)) { 11 | $installer->getConnection()->dropTable($main_table); 12 | } 13 | 14 | $table = $installer->getConnection() 15 | ->newTable($main_table) 16 | ->addColumn("entity_id", Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 17 | "identity" => true, 18 | "unsigned" => true, 19 | "nullable" => false, 20 | "primary" => true, 21 | ), "Entity ID") 22 | ->addColumn("url", Varien_Db_Ddl_Table::TYPE_TEXT, 2048, array( 23 | "nullable" => false, 24 | ), "Request URL") 25 | ->addColumn("created_at", Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( 26 | ), "Creation Time") 27 | ->setComment("Shopping Assistant Request Table"); 28 | $installer->getConnection()->createTable($table); 29 | 30 | $installer->endSetup(); 31 | -------------------------------------------------------------------------------- /src/app/code/community/Meanbee/ShoppingAssistant/sql/meanbee_shoppingassistant_setup/upgrade-1.0.0-1.0.1.php: -------------------------------------------------------------------------------- 1 | startSetup(); 7 | 8 | $main_table = $installer->getTable("meanbee_shoppingassistant/request"); 9 | 10 | $installer->getConnection()->addColumn( 11 | $main_table, 12 | "name", 13 | array( 14 | "type" => Varien_Db_Ddl_Table::TYPE_TEXT, 15 | "length" => 255, 16 | "nullable" => false, 17 | "default" => "", 18 | "after" => "entity_id", 19 | "comment" => "Customer Name" 20 | ) 21 | ); 22 | 23 | $installer->getConnection()->addColumn( 24 | $main_table, 25 | "customer_id", 26 | array( 27 | "type" => Varien_Db_Ddl_Table::TYPE_INTEGER, 28 | "nullable" => true, 29 | "after" => "name", 30 | "comment" => "Magento Customer ID" 31 | ) 32 | ); 33 | 34 | $installer->endSetup(); 35 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/layout/meanbee/shoppingassistant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | css/meanbee/shoppingassistant.css 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ]]> 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/meanbee/shoppingassistant/button.phtml: -------------------------------------------------------------------------------- 1 | 29 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/meanbee/shoppingassistant/scripts.phtml: -------------------------------------------------------------------------------- 1 | 2 | getCssJsHtml(); ?> -------------------------------------------------------------------------------- /src/app/etc/modules/Meanbee_ShoppingAssistant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/js/Meanbee/ShoppingAssistant/magentoShoppingAssistant.js: -------------------------------------------------------------------------------- 1 | /** var document, TogetherJS **/ 2 | /** 3 | * This library wraps around TogetherJS in order to provide shopping assistant 4 | * functionality to Magento. It will listen for requests from start elements 5 | * and send the request to Magento admin to be dealt with. 6 | */ 7 | ;(function() { 8 | 'use strict'; 9 | 10 | var Meanbee_ShoppingAssistant = Class.create(); 11 | 12 | Meanbee_ShoppingAssistant.prototype = { 13 | initialize: function(options) { 14 | this.options = Object.extend({ 15 | startElements: "[data-shoppingassistant-start]", 16 | started: false, 17 | debug: false 18 | }, options || {} ); 19 | 20 | // Listen to buttons which can be used to request a session 21 | $$(this.options.startElements).each(function(element) { 22 | Event.observe(element,'click', this.toggleSession.bind(this)); 23 | }.bind(this)); 24 | 25 | // TogetherJS callback for a party joining the session, e.g. admin 26 | TogetherJS.hub.on("togetherjs.hello", this.memberJoined.bind(this)); 27 | }, 28 | 29 | /** 30 | * Toggle debug mode 31 | * 32 | * @param enable 33 | */ 34 | debug: function(enable) { 35 | this.options.debug = enable; 36 | }, 37 | 38 | /** 39 | * Member has joined the shopping assistant session 40 | */ 41 | memberJoined: function() { 42 | this.log("Member joined."); 43 | $$(this.options.startElements).first().innerText = "Assistant arrived."; 44 | }, 45 | 46 | /** 47 | * Start or stop shopping assistant session 48 | */ 49 | toggleSession: function() { 50 | 51 | if (!TogetherJS.running) { 52 | this.log("Starting Shopping Assistant"); 53 | document.observe('togetherjs:ready', this.notifyAdmin.bind(this)); 54 | } else { 55 | this.log("Ending Shopping Assistant") 56 | } 57 | 58 | TogetherJS(this); 59 | }, 60 | 61 | /** 62 | * Send shopping assistant request to admin 63 | */ 64 | notifyAdmin: function() { 65 | var self = this; 66 | 67 | self.log("Sending request to admin"); 68 | 69 | new Ajax.Request(MeanbeeBaseUrl + 'shopping_assistant/request/create', { 70 | parameters: { 71 | url: TogetherJS.shareUrl(), 72 | name: TogetherJS.config.get("getUserName")(), 73 | email: TogetherJSConfig_getEmail() 74 | }, 75 | onSuccess: function(response) { 76 | var json = response.responseJSON; 77 | if (json.response) { 78 | $$(self.options.startElements).first().innerText = json.response; 79 | } 80 | } 81 | }); 82 | }, 83 | 84 | /** 85 | * Log messages to console if debug mode enabled. 86 | * 87 | * @param message 88 | */ 89 | log: function(message) { 90 | if (this.options.debug) { 91 | console.log(message); 92 | } 93 | } 94 | 95 | }; 96 | 97 | window.Meanbee_ShoppingAssistant = new Meanbee_ShoppingAssistant(); 98 | })(); -------------------------------------------------------------------------------- /src/skin/frontend/base/default/css/meanbee/shoppingassistant.css: -------------------------------------------------------------------------------- 1 | .button-shopping-assistant { 2 | bottom: 0; 3 | position: fixed; 4 | right: 5em; 5 | z-index: 100; 6 | } --------------------------------------------------------------------------------