Version Notes
v1.0.5
Added compatibility with Klarna
v1.0.4
Fixed bug in PHP 5.4
v1.0.3
Refresh caching
Fix bug when having a multi store setup for SKU check
v1.0.2
Bug fix release
v1.0.1
Stability improvements
Logging into separate logfile
v.1.0.0
* Initial official release
Download this release
Release Info
Developer | Maxicycle Software GmbH |
Extension | MaxicycleCom_Connector |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- app/code/community/Maxicycle/Connector/Helper/Data.php +3 -1
- app/code/community/Maxicycle/Connector/Model/Observer.php +270 -102
- app/code/community/Maxicycle/Connector/controllers/Adminhtml/InstallationController.php +4 -0
- app/code/community/Maxicycle/Connector/etc/config.xml +12 -3
- app/code/community/Maxicycle/Connector/sql/maxicycle_setup/upgrade-1.0.3-1.0.4.php +36 -0
- app/code/community/Maxicycle/Connector/sql/maxicycle_setup/upgrade-1.0.4-1.0.5.php +36 -0
- app/design/adminhtml/default/default/template/maxicycle/connector/installation/step1.phtml +11 -0
- package.xml +7 -5
app/code/community/Maxicycle/Connector/Helper/Data.php
CHANGED
@@ -20,6 +20,7 @@ class Maxicycle_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
20 |
$order_costs_key = 'maxicycle/maxicycle_option/order_costs';
|
21 |
$product_costs_type_key = 'maxicycle/maxicycle_option/product_costs_type';
|
22 |
$valid_statuses_key = 'maxicycle/maxicycle_option/valid_statuses';
|
|
|
23 |
|
24 |
return array(
|
25 |
'is_enable' => Mage::getStoreConfig($is_enable_key, $store_id),
|
@@ -30,7 +31,8 @@ class Maxicycle_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
30 |
'use_tax' => Mage::getStoreConfig($use_tax_key, $store_id),
|
31 |
'use_shipping' => Mage::getStoreConfig($use_shipping_key, $store_id),
|
32 |
'order_costs' => Mage::getStoreConfig($order_costs_key, $store_id),
|
33 |
-
'valid_statuses' => explode(',', Mage::getStoreConfig($valid_statuses_key, $store_id))
|
|
|
34 |
);
|
35 |
}
|
36 |
|
20 |
$order_costs_key = 'maxicycle/maxicycle_option/order_costs';
|
21 |
$product_costs_type_key = 'maxicycle/maxicycle_option/product_costs_type';
|
22 |
$valid_statuses_key = 'maxicycle/maxicycle_option/valid_statuses';
|
23 |
+
$add_during_checkout_key = 'maxicycle/maxicycle_option/add_during_checkout';
|
24 |
|
25 |
return array(
|
26 |
'is_enable' => Mage::getStoreConfig($is_enable_key, $store_id),
|
31 |
'use_tax' => Mage::getStoreConfig($use_tax_key, $store_id),
|
32 |
'use_shipping' => Mage::getStoreConfig($use_shipping_key, $store_id),
|
33 |
'order_costs' => Mage::getStoreConfig($order_costs_key, $store_id),
|
34 |
+
'valid_statuses' => explode(',', Mage::getStoreConfig($valid_statuses_key, $store_id)),
|
35 |
+
'add_during_checkout' => Mage::getStoreConfig($add_during_checkout_key, $store_id)
|
36 |
);
|
37 |
}
|
38 |
|
app/code/community/Maxicycle/Connector/Model/Observer.php
CHANGED
@@ -7,13 +7,13 @@
|
|
7 |
* @package Maxicycle_Connector
|
8 |
* @copyright Copyright (c) 2015 (http://www.maxicycle.com)
|
9 |
*/
|
10 |
-
class Maxicycle_Connector_Model_Observer
|
11 |
|
12 |
var $_db = null;
|
13 |
var $_dbResource = null;
|
14 |
var $_now = '';
|
15 |
var $_config = array();
|
16 |
-
|
17 |
public function __construct() {
|
18 |
$this->_db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
19 |
$this->_dbResource = Mage::getSingleton('core/resource');
|
@@ -21,96 +21,135 @@ class Maxicycle_Connector_Model_Observer {
|
|
21 |
}
|
22 |
|
23 |
private function setConfig($store_id) {
|
24 |
-
$this->_config = Mage::helper('maxicycle')->getConfiguration($store_id);
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
// add PRODUCT after order placement
|
28 |
-
|
|
|
|
|
|
|
29 |
try {
|
30 |
$order = $observer->getOrder();
|
31 |
$this->setConfig($order->getStoreId());
|
32 |
-
if (
|
33 |
-
Mage::log('
|
34 |
-
$active_campaigns = $this->
|
35 |
// If there is some active campaign
|
36 |
if (count($active_campaigns) > 0) {
|
37 |
-
Mage::log('
|
38 |
// Loop over active campaings
|
39 |
foreach ($active_campaigns as $campaign) {
|
40 |
// add product to Order
|
41 |
-
$this->
|
42 |
// Set campaign_id to order
|
43 |
$order->setMaxicycleCampaignId($campaign['campaign_id']);
|
44 |
$maxicycle_customer_id = $this->setCustomerIdToOrder($order, $campaign);
|
45 |
// check and mark if order is response order
|
46 |
-
$
|
47 |
}
|
48 |
} else {
|
49 |
-
Mage::log('
|
50 |
}
|
51 |
} else {
|
52 |
-
Mage::log('
|
53 |
}
|
54 |
}
|
55 |
catch(Exception $e) {
|
56 |
Mage::log('Order Place After Exception: ' .$e->getMessage(), null, 'maxicycle.log');
|
57 |
-
}
|
58 |
}
|
|
|
59 |
|
60 |
-
|
|
|
61 |
try {
|
62 |
$order = $observer->getOrder();
|
63 |
$this->setConfig($order->getStoreId());
|
64 |
-
Mage::log('
|
65 |
//Mage::log(json_encode($this->_config), null, 'maxicycle.log');
|
66 |
//Mage::log($this->_config['valid_statuses'], null, 'maxicycle.log');
|
67 |
// Check if Maxicycle is active and a valid status
|
68 |
if ($this->shouldExport($order)) {
|
69 |
-
Mage::log('
|
70 |
// Load order info
|
71 |
-
Mage::log('
|
72 |
-
Mage::log('
|
73 |
// Get all active campaigns
|
74 |
-
// Mage::log('
|
75 |
// TODO: refactor this, order has campaign id already
|
76 |
$active_campaigns = $this->_db->fetchAll("SELECT * FROM " . $this->_dbResource->getTableName('maxicycle/campaigns') .
|
77 |
" WHERE campaign_start <= '$this->_now' AND response_time_end >= '$this->_now' AND store_id = " . $order->getStoreId());
|
78 |
// If there are some active campaigns
|
79 |
if (count($active_campaigns) > 0) {
|
80 |
-
Mage::log('
|
81 |
// Loop over active campaings
|
82 |
foreach ($active_campaigns as $campaign) {
|
83 |
$this->exportToResults($order, $campaign);
|
84 |
}
|
85 |
} else {
|
86 |
-
Mage::log('
|
87 |
}
|
88 |
} else {
|
89 |
# do nothing
|
90 |
-
Mage::log('
|
91 |
}
|
92 |
}
|
93 |
catch(Exception $e) {
|
94 |
Mage::log('Order Save After Exception: ' .$e->getMessage(), null, 'maxicycle.log');
|
95 |
}
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
}
|
110 |
}
|
111 |
|
112 |
private function exportToResults($order, $campaign) {
|
113 |
-
Mage::log('
|
114 |
$order_id = $order->getIncrementId();
|
115 |
// check if already exported
|
116 |
$previous_order_exists = $this->_db->fetchAll("SELECT order_id FROM " .
|
@@ -119,10 +158,10 @@ class Maxicycle_Connector_Model_Observer {
|
|
119 |
" AND order_id = ". $order_id ." LIMIT 1");
|
120 |
|
121 |
if (count($previous_order_exists) == 1) {
|
122 |
-
Mage::log('
|
123 |
} else {
|
124 |
|
125 |
-
Mage::log('
|
126 |
|
127 |
// no idea why we do this, but we check and set the customer id to the order
|
128 |
$maxicycle_customer_id = $order->getMaxicycleCustomerId();
|
@@ -148,9 +187,9 @@ class Maxicycle_Connector_Model_Observer {
|
|
148 |
// Save order data into Maxicycle orders table
|
149 |
try {
|
150 |
$result = Mage::getModel('maxicycle/results')->setData($data)->save();
|
151 |
-
Mage::log('
|
152 |
} catch (Exception $e) {
|
153 |
-
Mage::log('
|
154 |
}
|
155 |
}
|
156 |
}
|
@@ -166,13 +205,13 @@ class Maxicycle_Connector_Model_Observer {
|
|
166 |
|
167 |
$maxicycle_customer_id = 0;
|
168 |
|
169 |
-
// If not then assign maxicycle customer
|
170 |
if (count($maxicycle_customer_id_exist) > 0) {
|
171 |
$maxicycle_customer_id = intval($maxicycle_customer_id_exist[0]['maxicycle_customer_id']);
|
172 |
-
Mage::log('
|
173 |
} else {
|
174 |
$maxicycle_customer_id = $order->getEntityId();
|
175 |
-
Mage::log('
|
176 |
}
|
177 |
$order->setMaxicycleCustomerId($maxicycle_customer_id);
|
178 |
return $maxicycle_customer_id;
|
@@ -201,21 +240,21 @@ class Maxicycle_Connector_Model_Observer {
|
|
201 |
if ($product_costs_type == '1') {
|
202 |
// get product price from specified attribute
|
203 |
$bp = floatval($product->getData($product_costs_attribute));
|
204 |
-
// Mage::log('
|
205 |
if ($bp != 0) {
|
206 |
-
// Mage::log('
|
207 |
$item_costs += ($item_quantity * $bp);
|
208 |
} else {
|
209 |
-
// Mage::log('
|
210 |
$item_costs += ($item_quantity * $item_price);
|
211 |
}
|
212 |
} else {
|
213 |
-
// Mage::log('
|
214 |
if (floatval($product_costs_fixed) != 0) {
|
215 |
// deduct percentage
|
216 |
$fixed_percentage = floatval($product_costs_fixed) / 100.00;
|
217 |
$item_costs += ($item_quantity * $item_price * $fixed_percentage);
|
218 |
-
// Mage::log('
|
219 |
} else {
|
220 |
$item_costs += ($item_quantity * $item_price);
|
221 |
}
|
@@ -224,10 +263,10 @@ class Maxicycle_Connector_Model_Observer {
|
|
224 |
|
225 |
// deduct specified average order costs
|
226 |
$gross_profit = ($grand_total - floatval($avg_order_costs));
|
227 |
-
Mage::log('
|
228 |
// deduct tax
|
229 |
if ($use_tax) {
|
230 |
-
Mage::log('
|
231 |
$gross_profit -= floatval($order->getTaxAmount());
|
232 |
}
|
233 |
// deduct order item costs
|
@@ -235,65 +274,102 @@ class Maxicycle_Connector_Model_Observer {
|
|
235 |
return $gross_profit;
|
236 |
}
|
237 |
|
238 |
-
private function
|
239 |
-
Mage::log('
|
240 |
-
$
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
break;
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
} else {
|
283 |
-
Mage::log('
|
284 |
}
|
285 |
}
|
286 |
|
287 |
private function checkIfResponseOrder($order, $maxicycle_customer_id, $campaign) {
|
288 |
-
Mage::log('
|
289 |
-
Mage::log('
|
290 |
$response_to_order_id = NULL;
|
291 |
// Identify if it is response order
|
292 |
$previous_order_exists = $this->_db->fetchAll("SELECT order_id FROM " . $this->_dbResource->getTableName('maxicycle/results') .
|
293 |
" WHERE campaign_id = " . $campaign['campaign_id'] .
|
294 |
" AND maxicycle_customer_id = $maxicycle_customer_id AND campaign_order_type IS NOT NULL ORDER BY created_at DESC LIMIT 1");
|
295 |
if (count($previous_order_exists) == 1) {
|
296 |
-
Mage::log('
|
297 |
$response_to_order_id = $previous_order_exists[0]['order_id'];
|
298 |
// Set it into order
|
299 |
$order->setMaxicycleResponseToOrderId($response_to_order_id);
|
@@ -309,24 +385,116 @@ class Maxicycle_Connector_Model_Observer {
|
|
309 |
// requires config to be set
|
310 |
private function validStatus($order) {
|
311 |
$status = $order->getStatus();
|
312 |
-
Mage::log('
|
313 |
$valid_status = in_array($order->getStatus(), $this->_config['valid_statuses']);
|
314 |
-
Mage::log('
|
315 |
return $valid_status;
|
316 |
}
|
317 |
|
318 |
// requires _config to be set
|
319 |
private function moduleEnabled() {
|
320 |
$enabled = intval($this->_config['is_enable']);
|
321 |
-
Mage::log('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
return $enabled;
|
323 |
}
|
324 |
|
325 |
// should have type set - fixes bug when exported before order_place_after_ran
|
326 |
-
private function hasCampaignOrderTypeSet($
|
327 |
-
$order_type = $
|
328 |
$has_type_set = isset($order_type);
|
329 |
-
Mage::log('
|
330 |
return $has_type_set;
|
331 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
7 |
* @package Maxicycle_Connector
|
8 |
* @copyright Copyright (c) 2015 (http://www.maxicycle.com)
|
9 |
*/
|
10 |
+
class Maxicycle_Connector_Model_Observer{
|
11 |
|
12 |
var $_db = null;
|
13 |
var $_dbResource = null;
|
14 |
var $_now = '';
|
15 |
var $_config = array();
|
16 |
+
|
17 |
public function __construct() {
|
18 |
$this->_db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
19 |
$this->_dbResource = Mage::getSingleton('core/resource');
|
21 |
}
|
22 |
|
23 |
private function setConfig($store_id) {
|
24 |
+
$this->_config = Mage::helper('maxicycle')->getConfiguration($store_id);
|
25 |
}
|
26 |
|
27 |
+
// get all active campaigns running or in response time
|
28 |
+
private function getActiveCampaigns() {
|
29 |
+
return $this->_db->fetchAll("SELECT * FROM " . $this->_dbResource->getTableName('maxicycle/campaigns') . " WHERE campaign_start <= '$this->_now' AND response_time_end >= '$this->_now' AND store_id = " . Mage::app()->getStore()->getId());
|
30 |
+
}
|
31 |
+
|
32 |
+
// will add product to quote table to have product ready for payment methods
|
33 |
+
// like Klarna which sends the cart items before the actual order creation
|
34 |
+
public function add_product_to_quote($observer) {
|
35 |
+
Mage::log('controller_action_predispatch_checkout_onepage_index', null, 'maxicycle.log');
|
36 |
+
try {
|
37 |
+
$quote = $this->getQuote();
|
38 |
+
$this->setConfig($quote->getStoreId());
|
39 |
+
if ($this->moduleEnabled() && $this->checkoutEnabled() && !$this->hasCampaignOrderTypeSet($quote)) {
|
40 |
+
Mage::log('QUOTE: adding product to order', null, 'maxicycle.log');
|
41 |
+
$active_campaigns = $this->getActiveCampaigns();
|
42 |
+
// If there is some active campaign
|
43 |
+
if (count($active_campaigns) > 0) {
|
44 |
+
Mage::log('QUOTE: active campaigns, checking for product to add', null, 'maxicycle.log');
|
45 |
+
// Loop over active campaings
|
46 |
+
foreach ($active_campaigns as $campaign) {
|
47 |
+
// add product to Quote
|
48 |
+
$this->_addProductToCart($quote, $campaign);
|
49 |
+
$quote->setMaxicycleCampaignId($campaign['campaign_id']);
|
50 |
+
}
|
51 |
+
} else {
|
52 |
+
Mage::log('QUOTE: No active campaigns, not adding a product', null, 'maxicycle.log');
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
Mage::log('QUOTE: Checkout adding disabled or product already added', null, 'maxicycle.log');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
catch(Exception $e) {
|
59 |
+
Mage::log('QUOTE: Adding product to quote failed: ' .$e->getMessage(), null, 'maxicycle.log');
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
// add PRODUCT after order placement
|
65 |
+
// This needs to run for all payment methods that skip the checkout like
|
66 |
+
// Paypal express
|
67 |
+
public function add_product_to_order($observer) {
|
68 |
+
Mage::log('adding product to order', null, 'maxicycle.log');
|
69 |
try {
|
70 |
$order = $observer->getOrder();
|
71 |
$this->setConfig($order->getStoreId());
|
72 |
+
if ($this->moduleEnabled()) {
|
73 |
+
Mage::log('adding product to order', null, 'maxicycle.log');
|
74 |
+
$active_campaigns = $this->getActiveCampaigns();
|
75 |
// If there is some active campaign
|
76 |
if (count($active_campaigns) > 0) {
|
77 |
+
Mage::log('ORDER: active campaigns, checking for product to add', null, 'maxicycle.log');
|
78 |
// Loop over active campaings
|
79 |
foreach ($active_campaigns as $campaign) {
|
80 |
// add product to Order
|
81 |
+
$this->_addProductToOrder($order, $campaign);
|
82 |
// Set campaign_id to order
|
83 |
$order->setMaxicycleCampaignId($campaign['campaign_id']);
|
84 |
$maxicycle_customer_id = $this->setCustomerIdToOrder($order, $campaign);
|
85 |
// check and mark if order is response order
|
86 |
+
$this->checkIfResponseOrder($order, $maxicycle_customer_id, $campaign);
|
87 |
}
|
88 |
} else {
|
89 |
+
Mage::log('No active campaigns, not adding a product', null, 'maxicycle.log');
|
90 |
}
|
91 |
} else {
|
92 |
+
Mage::log('module disabled', null, 'maxicycle.log');
|
93 |
}
|
94 |
}
|
95 |
catch(Exception $e) {
|
96 |
Mage::log('Order Place After Exception: ' .$e->getMessage(), null, 'maxicycle.log');
|
97 |
+
}
|
98 |
}
|
99 |
+
|
100 |
|
101 |
+
// Export to results table if right status was reached
|
102 |
+
public function sales_order_save_after($observer) {
|
103 |
try {
|
104 |
$order = $observer->getOrder();
|
105 |
$this->setConfig($order->getStoreId());
|
106 |
+
Mage::log('after save hook for order:' . $order->getEntityId(), null, 'maxicycle.log');
|
107 |
//Mage::log(json_encode($this->_config), null, 'maxicycle.log');
|
108 |
//Mage::log($this->_config['valid_statuses'], null, 'maxicycle.log');
|
109 |
// Check if Maxicycle is active and a valid status
|
110 |
if ($this->shouldExport($order)) {
|
111 |
+
Mage::log('valid status: ' . $order->getStatus(), null, 'maxicycle.log');
|
112 |
// Load order info
|
113 |
+
Mage::log('Order ID ' . $order->getEntityId(), null, 'maxicycle.log');
|
114 |
+
Mage::log('valid status: ' . $order->getStatus(), null, 'maxicycle.log');
|
115 |
// Get all active campaigns
|
116 |
+
// Mage::log('Current Store ' . $order->getStoreId(), null, 'maxicycle.log');
|
117 |
// TODO: refactor this, order has campaign id already
|
118 |
$active_campaigns = $this->_db->fetchAll("SELECT * FROM " . $this->_dbResource->getTableName('maxicycle/campaigns') .
|
119 |
" WHERE campaign_start <= '$this->_now' AND response_time_end >= '$this->_now' AND store_id = " . $order->getStoreId());
|
120 |
// If there are some active campaigns
|
121 |
if (count($active_campaigns) > 0) {
|
122 |
+
Mage::log('active campaigns', null, 'maxicycle.log');
|
123 |
// Loop over active campaings
|
124 |
foreach ($active_campaigns as $campaign) {
|
125 |
$this->exportToResults($order, $campaign);
|
126 |
}
|
127 |
} else {
|
128 |
+
Mage::log('No active campaigns', null, 'maxicycle.log');
|
129 |
}
|
130 |
} else {
|
131 |
# do nothing
|
132 |
+
Mage::log('module disabled or invalid status', null, 'maxicycle.log');
|
133 |
}
|
134 |
}
|
135 |
catch(Exception $e) {
|
136 |
Mage::log('Order Save After Exception: ' .$e->getMessage(), null, 'maxicycle.log');
|
137 |
}
|
138 |
}
|
139 |
+
|
140 |
+
private function _isTreatment($treatment_size) {
|
141 |
+
// Generate random number
|
142 |
+
$random_number = rand(0, 100);
|
143 |
+
// Log random number for overview
|
144 |
+
if ($random_number <= $treatment_size) {
|
145 |
+
return true;
|
146 |
+
} else {
|
147 |
+
return false;
|
148 |
+
}
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
private function exportToResults($order, $campaign) {
|
152 |
+
Mage::log('Starting Export', null, 'maxicycle.log');
|
153 |
$order_id = $order->getIncrementId();
|
154 |
// check if already exported
|
155 |
$previous_order_exists = $this->_db->fetchAll("SELECT order_id FROM " .
|
158 |
" AND order_id = ". $order_id ." LIMIT 1");
|
159 |
|
160 |
if (count($previous_order_exists) == 1) {
|
161 |
+
Mage::log('Order already exported: ' . $order->getIncrementId(), null, 'maxicycle.log');
|
162 |
} else {
|
163 |
|
164 |
+
Mage::log('exporting status: ' . $order->getStatus(), null, 'maxicycle.log');
|
165 |
|
166 |
// no idea why we do this, but we check and set the customer id to the order
|
167 |
$maxicycle_customer_id = $order->getMaxicycleCustomerId();
|
187 |
// Save order data into Maxicycle orders table
|
188 |
try {
|
189 |
$result = Mage::getModel('maxicycle/results')->setData($data)->save();
|
190 |
+
Mage::log('Result: ' . $result->getId(), null, 'maxicycle.log');
|
191 |
} catch (Exception $e) {
|
192 |
+
Mage::log('ERROR: ' . $e->getMessage(), null, 'maxicycle.log');
|
193 |
}
|
194 |
}
|
195 |
}
|
205 |
|
206 |
$maxicycle_customer_id = 0;
|
207 |
|
208 |
+
// If not then assign maxicycle customer as order entity ID is, if yes then use maxicycle_customer_id from the past
|
209 |
if (count($maxicycle_customer_id_exist) > 0) {
|
210 |
$maxicycle_customer_id = intval($maxicycle_customer_id_exist[0]['maxicycle_customer_id']);
|
211 |
+
Mage::log('existing customer id found: ' . $maxicycle_customer_id, null, 'maxicycle.log');
|
212 |
} else {
|
213 |
$maxicycle_customer_id = $order->getEntityId();
|
214 |
+
Mage::log('new customer id: ' . $maxicycle_customer_id, null, 'maxicycle.log');
|
215 |
}
|
216 |
$order->setMaxicycleCustomerId($maxicycle_customer_id);
|
217 |
return $maxicycle_customer_id;
|
240 |
if ($product_costs_type == '1') {
|
241 |
// get product price from specified attribute
|
242 |
$bp = floatval($product->getData($product_costs_attribute));
|
243 |
+
// Mage::log('Gross profit: attribute', null, 'maxicycle.log');
|
244 |
if ($bp != 0) {
|
245 |
+
// Mage::log('Gross profit: attribute value: ' . $bp, null, 'maxicycle.log');
|
246 |
$item_costs += ($item_quantity * $bp);
|
247 |
} else {
|
248 |
+
// Mage::log('Gross profit: attribute value empty ' . $bp, null, 'maxicycle.log');
|
249 |
$item_costs += ($item_quantity * $item_price);
|
250 |
}
|
251 |
} else {
|
252 |
+
// Mage::log('Gross profit: fixed product price - percentage', null, 'maxicycle.log');
|
253 |
if (floatval($product_costs_fixed) != 0) {
|
254 |
// deduct percentage
|
255 |
$fixed_percentage = floatval($product_costs_fixed) / 100.00;
|
256 |
$item_costs += ($item_quantity * $item_price * $fixed_percentage);
|
257 |
+
// Mage::log('Gross profit: item costs ' . $item_costs, null, 'maxicycle.log');
|
258 |
} else {
|
259 |
$item_costs += ($item_quantity * $item_price);
|
260 |
}
|
263 |
|
264 |
// deduct specified average order costs
|
265 |
$gross_profit = ($grand_total - floatval($avg_order_costs));
|
266 |
+
Mage::log('Gross profit: Grand total - avg order costs' . $gross_profit, null, 'maxicycle.log');
|
267 |
// deduct tax
|
268 |
if ($use_tax) {
|
269 |
+
Mage::log('Gross profit, deducting tax', null, 'maxicycle.log');
|
270 |
$gross_profit -= floatval($order->getTaxAmount());
|
271 |
}
|
272 |
// deduct order item costs
|
274 |
return $gross_profit;
|
275 |
}
|
276 |
|
277 |
+
private function _alreadyMaxicycleOrder($order) {
|
278 |
+
Mage::log('Check if quote is already maxicycle order', null, 'maxicycle.log');
|
279 |
+
$quote_id = $order->getQuoteId();
|
280 |
+
$quote = Mage::getModel('sales/quote')->load($quote_id);
|
281 |
+
$campaign_type_set = $this->hasCampaignOrderTypeSet($quote);
|
282 |
+
// copy values
|
283 |
+
if ($campaign_type_set) {
|
284 |
+
$order->setMaxicycleOrderType($quote->getMaxicycleOrderType());
|
285 |
+
$order->setMaxicycleCampaignId($quote->getMaxicycleCampaignId());
|
286 |
+
}
|
287 |
+
return $campaign_type_set;
|
288 |
+
}
|
289 |
+
|
290 |
+
private function _addProductToOrder($order, $campaign) {
|
291 |
+
Mage::log('Place order -> check adding order', null, 'maxicycle.log');
|
292 |
+
// exit if product was already added in quote
|
293 |
+
$already_added = $this->_alreadyMaxicycleOrder($order);
|
294 |
+
if ($already_added) {
|
295 |
+
Mage::log('Product was already added to order', null, 'maxicycle.log');
|
296 |
+
} else {
|
297 |
+
// Process condition - ADD PRODUCT - only if campaign is still in CP and not already in RT
|
298 |
+
if ($this->_campaignActive($campaign)) {
|
299 |
+
// conditiond = treatment_group_size:90
|
300 |
+
$condition = explode(":", $campaign['condition']);
|
301 |
+
// Get code and value of condition
|
302 |
+
$treatment_group_size = $condition[1];
|
303 |
+
// Test condition
|
304 |
+
// if treatment condition true -> insert SKU
|
305 |
+
if ($this->_isTreatment($treatment_group_size)) {
|
306 |
+
Mage::log('Product was NOT already added to order', null, 'maxicycle.log');
|
307 |
+
$this->addOrderItem($order, $campaign);
|
308 |
+
// Set it into order
|
309 |
+
$order->setMaxicycleOrderType('treatment');
|
310 |
+
Mage::log('OrderType: treatment', null, 'maxicycle.log');
|
311 |
+
} else {
|
312 |
+
// Set it into order to be used when exporting the results
|
313 |
+
$order->setMaxicycleOrderType('control');
|
314 |
+
Mage::log('OrderType: control', null, 'maxicycle.log');
|
|
|
|
|
|
|
|
|
315 |
}
|
316 |
+
|
317 |
+
} else {
|
318 |
+
Mage::log('Not adding product, campaign in response period', null, 'maxicycle.log');
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
private function checkIfSKUAlreadyAdded($items, $sku) {
|
324 |
+
$added = FALSE;
|
325 |
+
Foreach($items as $item){
|
326 |
+
if ($sku == $item->getSku()) {
|
327 |
+
$added = TRUE;
|
328 |
}
|
329 |
+
}
|
330 |
+
return $added;
|
331 |
+
}
|
332 |
+
|
333 |
+
// create and order item to product
|
334 |
+
private function addOrderItem($order, $campaign) {
|
335 |
+
Mage::log('Adding product to order', null, 'maxicycle.log');
|
336 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $campaign['product_sku']);
|
337 |
+
if ($product) {
|
338 |
+
// Save product into order
|
339 |
+
$rowTotal = 0.00;
|
340 |
+
$order_item = Mage::getModel('sales/order_item')
|
341 |
+
->setStoreId($order->getStore()->getStoreId())
|
342 |
+
->setQuoteItemId(null)
|
343 |
+
->setQuoteParentItemId(null)
|
344 |
+
->setProductId($product->getId())
|
345 |
+
->setProductType($product->getTypeId())
|
346 |
+
->setQtyBackordered(null)
|
347 |
+
->setTotalQtyOrdered(1)
|
348 |
+
->setQtyOrdered(1)
|
349 |
+
->setName($product->getName())
|
350 |
+
->setSku($product->getSku())
|
351 |
+
->setPrice(0)
|
352 |
+
->setBasePrice(0)
|
353 |
+
->setOriginalPrice(0)
|
354 |
+
->setRowTotal($rowTotal)
|
355 |
+
->setBaseRowTotal($rowTotal)
|
356 |
+
->setOrder($order);
|
357 |
+
$order_item->save();
|
358 |
} else {
|
359 |
+
Mage::log('WARNING: Product ' . $campaign['product_sku'] . ' not found for control order', null, 'maxicycle.log');
|
360 |
}
|
361 |
}
|
362 |
|
363 |
private function checkIfResponseOrder($order, $maxicycle_customer_id, $campaign) {
|
364 |
+
Mage::log('campaign: ' . $campaign['campaign_id'], null, 'maxicycle.log');
|
365 |
+
Mage::log('customer id: ' . $maxicycle_customer_id, null, 'maxicycle.log');
|
366 |
$response_to_order_id = NULL;
|
367 |
// Identify if it is response order
|
368 |
$previous_order_exists = $this->_db->fetchAll("SELECT order_id FROM " . $this->_dbResource->getTableName('maxicycle/results') .
|
369 |
" WHERE campaign_id = " . $campaign['campaign_id'] .
|
370 |
" AND maxicycle_customer_id = $maxicycle_customer_id AND campaign_order_type IS NOT NULL ORDER BY created_at DESC LIMIT 1");
|
371 |
if (count($previous_order_exists) == 1) {
|
372 |
+
Mage::log('response order', null, 'maxicycle.log');
|
373 |
$response_to_order_id = $previous_order_exists[0]['order_id'];
|
374 |
// Set it into order
|
375 |
$order->setMaxicycleResponseToOrderId($response_to_order_id);
|
385 |
// requires config to be set
|
386 |
private function validStatus($order) {
|
387 |
$status = $order->getStatus();
|
388 |
+
Mage::log('order status: ' . $status, null, 'maxicycle.log');
|
389 |
$valid_status = in_array($order->getStatus(), $this->_config['valid_statuses']);
|
390 |
+
Mage::log('has valid status: ' . $valid_status, null, 'maxicycle.log');
|
391 |
return $valid_status;
|
392 |
}
|
393 |
|
394 |
// requires _config to be set
|
395 |
private function moduleEnabled() {
|
396 |
$enabled = intval($this->_config['is_enable']);
|
397 |
+
Mage::log('Module enabled true/false: ' . $enabled, null, 'maxicycle.log');
|
398 |
+
return $enabled;
|
399 |
+
}
|
400 |
+
|
401 |
+
// requires _config to be set
|
402 |
+
// checks if product should be added during checkout
|
403 |
+
private function checkoutEnabled() {
|
404 |
+
$enabled = intval($this->_config['add_during_checkout']);
|
405 |
+
Mage::log('Checkout enabled true/false: ' . $enabled, null, 'maxicycle.log');
|
406 |
return $enabled;
|
407 |
}
|
408 |
|
409 |
// should have type set - fixes bug when exported before order_place_after_ran
|
410 |
+
private function hasCampaignOrderTypeSet($quote) {
|
411 |
+
$order_type = $quote->getMaxicycleOrderType();
|
412 |
$has_type_set = isset($order_type);
|
413 |
+
Mage::log('Campaign order type is set true/false: ' . $has_type_set, null, 'maxicycle.log');
|
414 |
return $has_type_set;
|
415 |
}
|
416 |
+
|
417 |
+
private function _campaignActive($campaign) {
|
418 |
+
$campaign_time_end = strtotime($campaign['campaign_end']);
|
419 |
+
// condition is treatment group size > 0
|
420 |
+
return ($campaign_time_end >= time());
|
421 |
+
}
|
422 |
+
|
423 |
+
protected function _addProductToCart($quote, $campaign) {
|
424 |
+
Mage::log('Checkout: adding order', null, 'maxicycle.log');
|
425 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $campaign['product_sku']);
|
426 |
+
// Process condition - ADD PRODUCT - only if campaign is still in CP and not already in RT
|
427 |
+
if ($this->_campaignActive($campaign)) {
|
428 |
+
// conditiond = treatment_group_size:90
|
429 |
+
$condition = explode(":", $campaign['condition']);
|
430 |
+
// Get code and value of condition
|
431 |
+
$treatment_group_size = $condition[1];
|
432 |
+
// Test condition
|
433 |
+
// if treatment condition true -> insert SKU
|
434 |
+
if ($this->_isTreatment($treatment_group_size)) {
|
435 |
+
// exit if product was already added in quote
|
436 |
+
$already_added = $this->checkIfSKUAlreadyAdded($quote->getAllItems(), $campaign['product_sku']);
|
437 |
+
if ($already_added) {
|
438 |
+
Mage::log('Product was already added to order', null, 'maxicycle.log');
|
439 |
+
} else {
|
440 |
+
Mage::log('Product was NOT already added to order', null, 'maxicycle.log');
|
441 |
+
$this->_addQuoteItem($product, $quote);
|
442 |
+
}
|
443 |
+
// Set it into order
|
444 |
+
$quote->setMaxicycleOrderType('treatment');
|
445 |
+
Mage::log('OrderType: treatment', null, 'maxicycle.log');
|
446 |
+
} else {
|
447 |
+
// Set it into order to be used when exporting the results
|
448 |
+
$quote->setMaxicycleOrderType('control');
|
449 |
+
Mage::log('OrderType: control', null, 'maxicycle.log');
|
450 |
+
}
|
451 |
+
|
452 |
+
} else {
|
453 |
+
Mage::log('Not adding product, campaign in response period', null, 'maxicycle.log');
|
454 |
+
}
|
455 |
+
|
456 |
+
}
|
457 |
+
|
458 |
+
protected function _addQuoteItem($product, $quote) {
|
459 |
+
if ($product->getId()) {
|
460 |
+
try {
|
461 |
+
// Save product into quote
|
462 |
+
$rowTotal = 0.00;
|
463 |
+
$order_item = Mage::getModel('sales/quote_item')
|
464 |
+
->setStoreId($quote->getStore()->getStoreId())
|
465 |
+
->setQuoteId($quote->getId())
|
466 |
+
->setProduct($product)
|
467 |
+
->setQty(1)
|
468 |
+
->setPrice(0)
|
469 |
+
->setBasePrice(0)
|
470 |
+
->setCustomPrice(0)
|
471 |
+
->setOriginalCustomPrice(0)
|
472 |
+
->setRowTotal($rowTotal)
|
473 |
+
->setBaseRowTotal($rowTotal)
|
474 |
+
->setRowTotalWithDiscount($rowTotal)
|
475 |
+
->setRowTotalInclTax($rowTotal)
|
476 |
+
->setBaseRowTotalInclTax($rowTotal)
|
477 |
+
->setQuote($quote);
|
478 |
+
$order_item->save();
|
479 |
+
Mage::log('Saving product to quote', null, 'maxicycle.log');
|
480 |
+
|
481 |
+
} catch (Exception $e) {
|
482 |
+
Mage::log('Adding product to quote failed: ' .$e->getMessage(), null, 'maxicycle.log');
|
483 |
+
throw $e;
|
484 |
+
}
|
485 |
+
return true;
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
// get checkout from controller
|
490 |
+
public function getCheckout()
|
491 |
+
{
|
492 |
+
return Mage::getSingleton('checkout/session');
|
493 |
+
}
|
494 |
+
|
495 |
+
// get quote from checkout
|
496 |
+
public function getQuote()
|
497 |
+
{
|
498 |
+
return $this->getCheckout()->getQuote();
|
499 |
+
}
|
500 |
}
|
app/code/community/Maxicycle/Connector/controllers/Adminhtml/InstallationController.php
CHANGED
@@ -32,7 +32,9 @@ class Maxicycle_Connector_Adminhtml_InstallationController extends Mage_Adminhtm
|
|
32 |
$use_shipping = intval($this->getRequest()->getPost('use_shipping'));
|
33 |
$order_costs = floatval($this->getRequest()->getPost('order_costs'));
|
34 |
$valid_statuses = $this->getRequest()->getPost('valid_statuses');
|
|
|
35 |
|
|
|
36 |
// KEYS
|
37 |
$is_enable_key = 'maxicycle/maxicycle_option/enable';
|
38 |
$api_key_key = 'maxicycle/maxicycle_option/api_key';
|
@@ -43,6 +45,7 @@ class Maxicycle_Connector_Adminhtml_InstallationController extends Mage_Adminhtm
|
|
43 |
$order_costs_key = 'maxicycle/maxicycle_option/order_costs';
|
44 |
$product_costs_type_key = 'maxicycle/maxicycle_option/product_costs_type';
|
45 |
$valid_statuses_key = 'maxicycle/maxicycle_option/valid_statuses';
|
|
|
46 |
|
47 |
// UPDATES
|
48 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$is_enable_key', '$is_enable') ON DUPLICATE KEY UPDATE value = '$is_enable'");
|
@@ -54,6 +57,7 @@ class Maxicycle_Connector_Adminhtml_InstallationController extends Mage_Adminhtm
|
|
54 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$use_shipping_key', '$use_shipping') ON DUPLICATE KEY UPDATE value = '$use_shipping'");
|
55 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$order_costs_key', '$order_costs') ON DUPLICATE KEY UPDATE value = '$order_costs'");
|
56 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$valid_statuses_key', '" . implode(',', $valid_statuses) . "') ON DUPLICATE KEY UPDATE value = '" . implode(',', $valid_statuses) . "'");
|
|
|
57 |
|
58 |
// RESET CACHE
|
59 |
$cacheType = 'config';
|
32 |
$use_shipping = intval($this->getRequest()->getPost('use_shipping'));
|
33 |
$order_costs = floatval($this->getRequest()->getPost('order_costs'));
|
34 |
$valid_statuses = $this->getRequest()->getPost('valid_statuses');
|
35 |
+
$add_during_checkout_set = $this->getRequest()->getPost('add_during_checkout');
|
36 |
|
37 |
+
$add_during_checkout = isset($add_during_checkout_set) ? TRUE : FALSE;
|
38 |
// KEYS
|
39 |
$is_enable_key = 'maxicycle/maxicycle_option/enable';
|
40 |
$api_key_key = 'maxicycle/maxicycle_option/api_key';
|
45 |
$order_costs_key = 'maxicycle/maxicycle_option/order_costs';
|
46 |
$product_costs_type_key = 'maxicycle/maxicycle_option/product_costs_type';
|
47 |
$valid_statuses_key = 'maxicycle/maxicycle_option/valid_statuses';
|
48 |
+
$add_during_checkout_key = 'maxicycle/maxicycle_option/add_during_checkout';
|
49 |
|
50 |
// UPDATES
|
51 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$is_enable_key', '$is_enable') ON DUPLICATE KEY UPDATE value = '$is_enable'");
|
57 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$use_shipping_key', '$use_shipping') ON DUPLICATE KEY UPDATE value = '$use_shipping'");
|
58 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$order_costs_key', '$order_costs') ON DUPLICATE KEY UPDATE value = '$order_costs'");
|
59 |
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$valid_statuses_key', '" . implode(',', $valid_statuses) . "') ON DUPLICATE KEY UPDATE value = '" . implode(',', $valid_statuses) . "'");
|
60 |
+
$db->query("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('core_config_data') . " (scope,scope_id,path,value) VALUES('$scope', $store_id, '$add_during_checkout_key', '$add_during_checkout') ON DUPLICATE KEY UPDATE value = '$add_during_checkout'");
|
61 |
|
62 |
// RESET CACHE
|
63 |
$cacheType = 'config';
|
app/code/community/Maxicycle/Connector/etc/config.xml
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Maxicycle_Connector>
|
15 |
-
<version>1.0.
|
16 |
</Maxicycle_Connector>
|
17 |
</modules>
|
18 |
|
@@ -80,15 +80,24 @@
|
|
80 |
</maxicycle_read>
|
81 |
</resources>
|
82 |
<events>
|
83 |
-
|
84 |
<observers>
|
85 |
<maxicycle>
|
86 |
<type>singleton</type>
|
87 |
<class>maxicycle/observer</class>
|
88 |
-
<method>
|
89 |
</maxicycle>
|
90 |
</observers>
|
91 |
</sales_order_place_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
<sales_order_save_after>
|
93 |
<observers>
|
94 |
<maxicycle>
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Maxicycle_Connector>
|
15 |
+
<version>1.0.5</version>
|
16 |
</Maxicycle_Connector>
|
17 |
</modules>
|
18 |
|
80 |
</maxicycle_read>
|
81 |
</resources>
|
82 |
<events>
|
83 |
+
<sales_order_place_after>
|
84 |
<observers>
|
85 |
<maxicycle>
|
86 |
<type>singleton</type>
|
87 |
<class>maxicycle/observer</class>
|
88 |
+
<method>add_product_to_order</method>
|
89 |
</maxicycle>
|
90 |
</observers>
|
91 |
</sales_order_place_after>
|
92 |
+
<controller_action_predispatch_checkout_onepage_index>
|
93 |
+
<observers>
|
94 |
+
<maxicycle>
|
95 |
+
<type>singleton</type>
|
96 |
+
<class>maxicycle/observer</class>
|
97 |
+
<method>add_product_to_quote</method>
|
98 |
+
</maxicycle>
|
99 |
+
</observers>
|
100 |
+
</controller_action_predispatch_checkout_onepage_index>
|
101 |
<sales_order_save_after>
|
102 |
<observers>
|
103 |
<maxicycle>
|
app/code/community/Maxicycle/Connector/sql/maxicycle_setup/upgrade-1.0.3-1.0.4.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Maxicycle
|
5 |
+
*
|
6 |
+
* @category Maxicycle
|
7 |
+
* @package Maxicycle_Connector
|
8 |
+
* @copyright Copyright (c) 2015 (http://www.maxicycle.com)
|
9 |
+
*/
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
// Add order attribute
|
14 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'maxicycle_response_to_order_id',
|
15 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
16 |
+
'nullable' => true,
|
17 |
+
'default' => null,
|
18 |
+
'comment' => 'Maxicycle response id',
|
19 |
+
'length' => 100
|
20 |
+
));
|
21 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'maxicycle_order_type',
|
22 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
23 |
+
'nullable' => true,
|
24 |
+
'default' => null,
|
25 |
+
'comment' => 'Maxicycle order type' ,
|
26 |
+
'length' => 100
|
27 |
+
));
|
28 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'maxicycle_campaign_id',
|
29 |
+
array(
|
30 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
31 |
+
'length' => 10,
|
32 |
+
'nullable' => true,
|
33 |
+
'default' => null,
|
34 |
+
'comment' => 'Maxicycle campaign ID for order'
|
35 |
+
));
|
36 |
+
$installer->endSetup();
|
app/code/community/Maxicycle/Connector/sql/maxicycle_setup/upgrade-1.0.4-1.0.5.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Maxicycle
|
5 |
+
*
|
6 |
+
* @category Maxicycle
|
7 |
+
* @package Maxicycle_Connector
|
8 |
+
* @copyright Copyright (c) 2015 (http://www.maxicycle.com)
|
9 |
+
*/
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
// Add order attribute
|
14 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_quote'), 'maxicycle_response_to_order_id',
|
15 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
16 |
+
'nullable' => true,
|
17 |
+
'default' => null,
|
18 |
+
'comment' => 'Maxicycle response id',
|
19 |
+
'length' => 100
|
20 |
+
));
|
21 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_quote'), 'maxicycle_order_type',
|
22 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
23 |
+
'nullable' => true,
|
24 |
+
'default' => null,
|
25 |
+
'comment' => 'Maxicycle order type' ,
|
26 |
+
'length' => 100
|
27 |
+
));
|
28 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_quote'), 'maxicycle_campaign_id',
|
29 |
+
array(
|
30 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
31 |
+
'length' => 10,
|
32 |
+
'nullable' => true,
|
33 |
+
'default' => null,
|
34 |
+
'comment' => 'Maxicycle campaign ID for order'
|
35 |
+
));
|
36 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/maxicycle/connector/installation/step1.phtml
CHANGED
@@ -174,6 +174,17 @@
|
|
174 |
</p>
|
175 |
</td>
|
176 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
</table>
|
178 |
</div>
|
179 |
</div>
|
174 |
</p>
|
175 |
</td>
|
176 |
</tr>
|
177 |
+
<tr>
|
178 |
+
<td class="label">
|
179 |
+
<?php echo $this->__('Add package insert during checkout'); ?>:
|
180 |
+
</td>
|
181 |
+
<td class="value">
|
182 |
+
<input type="checkbox" value="1" name="add_during_checkout" <?php echo (intval($config['add_during_checkout']) == 1 ? ' checked' : ''); ?>>
|
183 |
+
<p class="note">
|
184 |
+
<span><?php echo $this->__('Check this box e.g. if you use Klarna invoice.'); ?></span>
|
185 |
+
</p>
|
186 |
+
</td>
|
187 |
+
</tr>
|
188 |
</table>
|
189 |
</div>
|
190 |
</div>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>MaxicycleCom_Connector</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.maxicycle/license">Copyright Maxicycle Software GmbH 2015</license>
|
7 |
<channel>community</channel>
|
@@ -11,7 +11,9 @@
|
|
11 |

|
12 |
Did you know that enclosing package inserts (coupons, catalogs, freebies, product samples, etc.) are extremely effective in driving follow-up orders from your existing customer base? Maxicycle is the solution that turns your packages into a real performance-based retention marketing channel with an amazing ROI: Create, manage, measure and optimise package inserts in a similar way than you are used from your AdWords or Facebook ads.
|
13 |
</description>
|
14 |
-
<notes>v1.0.
|
|
|
|
|
15 |
Fixed bug in PHP 5.4
|
16 |
v1.0.3
|
17 |
Refresh caching
|
@@ -27,9 +29,9 @@ Logging into separate logfile
|
|
27 |
v.1.0.0
|
28 |
* Initial official release</notes>
|
29 |
<authors><author><name>Maxicycle Software GmbH</name><user>maxicycle</user><email>support@maxicycle.com</email></author></authors>
|
30 |
-
<date>2015-09
|
31 |
-
<time>
|
32 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Maxicycle_Connector.xml" hash="0d64b2d2ad66099e225460c349125557"/></dir></target><target name="magecommunity"><dir name="Maxicycle"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="Campaigns"><file name="Grid.php" hash="c350b3b4e428bf5f11027a97e38167ae"/></dir><file name="Campaigns.php" hash="b09c985fc4215ecd937024e0364f319b"/><dir name="Cronlog"><file name="Grid.php" hash="256284d0455dbb136baf8e00d2a71a89"/></dir><file name="Cronlog.php" hash="577f5e50a80fbac7b83cf8d5727bbb5f"/><dir name="Results"><file name="Grid.php" hash="4236c80b8faa31e6cba5f184e0d45adc"/><dir name="Renderer"><file name="Campaign.php" hash="ef4d3f0cd6c3558367f82e07853414e6"/><file name="Flag2.php" hash="d8779254a77e19da81c91e81452a7e43"/><file name="Order.php" hash="aecdc4cb460c558773660778060cde0f"/></dir></dir><file name="Results.php" hash="4d32a5f15b1f3a18434e3b2754030659"/></dir></dir><dir name="Helper"><file name="Data.php" hash="
|
33 |
<compatible/>
|
34 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
35 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>MaxicycleCom_Connector</name>
|
4 |
+
<version>1.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.maxicycle/license">Copyright Maxicycle Software GmbH 2015</license>
|
7 |
<channel>community</channel>
|
11 |

|
12 |
Did you know that enclosing package inserts (coupons, catalogs, freebies, product samples, etc.) are extremely effective in driving follow-up orders from your existing customer base? Maxicycle is the solution that turns your packages into a real performance-based retention marketing channel with an amazing ROI: Create, manage, measure and optimise package inserts in a similar way than you are used from your AdWords or Facebook ads.
|
13 |
</description>
|
14 |
+
<notes>v1.0.5
|
15 |
+
Added compatibility with Klarna
|
16 |
+
v1.0.4
|
17 |
Fixed bug in PHP 5.4
|
18 |
v1.0.3
|
19 |
Refresh caching
|
29 |
v.1.0.0
|
30 |
* Initial official release</notes>
|
31 |
<authors><author><name>Maxicycle Software GmbH</name><user>maxicycle</user><email>support@maxicycle.com</email></author></authors>
|
32 |
+
<date>2015-10-09</date>
|
33 |
+
<time>07:12:57</time>
|
34 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Maxicycle_Connector.xml" hash="0d64b2d2ad66099e225460c349125557"/></dir></target><target name="magecommunity"><dir name="Maxicycle"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="Campaigns"><file name="Grid.php" hash="c350b3b4e428bf5f11027a97e38167ae"/></dir><file name="Campaigns.php" hash="b09c985fc4215ecd937024e0364f319b"/><dir name="Cronlog"><file name="Grid.php" hash="256284d0455dbb136baf8e00d2a71a89"/></dir><file name="Cronlog.php" hash="577f5e50a80fbac7b83cf8d5727bbb5f"/><dir name="Results"><file name="Grid.php" hash="4236c80b8faa31e6cba5f184e0d45adc"/><dir name="Renderer"><file name="Campaign.php" hash="ef4d3f0cd6c3558367f82e07853414e6"/><file name="Flag2.php" hash="d8779254a77e19da81c91e81452a7e43"/><file name="Order.php" hash="aecdc4cb460c558773660778060cde0f"/></dir></dir><file name="Results.php" hash="4d32a5f15b1f3a18434e3b2754030659"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a7df4cd21dc681b1887b21276e099c53"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="71be3bc47c32463bc8f6f84e901719ef"/><file name="Rest.php" hash="260c1849fc5dba7b5698d5160f427d5d"/></dir><file name="Campaigns.php" hash="4e60821d8a19ea5391921e5b358257dc"/><file name="Cronlog.php" hash="dc5eec5445c6c703429992b749c8ef2c"/><dir name="Mysql4"><dir name="Campaigns"><file name="Collection.php" hash="880cbcd1ab65efb9096965c267ad35cc"/></dir><file name="Campaigns.php" hash="98143aae26423260cccb496aac9d28f2"/><dir name="Cronlog"><file name="Collection.php" hash="44d321c218f66619fbbf14271fca361f"/></dir><file name="Cronlog.php" hash="299749238a435407cce37b5dc524c466"/><dir name="Results"><file name="Collection.php" hash="8b046e56516f2f1893b6f3d1e6e2b228"/><dir name="Renderer"><file name="Actions.php" hash="da76e0352436e0570c8e6506a121d031"/><file name="Status.php" hash="37878ac8231edee56041b714077f7aec"/></dir></dir><file name="Results.php" hash="8898f253c8dce9ebe3a6b289e26945a6"/></dir><file name="Observer.php" hash="fcf1cef79925c7bc67479fe7f2be04a4"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="ccae8f6fc1d48cb5ef6b761211e75bd9"/></dir></dir><file name="Results.php" hash="246fff1018a0b03f521ba96ec61b8a8e"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CampaignsController.php" hash="420557976cfeda32353ce0b5f435a252"/><file name="CronlogController.php" hash="eb58983412dec2890d22138adecb95a7"/><file name="InstallationController.php" hash="8f338320862fc72b7f2eaaf5a918e293"/><file name="ResultsController.php" hash="78633bbdd767350c56deef829c7b4a62"/></dir><file name="TestConnectionController.php" hash="ddb67e441e3478d45632905b78e5c362"/><file name="V1Controller.php" hash="8cf992ec3ab988d3b11f8428ea98d501"/></dir><dir name="data"><file name="data_sample.sql" hash="c02ad04dc9c1b43814ac7877970ab1ae"/></dir><dir name="etc"><file name="adminhtml.xml" hash="363126b0e935810dd07d42426ce9f766"/><file name="config.xml" hash="403a42ac42d65dc92b9dc4b69f97eb69"/></dir><dir name="sql"><dir name="maxicycle_setup"><file name="mysql4-install-1.0.0.php" hash="ac322e77f8b08beb2d326426f2c23121"/><file name="upgrade-1.0.0-1.0.1.php" hash="dba0e0a874a87c101b379de988646b1f"/><file name="upgrade-1.0.3-1.0.4.php" hash="dba0e0a874a87c101b379de988646b1f"/><file name="upgrade-1.0.4-1.0.5.php" hash="28f1d904f1dc1bebb1436bd93dca0122"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="maxicycle"><dir name="connector"><dir name="installation"><file name="step1.phtml" hash="1e6b091fb1c9f94533b2015835030d91"/></dir></dir></dir></dir><dir name="layout"><dir name="maxicycle"><dir name="connector"><file name="layout.xml" hash="b4c388d059df42d365c945f972e8cfca"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="maxicycle"><dir name="connector"><dir name="css"><file name="css.css" hash="6cb4c9ca0ce1288f028ea80284d368ae"/></dir></dir></dir></dir></dir></dir></target></contents>
|
35 |
<compatible/>
|
36 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
37 |
</package>
|