├── code
├── Helper
│ └── Data.php
├── Block
│ ├── Order.php
│ ├── Creditmemo.php
│ ├── Shipment.php
│ └── Gmailactions.php
└── etc
│ ├── config.xml
│ └── system.xml
├── Module.xml
├── modman
├── composer.json
├── design
└── frontend
│ └── layout
│ └── meanbee
│ └── gmailactions
│ └── gmailactions.xml
├── LICENSE.md
├── README.md
└── Package.xml
/code/Helper/Data.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | community
7 |
8 |
9 |
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | code app/code/community/Meanbee/Gmailactions
2 | design/frontend/layout/meanbee/gmailactions app/design/frontend/base/default/layout/meanbee/gmailactions
3 | #Misc
4 | Module.xml app/etc/modules/Meanbee_Gmailactions.xml
5 | Package.xml var/connect/Meanbee_Gmailactions.xml
6 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "meanbee/gmailactions",
3 | "type": "magento-module",
4 | "description": "Adds schema markup to order, shipment and credit memo email. Which is used by Gmail to give quick options to customers",
5 | "keywords": ["google", "gmail", "meanbee"],
6 | "license": "MIT",
7 | "authors":[
8 | {
9 | "name":"Meanbee",
10 | "email":"hello@meanbee.com"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/code/Block/Order.php:
--------------------------------------------------------------------------------
1 | getOrder()->getStore()
10 | );
11 | }
12 |
13 | public function getJsonArray()
14 | {
15 | return $this->generateOrderArray($this->getOrder());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/design/frontend/layout/meanbee/gmailactions/gmailactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Meanbee Limited
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 |
--------------------------------------------------------------------------------
/code/Block/Creditmemo.php:
--------------------------------------------------------------------------------
1 | getOrder()->getStore()
10 | );
11 | }
12 |
13 | public function getJsonArray()
14 | {
15 | return $this->generateCreditMemoArray($this->getOrder());
16 | }
17 |
18 | public function generateCreditMemoArray(Mage_Sales_Model_Order $order)
19 | {
20 | $store = $order->getStore();
21 |
22 | return array(
23 | '@context' => 'http://schema.org',
24 | '@type' => 'EmailMessage',
25 | 'description' => Mage::getStoreConfig("meanbee_gmailactions_options/creditmemo_email/description", $store),
26 | 'action' => array(
27 | '@type' => 'ViewAction',
28 | 'url' => $this->getViewCreditmemoUrl($order),
29 | 'name' => Mage::getStoreConfig('meanbee_gmailactions_options/creditmemo_email/action_name', $store)
30 | )
31 | );
32 | }
33 |
34 | public function getViewCreditmemoUrl($order)
35 | {
36 | return Mage::getUrl(
37 | "sales/order/creditmemo",
38 | array(
39 | 'order_id' => $order->getId(),
40 | '_secure' => Mage::getStoreConfig('web/secure/use_in_frontend')
41 | )
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/code/Block/Shipment.php:
--------------------------------------------------------------------------------
1 | getShipment()->getStore()
10 | );
11 | }
12 |
13 | public function getJsonArray()
14 | {
15 | return $this->generateShipmentArray($this->getShipment());
16 | }
17 |
18 | public function generateShipmentArray(Mage_Sales_Model_Order_Shipment $shipment)
19 | {
20 | $address = $shipment->getShippingAddress();
21 | $trackingMethods = $shipment->getAllTracks();
22 | $primaryTrack = count($trackingMethods) ? $trackingMethods[0] : false;
23 |
24 | $array = array(
25 | '@context' => 'http://schema.org',
26 | '@type' => 'ParcelDelivery',
27 | 'deliveryAddress' => array(
28 | '@type' => 'PostalAddress',
29 | 'streetAddress' => $address->getStreetFull(),
30 | 'addressLocality' => $address->getCity(),
31 | 'addressRegion' => $address->getRegionCode(),
32 | 'addressCountry' => $address->getCountry(),
33 | 'postalCode' => $address->getPostcode(),
34 | ),
35 | 'partOfOrder' => $this->generateOrderArray($shipment->getOrder()),
36 | "expectedArrivalUntil" => date("c", time() + 60 * 60 * 24 * 365.25),
37 | );
38 |
39 | if (count($trackingMethods)) {
40 | $array['carrier'] = $primaryTrack->getTitle();
41 | $array['trackingNumber'] = $primaryTrack->getNumber();
42 | $array['trackingUrl'] = $this->helper('shipping')->getTrackingPopUpUrlByTrackId($primaryTrack->getId());
43 | }
44 |
45 | return $array;
46 | }
47 |
48 |
49 | public function getViewShipmentUrl($order)
50 | {
51 | return Mage::getUrl(
52 | "sales/order/shipment",
53 | array(
54 | 'order_id' => $order->getId(),
55 | '_secure' => Mage::getStoreConfig('web/secure/use_in_frontend')
56 | )
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/code/etc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 1.0.0
6 |
7 |
8 |
9 |
10 |
11 | Meanbee_Gmailactions_Block
12 |
13 |
14 |
15 |
16 | Meanbee_Gmailactions_Helper
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | meanbee/gmailactions/gmailactions.xml
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | Gmail Actions Configuration
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | 1
54 |
55 |
56 | 1
57 |
58 |
59 | 1
60 | View Credit Memo
61 | Open credit memo in browser
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Meanbee Gmailactions
2 |
3 | Increase user-engagement in your Magento stores transactional emails. Adding schema supported by Gmail adds quick go-to buttons to your customers inboxes. For more info see: [Gmail Actions](https://developers.google.com/gmail/actions/)
4 |
5 | 
6 | 
7 |
8 | ## Requirements:
9 |
10 | - Emails must be [authenticated via DKIM or SPF](https://support.google.com/mail/answer/180707?hl=en)
11 | - If you are unable to modify your DNS records to support this, one way of achieving is through the use of a SMTP module
12 | - Your domain of the DKIM or SPF signatures must match the domain of your From: email address exactly. eg for From: foo@bar.com the DKIM must be for the bar.com domain and not a subdomain such as email.bar.com.
13 | - Emails must come from a static email address, eg foo@bar.com
14 | - Emails must follow [Google's general email guidelines](https://support.google.com/mail/answer/81126?hl=en)
15 |
16 |
17 | Once you have met these basic requirements, you can then [register with Google](https://developers.google.com/gmail/actions/registering-with-google) so your customers can start seeing the new Go-to Actions in their inboxes.
18 |
19 |
20 | [Full list of requirements from Google](https://developers.google.com/gmail/actions/registering-with-google)
21 |
22 |
23 | ## Installation
24 |
25 | You can install via [Modman](https://github.com/colinmollenhour/modman):
26 |
27 | cd /to/magento/root/
28 | modman init
29 | modman clone https://github.com/meanbee/gmailactions.git
30 |
31 | Or by copying the files across manually (using the modman file as a reference)
32 |
33 | Once installed, clear your cache and sessions.
34 |
35 | ## Configuration
36 |
37 | We have added a few configurable options, which allows you to customise the `Action Text` which appears on the button. Plus `Description` which describes the contents of the email. These options are located at `System > Configuration > Gmail Actions > Gmail Actions Configurationn`. There is an `Action Name` and `Description` for each type of transactional email with the exception of Invoices.
38 |
39 | ## Testing
40 |
41 | To test that the emails are sending correctly, you will require a gmail account (Google Apps accounts also work). You will then need to change the Sales Representative Contact Email in `System > Configuration > Store Email Addresses`. Changing it to your gmail account. When you place a test order, you will also need to use that same email address.
42 |
--------------------------------------------------------------------------------
/Package.xml:
--------------------------------------------------------------------------------
1 | <_>
2 | 9mAw6kU4QX5Ge77u
3 | Meanbee_Gmailactions
4 | community
5 |
6 | 2
7 |
8 | Adds schema markup to order, shipment and credit memo email. Which is used by Gmail to give quick options to customers.
9 | This module simply adds some additional schema markup to transactional emails, which is then used by Gmail to display quick action buttons to the gmail interface.
10 |
11 | This is achieved by adjusting the block "additional.product.info".
12 |
13 | System configuration options have been added so the end-user can customise the text that is displayed if they wish. Defaults are provided (in English).
14 | MIT
15 | http://opensource.org/licenses/MIT
16 | 1.0.0
17 | stable
18 | Initial release.
19 |
20 |
21 | Meanbee
22 |
23 |
24 | meanbee
25 |
26 |
27 | hello@meanbee.com
28 |
29 |
30 | 5.2.13
31 | 5.3.24
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Core
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | magelocal
65 | magecommunity
66 | magedesign
67 | magedesign
68 | mageetc
69 |
70 |
71 |
72 | Meanbee/Gmailactions
73 | frontend/base/default/layout/meanbee
74 | modules/Meanbee_Gmailactions.xml
75 |
76 |
77 | file
78 | dir
79 | dir
80 | dir
81 | file
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/code/Block/Gmailactions.php:
--------------------------------------------------------------------------------
1 | isEnabled()) {
15 | return null;
16 | }
17 |
18 | $json = json_encode($this->getJsonArray());
19 |
20 | return '';
21 | }
22 |
23 | public function getViewOrderUrl($order)
24 | {
25 | return Mage::getUrl(
26 | "sales/order/view",
27 | array(
28 | 'order_id' => $order->getId(),
29 | '_secure' => Mage::getStoreConfig('web/secure/use_in_frontend')
30 | )
31 | );
32 | }
33 |
34 | /**
35 | * @param Mage_Sales_Model_Order $order
36 | *
37 | * @return string
38 | */
39 | public function getOrderStatus($order)
40 | {
41 | $state = $order->getState();
42 | $map = array(
43 | 'new' => 'Processing',
44 | 'pending_payment' => 'ProblemWithOrder',
45 | 'processing' => 'Processing',
46 | 'complete' => 'Delivered',
47 | 'closed' => 'Cancelled',
48 | 'cancelled' => 'Cancelled',
49 | 'holded' => 'ProblemWithOrder',
50 | );
51 |
52 | return 'http://schema.org/OrderStatus/' . $map[$state];
53 | }
54 |
55 | public function generateAcceptedOfferArray(Mage_Sales_Model_Order $order)
56 | {
57 | $array = array();
58 | foreach ($order->getAllVisibleItems() as $item) {
59 | $_offer = array(
60 | '@type' => 'Offer',
61 | 'itemOffered' => array(
62 | '@type' => 'Product',
63 | 'name' => $item->getName(),
64 | 'sku' => $item->getSku(),
65 | 'image' => $item->getImageUrl(),
66 | ),
67 | 'price' => (string) number_format($item->getPrice(), 2),
68 | 'priceCurrency' => $order->getBaseCurrency()->getCurrencyCode(),
69 | 'eligibleQuantity' => array(
70 | '@type' => 'QuantitativeValue',
71 | 'value' => $item->getQtyOrdered(),
72 | ),
73 | );
74 |
75 | $array[] = $_offer;
76 | }
77 |
78 | return $array;
79 | }
80 |
81 | public function generateOrderArray(Mage_Sales_Model_Order $order)
82 | {
83 | $array = array(
84 | '@context' => 'http://schema.org',
85 | '@type' => 'Order',
86 | 'merchant' => array(
87 | '@type' => 'Organization',
88 | 'name' => $order->getStore()->getFrontendName(),
89 | ),
90 | 'orderNumber' => $order->getIncrementId(),
91 | 'priceCurrency' => $order->getOrderCurrency()->toString(),
92 | 'price' => (string) number_format($order->getBaseTotalDue(), 2),
93 | 'acceptedOffer' => $this->generateAcceptedOfferArray($order),
94 | );
95 |
96 | if (!$order->getCustomerIsGuest()) {
97 | $array['url'] = $this->getViewOrderUrl($order);
98 | }
99 |
100 | return $array;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/code/etc/system.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 99999
7 |
8 |
9 |
10 |
11 |
12 | meanbee_gmailactionsconfig
13 | text
14 | 1000
15 | 1
16 | 1
17 | 1
18 |
19 |
20 |
21 | text
22 | 0
23 | 1
24 | 1
25 | 1
26 |
27 |
28 |
29 | select
30 | adminhtml/system_config_source_yesno
31 | 1
32 | 1
33 | 1
34 | 1
35 |
36 |
37 |
38 |
39 |
40 | text
41 | 1
42 | 1
43 | 1
44 | 1
45 |
46 |
47 |
48 | select
49 | adminhtml/system_config_source_yesno
50 | 1
51 | 1
52 | 1
53 | 1
54 |
55 |
56 |
57 |
58 |
59 | text
60 | 2
61 | 1
62 | 1
63 | 1
64 |
65 |
66 |
67 | select
68 | adminhtml/system_config_source_yesno
69 | 10
70 | 1
71 | 1
72 | 1
73 |
74 |
75 |
76 | text
77 | 30
78 | 1
79 | 1
80 | 1
81 |
82 |
83 |
84 | text
85 | 20
86 | 1
87 | 1
88 | 1
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------