Version Notes
Initial Code
Download this release
Release Info
Developer | MineWhat Inc. |
Extension | choiceai |
Version | 1.0.7 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.7
- app/code/community/ChoiceAI/Personalisation/Helper/Data.php +1 -1
- app/code/community/ChoiceAI/Personalisation/Model/Observer.php +62 -2
- app/design/frontend/base/default/template/choiceai/personalisation/base/script.phtml +2 -2
- app/design/frontend/base/default/template/choiceai/personalisation/event/catalog/product/view.phtml +2 -2
- app/design/frontend/base/default/template/choiceai/personalisation/event/checkout/cart/index.phtml +2 -2
- app/design/frontend/base/default/template/choiceai/personalisation/event/checkout/onepage/success.phtml +2 -2
- app/design/frontend/default/default/template/choiceai/personalisation/base/script.phtml +2 -2
- app/design/frontend/default/default/template/choiceai/personalisation/event/catalog/product/view.phtml +2 -2
- app/design/frontend/default/default/template/choiceai/personalisation/event/checkout/cart/index.phtml +2 -2
- app/design/frontend/default/default/template/choiceai/personalisation/event/checkout/onepage/success.phtml +2 -2
- package.xml +2 -2
app/code/community/ChoiceAI/Personalisation/Helper/Data.php
CHANGED
@@ -25,7 +25,7 @@ class ChoiceAI_Personalisation_Helper_Data extends Mage_Core_Helper_Data {
|
|
25 |
|
26 |
try {
|
27 |
|
28 |
-
$base_script = "\n<!-- ChoiceAI Script begins -->\n<script type='text/javascript'>!function(){function t(){if(!window.
|
29 |
$base_script = str_replace("ORG_HANDLE", split("_", Mage::getStoreConfig(self::CONFIG_API_KEY, $store))[0], $base_script);
|
30 |
|
31 |
} catch (Exception $e) {
|
25 |
|
26 |
try {
|
27 |
|
28 |
+
$base_script = "\n<!-- ChoiceAI Script begins -->\n<script type='text/javascript'>!function(){function t(){if(!window.CAISDK){var t=document.createElement('script'),n='beaconhttp.choice.ai';t.type='text/javascript',t.async=!0,'https:'==location.protocol&&(n='d3caf2da6t944y.cloudfront.net'),t.src='//'+n+'/site/ethno/ORG_HANDLE/choice.js';var e=document.getElementsByTagName('script')[0];e.parentNode.insertBefore(t,e)}}window.CAISDK&&window.CAISDK.reinit&&window.CAISDK.reinit(),!window.CAISDK && t()}();</script>\n<!-- ChoiceAI Script ends -->\n";
|
29 |
$base_script = str_replace("ORG_HANDLE", split("_", Mage::getStoreConfig(self::CONFIG_API_KEY, $store))[0], $base_script);
|
30 |
|
31 |
} catch (Exception $e) {
|
app/code/community/ChoiceAI/Personalisation/Model/Observer.php
CHANGED
@@ -12,7 +12,67 @@ class ChoiceAI_Personalisation_Model_Observer {
|
|
12 |
$store_url = Mage::getBaseUrl();
|
13 |
$magento_version = Mage::getVersion();
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
}
|
18 |
|
@@ -63,4 +123,4 @@ class ChoiceAI_Personalisation_Model_Observer {
|
|
63 |
);
|
64 |
|
65 |
}
|
66 |
-
}
|
12 |
$store_url = Mage::getBaseUrl();
|
13 |
$magento_version = Mage::getVersion();
|
14 |
|
15 |
+
$error_message = "";
|
16 |
+
|
17 |
+
try {
|
18 |
+
|
19 |
+
$roles = Mage::getModel('api/roles')->getCollection()->addFieldToFilter('role_name', 'ChoiceAI');
|
20 |
+
|
21 |
+
if ($roles && sizeof($roles) > 0) {
|
22 |
+
|
23 |
+
$api_role = $roles->getFirstItem();
|
24 |
+
|
25 |
+
} else {
|
26 |
+
|
27 |
+
$api_role = Mage::getModel('api/roles')
|
28 |
+
->setName('ChoiceAI')
|
29 |
+
->setPid("ChoiceAI")
|
30 |
+
->setRoleType('G')
|
31 |
+
->save();
|
32 |
+
}
|
33 |
+
|
34 |
+
Mage::getModel('api/rules')
|
35 |
+
->setRoleId($api_role->getId())
|
36 |
+
->setResources(array('all'))
|
37 |
+
->saveRel();
|
38 |
+
|
39 |
+
$users = Mage::getModel('api/user')->getCollection()->addFieldToFilter('email', 'magento@choice.ai');
|
40 |
+
if ($users && sizeof($users) > 0) {
|
41 |
+
|
42 |
+
$api_user = $users->getFirstItem();
|
43 |
+
|
44 |
+
} else {
|
45 |
+
|
46 |
+
$api_user = Mage::getModel('api/user');
|
47 |
+
$api_user->setData(array(
|
48 |
+
'username' => 'choiceai',
|
49 |
+
'firstname' => 'ChoiceAI',
|
50 |
+
'lastname' => 'Personalisation',
|
51 |
+
'email' => 'magento@choice.ai',
|
52 |
+
'api_key' => $api_key,
|
53 |
+
'api_key_confirmation' => $api_key,
|
54 |
+
'is_active' => 1,
|
55 |
+
'user_roles' => '',
|
56 |
+
'assigned_user_role' => '',
|
57 |
+
'role_name' => '',
|
58 |
+
'roles' => array($api_role->getId())
|
59 |
+
));
|
60 |
+
|
61 |
+
$api_user->save()->load($api_user->getId());
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
$api_user->setRoleIds(array($api_role->getId()))
|
66 |
+
->setRoleUserId($api_user->getUserId())
|
67 |
+
->saveRelations();
|
68 |
+
|
69 |
+
} catch (Exception $e) {
|
70 |
+
|
71 |
+
$error_message = $e->getMessage();
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
file_get_contents("https://app.choice.ai/stats/magentoinstall?enabled=".$enabled."&api_key=".$api_key."&store_url=".$store_url."&magentoversion=".$magento_version."&error=".$error_message);
|
76 |
|
77 |
}
|
78 |
|
123 |
);
|
124 |
|
125 |
}
|
126 |
+
}
|
app/design/frontend/base/default/template/choiceai/personalisation/base/script.phtml
CHANGED
@@ -7,8 +7,8 @@ if($user) {
|
|
7 |
?>
|
8 |
<script type="text/javascript">
|
9 |
//<![CDATA[
|
10 |
-
window.
|
11 |
-
|
12 |
//]]>
|
13 |
</script>
|
14 |
<?php
|
7 |
?>
|
8 |
<script type="text/javascript">
|
9 |
//<![CDATA[
|
10 |
+
window._caiapi = window._caiapi || [];
|
11 |
+
_caiapi.push(['trackUser', '<?php echo $email ?>']);
|
12 |
//]]>
|
13 |
</script>
|
14 |
<?php
|
app/design/frontend/base/default/template/choiceai/personalisation/event/catalog/product/view.phtml
CHANGED
@@ -54,8 +54,8 @@
|
|
54 |
|
55 |
<script type="text/javascript">
|
56 |
//<![CDATA[
|
57 |
-
var
|
58 |
-
|
59 |
//]]>
|
60 |
</script>
|
61 |
<?php } ?>
|
54 |
|
55 |
<script type="text/javascript">
|
56 |
//<![CDATA[
|
57 |
+
var _caiapi = _caiapi || [];
|
58 |
+
_caiapi.push(['trackEvent', 'product', {pid: '<?php echo $_product->getId() ?>', associated_ids: '<?php echo json_encode($associated_ids) ?>'}]);
|
59 |
//]]>
|
60 |
</script>
|
61 |
<?php } ?>
|
app/design/frontend/base/default/template/choiceai/personalisation/event/checkout/cart/index.phtml
CHANGED
@@ -10,8 +10,8 @@
|
|
10 |
<?php if ($_product && $_product["id"]) { ?>
|
11 |
<script type="text/javascript">
|
12 |
//<![CDATA[
|
13 |
-
var
|
14 |
-
|
15 |
//]]>
|
16 |
</script>
|
17 |
<?php } ?>
|
10 |
<?php if ($_product && $_product["id"]) { ?>
|
11 |
<script type="text/javascript">
|
12 |
//<![CDATA[
|
13 |
+
var _caiapi = _caiapi || [];
|
14 |
+
_caiapi.push(['trackEvent', 'addtocart', {pid: '<?php echo $_product["id"] ?>', sku: '<?php echo $_product["sku"] ?>', parent_pid: '<?php echo $_product["parentId"] ?>', qty: '<?php echo $_product["qty"] ?>', bundle: '<?php echo json_encode($_product["bundle"]) ?>'}]);
|
15 |
//]]>
|
16 |
</script>
|
17 |
<?php } ?>
|
app/design/frontend/base/default/template/choiceai/personalisation/event/checkout/onepage/success.phtml
CHANGED
@@ -9,12 +9,12 @@
|
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
-
var
|
13 |
var products = [];
|
14 |
<?php foreach ($orderInfo['items'] as $product) { ?>
|
15 |
products.push({pid: '<?php echo $product["id"] ?>', qty: '<?php echo intval($product["qty"]) ?>', sku: '<?php echo $product["sku"] ?>', price: '<?php echo $product["price"] ?>', parent_pid: '<?php echo $product["parentId"] ?>', bundle: '<?php echo json_encode($product["bundle"]) ?>'});
|
16 |
<?php } ?>
|
17 |
-
|
18 |
|
19 |
//]]>
|
20 |
</script>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
+
var _caiapi = _caiapi || [];
|
13 |
var products = [];
|
14 |
<?php foreach ($orderInfo['items'] as $product) { ?>
|
15 |
products.push({pid: '<?php echo $product["id"] ?>', qty: '<?php echo intval($product["qty"]) ?>', sku: '<?php echo $product["sku"] ?>', price: '<?php echo $product["price"] ?>', parent_pid: '<?php echo $product["parentId"] ?>', bundle: '<?php echo json_encode($product["bundle"]) ?>'});
|
16 |
<?php } ?>
|
17 |
+
_caiapi.push(['trackEvent', 'buy', {products: products, order: {order_number: '<?php echo $orderInfo["orderId"] ?>', payment: '<?php echo $orderInfo["paymentMethod"] ?>', created_at: '<?php echo $orderInfo["createdAt"] ?>', email: '<?php echo $orderInfo["email"] ?>'}, platform: 'magento', currency: '<?php echo $orderInfo["currency"] ?>'}]);
|
18 |
|
19 |
//]]>
|
20 |
</script>
|
app/design/frontend/default/default/template/choiceai/personalisation/base/script.phtml
CHANGED
@@ -7,8 +7,8 @@
|
|
7 |
?>
|
8 |
<script type="text/javascript">
|
9 |
//<![CDATA[
|
10 |
-
window.
|
11 |
-
|
12 |
//]]>
|
13 |
</script>
|
14 |
<?php
|
7 |
?>
|
8 |
<script type="text/javascript">
|
9 |
//<![CDATA[
|
10 |
+
window._caiapi = window._caiapi || [];
|
11 |
+
_caiapi.push(['trackUser', '<?php echo $email ?>']);
|
12 |
//]]>
|
13 |
</script>
|
14 |
<?php
|
app/design/frontend/default/default/template/choiceai/personalisation/event/catalog/product/view.phtml
CHANGED
@@ -54,8 +54,8 @@
|
|
54 |
|
55 |
<script type="text/javascript">
|
56 |
//<![CDATA[
|
57 |
-
var
|
58 |
-
|
59 |
//]]>
|
60 |
</script>
|
61 |
<?php } ?>
|
54 |
|
55 |
<script type="text/javascript">
|
56 |
//<![CDATA[
|
57 |
+
var _caiapi = _caiapi || [];
|
58 |
+
_caiapi.push(['trackEvent', 'product', {pid: '<?php echo $_product->getId() ?>', associated_ids: '<?php echo json_encode($associated_ids) ?>'}]);
|
59 |
//]]>
|
60 |
</script>
|
61 |
<?php } ?>
|
app/design/frontend/default/default/template/choiceai/personalisation/event/checkout/cart/index.phtml
CHANGED
@@ -10,8 +10,8 @@
|
|
10 |
<?php if ($_product && $_product["id"]) { ?>
|
11 |
<script type="text/javascript">
|
12 |
//<![CDATA[
|
13 |
-
var
|
14 |
-
|
15 |
//]]>
|
16 |
</script>
|
17 |
<?php } ?>
|
10 |
<?php if ($_product && $_product["id"]) { ?>
|
11 |
<script type="text/javascript">
|
12 |
//<![CDATA[
|
13 |
+
var _caiapi = _caiapi || [];
|
14 |
+
_caiapi.push(['trackEvent', 'addtocart', {pid: '<?php echo $_product["id"] ?>', sku: '<?php echo $_product["sku"] ?>', parent_pid: '<?php echo $_product["parentId"] ?>', qty: '<?php echo $_product["qty"] ?>', bundle: '<?php echo json_encode($_product["bundle"]) ?>'}]);
|
15 |
//]]>
|
16 |
</script>
|
17 |
<?php } ?>
|
app/design/frontend/default/default/template/choiceai/personalisation/event/checkout/onepage/success.phtml
CHANGED
@@ -9,12 +9,12 @@
|
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
-
var
|
13 |
var products = [];
|
14 |
<?php foreach ($orderInfo['items'] as $product) { ?>
|
15 |
products.push({pid: '<?php echo $product["id"] ?>', qty: '<?php echo intval($product["qty"]) ?>', sku: '<?php echo $product["sku"] ?>', price: '<?php echo $product["price"] ?>', parent_pid: '<?php echo $product["parentId"] ?>', bundle: '<?php echo json_encode($product["bundle"]) ?>'});
|
16 |
<?php } ?>
|
17 |
-
|
18 |
//]]>
|
19 |
</script>
|
20 |
<?php } ?>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
+
var _caiapi = _caiapi || [];
|
13 |
var products = [];
|
14 |
<?php foreach ($orderInfo['items'] as $product) { ?>
|
15 |
products.push({pid: '<?php echo $product["id"] ?>', qty: '<?php echo intval($product["qty"]) ?>', sku: '<?php echo $product["sku"] ?>', price: '<?php echo $product["price"] ?>', parent_pid: '<?php echo $product["parentId"] ?>', bundle: '<?php echo json_encode($product["bundle"]) ?>'});
|
16 |
<?php } ?>
|
17 |
+
_caiapi.push(['trackEvent', 'buy', {products: products, order: {order_number: '<?php echo $orderInfo["orderId"] ?>', payment: '<?php echo $orderInfo["paymentMethod"] ?>', created_at: '<?php echo $orderInfo["createdAt"] ?>', email: '<?php echo $orderInfo["email"] ?>'}, platform: 'magento', currency: '<?php echo $orderInfo["currency"] ?>'}]);
|
18 |
//]]>
|
19 |
</script>
|
20 |
<?php } ?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>choiceai</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
|
7 |
<channel>community</channel>
|
@@ -10,7 +10,7 @@
|
|
10 |
<description>Choice AI</description>
|
11 |
<notes>Initial Code</notes>
|
12 |
<authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
|
13 |
-
<date>
|
14 |
<time>12:05:00</time>
|
15 |
<contents><target name="mageetc"><dir name="modules"><file name="ChoiceAI_Personalisation.xml" hash="28fd1d1b9b298b14b83fdcadf586efc5"/></dir></target><target name="magecommunity"><dir name="ChoiceAI"><dir name="Personalisation"><dir><dir name="Block"><dir name="Base"><file name="Script.php" hash="af614113dea10a0a6d88281f615f1929"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="233ac45484c22ecdf7063071406f71e2"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="e3bc31a08a994d72223d78ebde8a74f0"/></dir><dir name="Onepage"><file name="Success.php" hash="cc242d118e6b06bb3817d95b2322167c"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7da393b7cf4def36383198029a90c907"/></dir><dir name="Model"><file name="Observer.php" hash="b62729ff6f0d7666c1461b3259aa2755"/></dir><dir name="controllers"><file name="ApiController.php" hash="035c1f5e7c1cefbec8ae59b2f1946897"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2fc12bb0874c8f39963f1593b3954d2e"/><file name="config.xml" hash="f743d8ead3776891503ff368ad7e7330"/><file name="system.xml" hash="6f4674088b4c392cc06f5a70f383fd54"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir><dir name="base"><file name="script.phtml" hash="5e9386a2c0af502d406ba0c8f29b7345"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="21de45429a80fd7a025092cd17629e6d"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="37a7ec61318af0e52aae869de631aaf6"/></dir></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="choiceai_personalisation.xml" hash="95d72912f3b13c5a399e3b2e5b89dba9"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir><dir name="base"><file name="script.phtml" hash="3e5799dc6ccf5b4f120400d48f5f95d2"/></dir></dir></dir></dir></dir><dir name="layout"><file name="choiceai_personalisation.xml" hash="95d72912f3b13c5a399e3b2e5b89dba9"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>choiceai</name>
|
4 |
+
<version>1.0.7</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Choice AI</description>
|
11 |
<notes>Initial Code</notes>
|
12 |
<authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
|
13 |
+
<date>2017-01-25</date>
|
14 |
<time>12:05:00</time>
|
15 |
<contents><target name="mageetc"><dir name="modules"><file name="ChoiceAI_Personalisation.xml" hash="28fd1d1b9b298b14b83fdcadf586efc5"/></dir></target><target name="magecommunity"><dir name="ChoiceAI"><dir name="Personalisation"><dir><dir name="Block"><dir name="Base"><file name="Script.php" hash="af614113dea10a0a6d88281f615f1929"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="233ac45484c22ecdf7063071406f71e2"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="e3bc31a08a994d72223d78ebde8a74f0"/></dir><dir name="Onepage"><file name="Success.php" hash="cc242d118e6b06bb3817d95b2322167c"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7da393b7cf4def36383198029a90c907"/></dir><dir name="Model"><file name="Observer.php" hash="b62729ff6f0d7666c1461b3259aa2755"/></dir><dir name="controllers"><file name="ApiController.php" hash="035c1f5e7c1cefbec8ae59b2f1946897"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2fc12bb0874c8f39963f1593b3954d2e"/><file name="config.xml" hash="f743d8ead3776891503ff368ad7e7330"/><file name="system.xml" hash="6f4674088b4c392cc06f5a70f383fd54"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir><dir name="base"><file name="script.phtml" hash="5e9386a2c0af502d406ba0c8f29b7345"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="21de45429a80fd7a025092cd17629e6d"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="37a7ec61318af0e52aae869de631aaf6"/></dir></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="choiceai_personalisation.xml" hash="95d72912f3b13c5a399e3b2e5b89dba9"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir><dir name="base"><file name="script.phtml" hash="3e5799dc6ccf5b4f120400d48f5f95d2"/></dir></dir></dir></dir></dir><dir name="layout"><file name="choiceai_personalisation.xml" hash="95d72912f3b13c5a399e3b2e5b89dba9"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|