Version Notes
drone magento module - release 1.1.19
Download this release
Release Info
| Developer | Michał Blak |
| Extension | edroneCRM |
| Version | 1.1.19 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.18 to 1.1.19
- app/code/local/Edrone/Base/Block/Base.php +17 -17
- app/code/local/Edrone/Base/Block/Order.php +1 -406
- app/code/local/Edrone/Base/Helper/Config.php +8 -2
- app/code/local/Edrone/Base/Model/Observer.php +27 -595
- app/code/local/Edrone/Base/Model/Utilities/EdroneEvent.php +66 -0
- app/code/local/Edrone/Base/Model/Utilities/EdroneEventOrder.php +266 -0
- app/code/local/Edrone/Base/Model/Utilities/EdroneEventSubscribe.php +119 -0
- app/code/local/Edrone/Base/Model/Utilities/EdroneIns.php +121 -0
- app/code/local/Edrone/Base/etc/config.xml +8 -2
- app/code/local/Edrone/Base/etc/system.xml +4 -3
- app/design/frontend/base/default/template/edrone/cart_view.phtml +2 -2
- app/design/frontend/base/default/template/edrone/default.phtml +1 -1
- app/design/frontend/base/default/template/edrone/product_view.phtml +1 -1
- app/design/frontend/base/default/template/edrone/success_view.phtml +1 -2
- package.xml +5 -5
app/code/local/Edrone/Base/Block/Base.php
CHANGED
|
@@ -27,18 +27,6 @@ class Edrone_Base_Block_Base extends Mage_Core_Block_Template
|
|
| 27 |
{
|
| 28 |
return $this->configHelper;
|
| 29 |
}
|
| 30 |
-
/**
|
| 31 |
-
*
|
| 32 |
-
* Warning Warning Warning Warning Warning
|
| 33 |
-
*
|
| 34 |
-
* NEVER MAKE NEW METHOD CALLED getHelper
|
| 35 |
-
* BECOUSE IT WILL OVERRIDE METHOD FROM BASE CLASS
|
| 36 |
-
*
|
| 37 |
-
* Warning Warning Warning Warning Warning
|
| 38 |
-
*
|
| 39 |
-
*/
|
| 40 |
-
|
| 41 |
-
|
| 42 |
/**
|
| 43 |
* @return array
|
| 44 |
*/
|
|
@@ -62,12 +50,24 @@ class Edrone_Base_Block_Base extends Mage_Core_Block_Template
|
|
| 62 |
$this->customerData['first_name'] = $customer->getFirstname();
|
| 63 |
$this->customerData['last_name'] = $customer->getLastname();
|
| 64 |
$this->customerData['email'] = $customer->getEmail();
|
| 65 |
-
|
| 66 |
-
$
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
-
|
| 71 |
if ($address = $customer->getDefaultShippingAddress()) {
|
| 72 |
$this->customerData['country'] = $address->getCountry();
|
| 73 |
$this->customerData['city'] = $address->getCity();
|
| 27 |
{
|
| 28 |
return $this->configHelper;
|
| 29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
/**
|
| 31 |
* @return array
|
| 32 |
*/
|
| 50 |
$this->customerData['first_name'] = $customer->getFirstname();
|
| 51 |
$this->customerData['last_name'] = $customer->getLastname();
|
| 52 |
$this->customerData['email'] = $customer->getEmail();
|
| 53 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
| 54 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 55 |
+
$this->customerData['first_name'] = $customer->getFirstname();
|
| 56 |
+
$this->customerData['last_name'] = $customer->getLastname();
|
| 57 |
+
$this->customerData['email'] = $customer->getEmail();
|
| 58 |
+
$sub = (Mage::getSingleton('customer/session')->getData('edrone-substatus'));
|
| 59 |
+
$update_time = strtotime(Mage::getSingleton('customer/session')->getCustomer()->getData("updated_at"));
|
| 60 |
+
if( (!is_array($sub)) || (is_null($sub)) || ($sub['time'] !== $update_time )){
|
| 61 |
+
$sub = array();
|
| 62 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
|
| 63 |
+
if($subscriber){
|
| 64 |
+
$sub['status'] = $this->customerData['subscriber_status'] = ( $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ) ? 1 : 0;
|
| 65 |
+
$sub['time'] = $update_time;
|
| 66 |
+
Mage::getSingleton('customer/session')->setData('edrone-substatus',$sub);
|
| 67 |
+
}
|
| 68 |
+
}else{
|
| 69 |
+
$this->customerData['subscriber_status'] = $sub['status'];
|
| 70 |
}
|
|
|
|
| 71 |
if ($address = $customer->getDefaultShippingAddress()) {
|
| 72 |
$this->customerData['country'] = $address->getCountry();
|
| 73 |
$this->customerData['city'] = $address->getCity();
|
app/code/local/Edrone/Base/Block/Order.php
CHANGED
|
@@ -1,413 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
-
define('EDRONE_SDK_VERSION','PHPSDK_1.0.0');
|
| 4 |
-
|
| 5 |
-
abstract class EdroneEvent{
|
| 6 |
-
|
| 7 |
-
protected $field = array();
|
| 8 |
-
|
| 9 |
-
abstract public function init();
|
| 10 |
-
|
| 11 |
-
public function pre_init(){
|
| 12 |
-
//preInitObject
|
| 13 |
-
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
public function userCid($value){
|
| 17 |
-
$this->field['c_id'] = trim('phpsd_'.$value);
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
public function userEmail($value){
|
| 21 |
-
$this->field['email'] = trim($value);
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
public function userFirstName($value){
|
| 25 |
-
$this->field['first_name'] = trim($value);
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
public function userLastName($value){
|
| 29 |
-
$this->field['last_name'] = trim($value);
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
public function userSubscriberStatus($value){
|
| 33 |
-
$this->field['subscriber_status'] = trim($value);
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
public function userCountry($value){
|
| 37 |
-
$this->field['country'] = trim($value);
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
public function userCity($value){
|
| 41 |
-
$this->field['city'] = trim($value);
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
public function userPhone($value){
|
| 45 |
-
$this->field['phone'] = trim($value);
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
public function userTag($value){
|
| 49 |
-
$this->field['customer_tags'] = trim($value);
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
public function get(){
|
| 54 |
-
return $this->field;
|
| 55 |
-
return $this;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
class EdroneEventOrder extends EdroneEvent{
|
| 62 |
-
public function init(){
|
| 63 |
-
$this->field['action_type'] = 'order';
|
| 64 |
-
}
|
| 65 |
-
/**
|
| 66 |
-
*
|
| 67 |
-
* @param type $value
|
| 68 |
-
* @return \EdroneEventOrder
|
| 69 |
-
*/
|
| 70 |
-
public function userCid($value){
|
| 71 |
-
parent::userCid($value);
|
| 72 |
-
return $this;
|
| 73 |
-
}
|
| 74 |
-
/**
|
| 75 |
-
*
|
| 76 |
-
* @param type $value
|
| 77 |
-
* @return \EdroneEventOrder
|
| 78 |
-
*/
|
| 79 |
-
public function userEmail($value){
|
| 80 |
-
parent::userEmail($value);
|
| 81 |
-
return $this;
|
| 82 |
-
}
|
| 83 |
-
/**
|
| 84 |
-
*
|
| 85 |
-
* @param type $value
|
| 86 |
-
* @return \EdroneEventOrder
|
| 87 |
-
*/
|
| 88 |
-
public function userFirstName($value){
|
| 89 |
-
parent::userFirstName($value);
|
| 90 |
-
return $this;
|
| 91 |
-
}
|
| 92 |
-
/**
|
| 93 |
-
*
|
| 94 |
-
* @param type $value
|
| 95 |
-
* @return \EdroneEventOrder
|
| 96 |
-
*/
|
| 97 |
-
public function userLastName($value){
|
| 98 |
-
parent::userLastName($value);
|
| 99 |
-
return $this;
|
| 100 |
-
}
|
| 101 |
-
/**
|
| 102 |
-
*
|
| 103 |
-
* @param type $value
|
| 104 |
-
* @return \EdroneEventOrder
|
| 105 |
-
*/
|
| 106 |
-
public function userSubscriberStatus($value){
|
| 107 |
-
parent::userSubscriberStatus($value);
|
| 108 |
-
return $this;
|
| 109 |
-
}
|
| 110 |
-
/**
|
| 111 |
-
*
|
| 112 |
-
* @param type $value
|
| 113 |
-
* @return \EdroneEventOrder
|
| 114 |
-
*/
|
| 115 |
-
public function userCountry($value){
|
| 116 |
-
parent::userCountry($value);
|
| 117 |
-
return $this;
|
| 118 |
-
}
|
| 119 |
-
/**
|
| 120 |
-
*
|
| 121 |
-
* @param type $value
|
| 122 |
-
* @return \EdroneEventOrder
|
| 123 |
-
*/
|
| 124 |
-
public function userCity($value){
|
| 125 |
-
parent::userCity($value);
|
| 126 |
-
return $this;
|
| 127 |
-
}
|
| 128 |
-
/**
|
| 129 |
-
*
|
| 130 |
-
* @param type $value
|
| 131 |
-
* @return \EdroneEventOrder
|
| 132 |
-
*/
|
| 133 |
-
public function userOrder($value){
|
| 134 |
-
parent::userPhone($value);
|
| 135 |
-
return $this;
|
| 136 |
-
}
|
| 137 |
-
/**
|
| 138 |
-
*
|
| 139 |
-
* @param type $value
|
| 140 |
-
* @return \EdroneEventOther
|
| 141 |
-
*/
|
| 142 |
-
public function userTag($value){
|
| 143 |
-
parent::userTag($value);
|
| 144 |
-
return $this;
|
| 145 |
-
}
|
| 146 |
-
/**
|
| 147 |
-
*
|
| 148 |
-
* @param type $value
|
| 149 |
-
* @return \EdroneEventOrder Description
|
| 150 |
-
*/
|
| 151 |
-
public function productSkus($value){
|
| 152 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 153 |
-
$this->field['product_skus'] = $value;
|
| 154 |
-
return $this;
|
| 155 |
-
}
|
| 156 |
-
/**
|
| 157 |
-
*
|
| 158 |
-
* @param type $value
|
| 159 |
-
* @return \EdroneEventOrder
|
| 160 |
-
*/
|
| 161 |
-
public function productIds($value){
|
| 162 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 163 |
-
$this->field['product_ids'] = $value;
|
| 164 |
-
return $this;
|
| 165 |
-
}
|
| 166 |
-
/**
|
| 167 |
-
*
|
| 168 |
-
* @param type $value
|
| 169 |
-
* @return \EdroneEventOrder
|
| 170 |
-
*/
|
| 171 |
-
public function productTitles($value){
|
| 172 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 173 |
-
$this->field['product_titles'] = $value;
|
| 174 |
-
return $this;
|
| 175 |
-
}
|
| 176 |
-
/**
|
| 177 |
-
*
|
| 178 |
-
* @param type $value
|
| 179 |
-
* @return \EdroneEventOrder
|
| 180 |
-
*/
|
| 181 |
-
public function productImages($value){
|
| 182 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 183 |
-
$this->field['product_images'] = $value;
|
| 184 |
-
return $this;
|
| 185 |
-
}
|
| 186 |
-
/**
|
| 187 |
-
*
|
| 188 |
-
* @param type $value
|
| 189 |
-
* @return \EdroneEventOrder
|
| 190 |
-
*/
|
| 191 |
-
public function productUrls($value){
|
| 192 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 193 |
-
$this->field['product_urls'] = $value;
|
| 194 |
-
return $this;
|
| 195 |
-
}
|
| 196 |
-
/**
|
| 197 |
-
*
|
| 198 |
-
* @param type $value
|
| 199 |
-
* @return \EdroneEventOrder
|
| 200 |
-
*/
|
| 201 |
-
public function productCounts($value){
|
| 202 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 203 |
-
$this->field['product_counts'] = $value;
|
| 204 |
-
return $this;
|
| 205 |
-
}
|
| 206 |
-
/**
|
| 207 |
-
*
|
| 208 |
-
* @param type $value
|
| 209 |
-
* @return \EdroneEventOrder
|
| 210 |
-
*/
|
| 211 |
-
public function productCategoryIds($value){
|
| 212 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 213 |
-
$this->field['product_category_ids'] = $value;
|
| 214 |
-
return $this;
|
| 215 |
-
}
|
| 216 |
-
/**
|
| 217 |
-
*
|
| 218 |
-
* @param type $value
|
| 219 |
-
* @return \EdroneEventOrder
|
| 220 |
-
*/
|
| 221 |
-
public function productCategoryNames($value){
|
| 222 |
-
if(is_array($value)){ $value= implode('|', $value);}
|
| 223 |
-
$this->field['product_category_names'] = $value;
|
| 224 |
-
return $this;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
public function orderId($value){
|
| 229 |
-
$this->field['order_id'] = $value;
|
| 230 |
-
return $this;
|
| 231 |
-
}
|
| 232 |
-
|
| 233 |
-
public function orderPaymentValue($value){
|
| 234 |
-
$this->field['order_payment_value'] = $value;
|
| 235 |
-
return $this;
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
public function orderBasePaymentValue($value){
|
| 239 |
-
$this->field['base_payment_value'] = $value;
|
| 240 |
-
return $this;
|
| 241 |
-
}
|
| 242 |
-
|
| 243 |
-
public function orderDetails($value){
|
| 244 |
-
$this->field['order_details'] = $value;
|
| 245 |
-
return $this;
|
| 246 |
-
}
|
| 247 |
-
|
| 248 |
-
public function orderCurrency($value){
|
| 249 |
-
$this->field['order_currency'] = $value;
|
| 250 |
-
return $this;
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
public function orderBaseCurrency($value){
|
| 254 |
-
$this->field['base_currency'] = $value;
|
| 255 |
-
return $this;
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
/**
|
| 259 |
-
* @return EdroneEventOrder
|
| 260 |
-
*/
|
| 261 |
-
public static function create(){
|
| 262 |
-
return new EdroneEventOrder();
|
| 263 |
-
}
|
| 264 |
-
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
class EdroneIns{
|
| 270 |
-
|
| 271 |
-
/** @var string AppId */
|
| 272 |
-
private $appid = '';
|
| 273 |
-
/** @var string $secret Secret */
|
| 274 |
-
private $secret = '';
|
| 275 |
-
/** @var string Trace url. def https://api.edrone.me/trace */
|
| 276 |
-
private $trace_url = '';
|
| 277 |
-
/** @var array Array of request field */
|
| 278 |
-
private $fiels = array();
|
| 279 |
-
/** @var array Prepared request array */
|
| 280 |
-
private $preparedpack = array();
|
| 281 |
-
/** @var Closure Closure method called on error */
|
| 282 |
-
private $errorHandle = null;
|
| 283 |
-
/** @var Closure Closure method called on success */
|
| 284 |
-
private $readyHandle = null;
|
| 285 |
-
/** @var Array Last request information */
|
| 286 |
-
private $lastRequest = null;
|
| 287 |
-
|
| 288 |
-
/**
|
| 289 |
-
* Construct new Edrone Request instace
|
| 290 |
-
* @param string $appid AppId of tracker
|
| 291 |
-
* @param string $secret Secret of tracer
|
| 292 |
-
* @param string $trace_url def https://api.edrone.me/trace
|
| 293 |
-
* @since 1.0.0
|
| 294 |
-
*/
|
| 295 |
-
function __construct($appid,$secret,$trace_url='https://api.edrone.me/trace.php'){
|
| 296 |
-
$this->appid = $appid;
|
| 297 |
-
$this->secret = $secret;
|
| 298 |
-
$this->trace_url = $trace_url;
|
| 299 |
-
}
|
| 300 |
-
/**
|
| 301 |
-
*
|
| 302 |
-
* Prepare event to send
|
| 303 |
-
*
|
| 304 |
-
* @param EdroneEvent $event Use object of EdroneEventAddToCart,EdroneEventOrder,EdroneEventOrder,EdroneEventOther
|
| 305 |
-
* @return EdroneIns
|
| 306 |
-
* @since 1.0.0
|
| 307 |
-
*/
|
| 308 |
-
public function prepare($event){
|
| 309 |
-
if(!($event instanceof EdroneEvent )){
|
| 310 |
-
throw new Exception('Event must by child EdroneEvent class ');
|
| 311 |
-
$this->preparedpack = array();
|
| 312 |
-
return;
|
| 313 |
-
}
|
| 314 |
-
$event->pre_init();
|
| 315 |
-
$event->init();
|
| 316 |
-
$this->preparedpack = array_merge($event->get(),array(
|
| 317 |
-
"app_id" => $this->appid,
|
| 318 |
-
"version" => EDRONE_SDK_VERSION,
|
| 319 |
-
"sender_type" => 'server',
|
| 320 |
-
));
|
| 321 |
-
//Calc sign - beta
|
| 322 |
-
ksort($this->preparedpack);
|
| 323 |
-
$sign = '';
|
| 324 |
-
foreach($this->preparedpack as $key=>$value){$sign .= $value;}
|
| 325 |
-
$this->preparedpack['sign'] = md5($this->secret.$sign);
|
| 326 |
-
//
|
| 327 |
-
return $this;
|
| 328 |
-
}
|
| 329 |
-
|
| 330 |
-
/**
|
| 331 |
-
*
|
| 332 |
-
* Force send prepared data
|
| 333 |
-
* @since 1.0.0
|
| 334 |
-
*/
|
| 335 |
-
public function send(){
|
| 336 |
-
$ch = curl_init();
|
| 337 |
-
curl_setopt($ch, CURLOPT_URL, $this->trace_url);
|
| 338 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 339 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
| 340 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($this->preparedpack));
|
| 341 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,3);
|
| 342 |
-
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
| 343 |
-
$data = curl_exec($ch);
|
| 344 |
-
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 345 |
-
$report=curl_getinfo($ch);
|
| 346 |
-
curl_close($ch);
|
| 347 |
-
$this->lastRequest = array("code"=>$httpcode,"response"=>$data,"info"=>$report,'fields'=>$this->preparedpack);
|
| 348 |
-
if( ($httpcode !== 200) && ($this->errorHandle !== null) ){
|
| 349 |
-
call_user_func_array($this->errorHandle,array($this));
|
| 350 |
-
}elseif ( ($httpcode === 200) && ($this->readyHandle !== null) ){
|
| 351 |
-
call_user_func_array($this->readyHandle,array($this));
|
| 352 |
-
}
|
| 353 |
-
}
|
| 354 |
-
/**
|
| 355 |
-
* Return last request as array (debug)
|
| 356 |
-
* @return array
|
| 357 |
-
* @since 1.0.0
|
| 358 |
-
*/
|
| 359 |
-
public function getLastRequest(){
|
| 360 |
-
return $this->lastRequest;
|
| 361 |
-
}
|
| 362 |
-
|
| 363 |
-
/**
|
| 364 |
-
* Set Callbacks for error action and ready action
|
| 365 |
-
* @param \Closure $errorHandle
|
| 366 |
-
* @param \Closure $readyHandle
|
| 367 |
-
* @since 1.0.0
|
| 368 |
-
*/
|
| 369 |
-
public function setCallbacks($errorHandle=null,$readyHandle=null){
|
| 370 |
-
$this->errorHandle = $errorHandle;
|
| 371 |
-
$this->readyHandle = $readyHandle;
|
| 372 |
-
}
|
| 373 |
-
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
class Edrone_Base_Block_Order extends Edrone_Base_Block_Base
|
| 379 |
{
|
| 380 |
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
public function sendDataToServer($orderData,$customerData){
|
| 384 |
-
try{
|
| 385 |
-
$configHelper = Mage::helper('edrone/config');
|
| 386 |
-
$edrone = new EdroneIns($configHelper->getAppId(),'');
|
| 387 |
-
$edrone->setCallbacks(function($obj){
|
| 388 |
-
error_log("EDRONEPHPSDK ERROR - wrong request:". json_encode($obj->getLastRequest()));
|
| 389 |
-
},function(){
|
| 390 |
-
|
| 391 |
-
});
|
| 392 |
-
$edrone->prepare(
|
| 393 |
-
EdroneEventOrder::create()->
|
| 394 |
-
userFirstName(($customerData['first_name']))->
|
| 395 |
-
userLastName(($customerData['last_name']))->
|
| 396 |
-
userEmail($customerData['email'])->
|
| 397 |
-
productSkus($orderData['sku'])->
|
| 398 |
-
productTitles($orderData['title'])->
|
| 399 |
-
productImages($orderData['image'])->
|
| 400 |
-
productCategoryIds($orderData['product_category_ids'])->
|
| 401 |
-
productCategoryNames($orderData['product_category_names'])->
|
| 402 |
-
orderId($orderData['order_id'])->
|
| 403 |
-
orderPaymentValue($orderData['order_payment_value'])->
|
| 404 |
-
orderCurrency($orderData['order_currency'])->
|
| 405 |
-
productCounts($orderData['product_counts'])
|
| 406 |
-
)->send();
|
| 407 |
-
} catch (Exception $e){
|
| 408 |
-
error_log("EDRONEPHPSDK ERROR:".$e->getMessage().' more :'.json_encode($e));
|
| 409 |
-
}
|
| 410 |
-
}
|
| 411 |
/**
|
| 412 |
* @return array
|
| 413 |
*/
|
| 1 |
<?php
|
| 2 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Edrone_Base_Block_Order extends Edrone_Base_Block_Base
|
| 4 |
{
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
/**
|
| 7 |
* @return array
|
| 8 |
*/
|
app/code/local/Edrone/Base/Helper/Config.php
CHANGED
|
@@ -8,7 +8,7 @@ class Edrone_Base_Helper_Config extends Mage_Core_Helper_Abstract
|
|
| 8 |
const EXTERNAL_SCRIPT_URL_CONFIG_PATH = "edrone/base/external_script_url";
|
| 9 |
const COLLECTOR_URL_CONFIG_PATH = "edrone/base/collector_url";
|
| 10 |
const NEWSLETTER_SYNC_ENABLED_PATH = "edrone/newsletter/subscription_sync_enabled";
|
| 11 |
-
|
| 12 |
/**
|
| 13 |
* @return string
|
| 14 |
*/
|
|
@@ -16,7 +16,13 @@ class Edrone_Base_Helper_Config extends Mage_Core_Helper_Abstract
|
|
| 16 |
{
|
| 17 |
return (string)Mage::getStoreConfig(self::APP_ID_CONFIG_PATH);
|
| 18 |
}
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
/**
|
| 21 |
* @return string
|
| 22 |
*/
|
| 8 |
const EXTERNAL_SCRIPT_URL_CONFIG_PATH = "edrone/base/external_script_url";
|
| 9 |
const COLLECTOR_URL_CONFIG_PATH = "edrone/base/collector_url";
|
| 10 |
const NEWSLETTER_SYNC_ENABLED_PATH = "edrone/newsletter/subscription_sync_enabled";
|
| 11 |
+
const SSSYNC = "edrone/base/serverside_order";
|
| 12 |
/**
|
| 13 |
* @return string
|
| 14 |
*/
|
| 16 |
{
|
| 17 |
return (string)Mage::getStoreConfig(self::APP_ID_CONFIG_PATH);
|
| 18 |
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @return boolean
|
| 22 |
+
*/
|
| 23 |
+
public function isSSSync(){
|
| 24 |
+
return (boolean) Mage::getStoreConfig(self:: SSSYNC);
|
| 25 |
+
}
|
| 26 |
/**
|
| 27 |
* @return string
|
| 28 |
*/
|
app/code/local/Edrone/Base/Model/Observer.php
CHANGED
|
@@ -1,580 +1,5 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
//Check included serverside components
|
| 4 |
-
if (!defined('EDRONE_SDK_VERSION')) {
|
| 5 |
-
define('EDRONE_SDK_VERSION', 'PHPSDK_1.0.0');
|
| 6 |
-
|
| 7 |
-
abstract class EdroneEvent
|
| 8 |
-
{
|
| 9 |
-
|
| 10 |
-
protected $field = array();
|
| 11 |
-
|
| 12 |
-
abstract public function init();
|
| 13 |
-
|
| 14 |
-
public function pre_init()
|
| 15 |
-
{
|
| 16 |
-
//preInitObject
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
public function userCid($value)
|
| 20 |
-
{
|
| 21 |
-
$this->field['c_id'] = trim('phpsd_' . $value);
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
public function userEmail($value)
|
| 25 |
-
{
|
| 26 |
-
$this->field['email'] = trim($value);
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
public function userFirstName($value)
|
| 30 |
-
{
|
| 31 |
-
$this->field['first_name'] = trim($value);
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
public function userLastName($value)
|
| 35 |
-
{
|
| 36 |
-
$this->field['last_name'] = trim($value);
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
public function userSubscriberStatus($value)
|
| 40 |
-
{
|
| 41 |
-
$this->field['subscriber_status'] = trim($value);
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
public function userCountry($value)
|
| 45 |
-
{
|
| 46 |
-
$this->field['country'] = trim($value);
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
public function userCity($value)
|
| 50 |
-
{
|
| 51 |
-
$this->field['city'] = trim($value);
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
public function userPhone($value)
|
| 55 |
-
{
|
| 56 |
-
$this->field['phone'] = trim($value);
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
public function userTag($value)
|
| 60 |
-
{
|
| 61 |
-
$this->field['customer_tags'] = trim($value);
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
public function get()
|
| 65 |
-
{
|
| 66 |
-
return $this->field;
|
| 67 |
-
return $this;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
class EdroneEventSubscribe extends EdroneEvent
|
| 73 |
-
{
|
| 74 |
-
|
| 75 |
-
public function init()
|
| 76 |
-
{
|
| 77 |
-
$this->field['action_type'] = 'subscribe';
|
| 78 |
-
$this->field['customer_tags'] = 'From PopUp';
|
| 79 |
-
}
|
| 80 |
-
/**
|
| 81 |
-
*
|
| 82 |
-
* @param type $value
|
| 83 |
-
* @return \EdroneEventOrder
|
| 84 |
-
*/
|
| 85 |
-
public function userCid($value)
|
| 86 |
-
{
|
| 87 |
-
parent::userCid($value);
|
| 88 |
-
return $this;
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
/**
|
| 92 |
-
*
|
| 93 |
-
* @param type $value
|
| 94 |
-
* @return \EdroneEventOrder
|
| 95 |
-
*/
|
| 96 |
-
public function userEmail($value)
|
| 97 |
-
{
|
| 98 |
-
parent::userEmail($value);
|
| 99 |
-
return $this;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
*
|
| 104 |
-
* @param type $value
|
| 105 |
-
* @return \EdroneEventOrder
|
| 106 |
-
*/
|
| 107 |
-
public function userFirstName($value)
|
| 108 |
-
{
|
| 109 |
-
parent::userFirstName($value);
|
| 110 |
-
return $this;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
/**
|
| 114 |
-
*
|
| 115 |
-
* @param type $value
|
| 116 |
-
* @return \EdroneEventOrder
|
| 117 |
-
*/
|
| 118 |
-
public function userLastName($value)
|
| 119 |
-
{
|
| 120 |
-
parent::userLastName($value);
|
| 121 |
-
return $this;
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
/**
|
| 125 |
-
*
|
| 126 |
-
* @param type $value
|
| 127 |
-
* @return \EdroneEventOrder
|
| 128 |
-
*/
|
| 129 |
-
public function userSubscriberStatus($value)
|
| 130 |
-
{
|
| 131 |
-
parent::userSubscriberStatus($value);
|
| 132 |
-
return $this;
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
/**
|
| 136 |
-
*
|
| 137 |
-
* @param type $value
|
| 138 |
-
* @return \EdroneEventOrder
|
| 139 |
-
*/
|
| 140 |
-
public function userCountry($value)
|
| 141 |
-
{
|
| 142 |
-
parent::userCountry($value);
|
| 143 |
-
return $this;
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
/**
|
| 147 |
-
*
|
| 148 |
-
* @param type $value
|
| 149 |
-
* @return \EdroneEventOrder
|
| 150 |
-
*/
|
| 151 |
-
public function userCity($value)
|
| 152 |
-
{
|
| 153 |
-
parent::userCity($value);
|
| 154 |
-
return $this;
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
/**
|
| 158 |
-
*
|
| 159 |
-
* @param type $value
|
| 160 |
-
* @return \EdroneEventOrder
|
| 161 |
-
*/
|
| 162 |
-
public function userOrder($value)
|
| 163 |
-
{
|
| 164 |
-
parent::userPhone($value);
|
| 165 |
-
return $this;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
/**
|
| 169 |
-
*
|
| 170 |
-
* @param type $value
|
| 171 |
-
* @return \EdroneEventOther
|
| 172 |
-
*/
|
| 173 |
-
public function userTag($value)
|
| 174 |
-
{
|
| 175 |
-
parent::userTag($value);
|
| 176 |
-
return $this;
|
| 177 |
-
}
|
| 178 |
-
/**
|
| 179 |
-
* @return EdroneEventOther
|
| 180 |
-
*/
|
| 181 |
-
public static function create()
|
| 182 |
-
{
|
| 183 |
-
return new EdroneEventSubscribe();
|
| 184 |
-
}
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
class EdroneEventOrder extends EdroneEvent
|
| 188 |
-
{
|
| 189 |
-
|
| 190 |
-
public function init()
|
| 191 |
-
{
|
| 192 |
-
$this->field['action_type'] = 'order';
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
/**
|
| 196 |
-
*
|
| 197 |
-
* @param type $value
|
| 198 |
-
* @return \EdroneEventOrder
|
| 199 |
-
*/
|
| 200 |
-
public function userCid($value)
|
| 201 |
-
{
|
| 202 |
-
parent::userCid($value);
|
| 203 |
-
return $this;
|
| 204 |
-
}
|
| 205 |
-
|
| 206 |
-
/**
|
| 207 |
-
*
|
| 208 |
-
* @param type $value
|
| 209 |
-
* @return \EdroneEventOrder
|
| 210 |
-
*/
|
| 211 |
-
public function userEmail($value)
|
| 212 |
-
{
|
| 213 |
-
parent::userEmail($value);
|
| 214 |
-
return $this;
|
| 215 |
-
}
|
| 216 |
-
|
| 217 |
-
/**
|
| 218 |
-
*
|
| 219 |
-
* @param type $value
|
| 220 |
-
* @return \EdroneEventOrder
|
| 221 |
-
*/
|
| 222 |
-
public function userFirstName($value)
|
| 223 |
-
{
|
| 224 |
-
parent::userFirstName($value);
|
| 225 |
-
return $this;
|
| 226 |
-
}
|
| 227 |
-
|
| 228 |
-
/**
|
| 229 |
-
*
|
| 230 |
-
* @param type $value
|
| 231 |
-
* @return \EdroneEventOrder
|
| 232 |
-
*/
|
| 233 |
-
public function userLastName($value)
|
| 234 |
-
{
|
| 235 |
-
parent::userLastName($value);
|
| 236 |
-
return $this;
|
| 237 |
-
}
|
| 238 |
-
|
| 239 |
-
/**
|
| 240 |
-
*
|
| 241 |
-
* @param type $value
|
| 242 |
-
* @return \EdroneEventOrder
|
| 243 |
-
*/
|
| 244 |
-
public function userSubscriberStatus($value)
|
| 245 |
-
{
|
| 246 |
-
parent::userSubscriberStatus($value);
|
| 247 |
-
return $this;
|
| 248 |
-
}
|
| 249 |
-
|
| 250 |
-
/**
|
| 251 |
-
*
|
| 252 |
-
* @param type $value
|
| 253 |
-
* @return \EdroneEventOrder
|
| 254 |
-
*/
|
| 255 |
-
public function userCountry($value)
|
| 256 |
-
{
|
| 257 |
-
parent::userCountry($value);
|
| 258 |
-
return $this;
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
-
/**
|
| 262 |
-
*
|
| 263 |
-
* @param type $value
|
| 264 |
-
* @return \EdroneEventOrder
|
| 265 |
-
*/
|
| 266 |
-
public function userCity($value)
|
| 267 |
-
{
|
| 268 |
-
parent::userCity($value);
|
| 269 |
-
return $this;
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
/**
|
| 273 |
-
*
|
| 274 |
-
* @param type $value
|
| 275 |
-
* @return \EdroneEventOrder
|
| 276 |
-
*/
|
| 277 |
-
public function userOrder($value)
|
| 278 |
-
{
|
| 279 |
-
parent::userPhone($value);
|
| 280 |
-
return $this;
|
| 281 |
-
}
|
| 282 |
-
|
| 283 |
-
/**
|
| 284 |
-
*
|
| 285 |
-
* @param type $value
|
| 286 |
-
* @return \EdroneEventOther
|
| 287 |
-
*/
|
| 288 |
-
public function userTag($value)
|
| 289 |
-
{
|
| 290 |
-
parent::userTag($value);
|
| 291 |
-
return $this;
|
| 292 |
-
}
|
| 293 |
-
|
| 294 |
-
/**
|
| 295 |
-
*
|
| 296 |
-
* @param type $value
|
| 297 |
-
* @return \EdroneEventOrder Description
|
| 298 |
-
*/
|
| 299 |
-
public function productSkus($value)
|
| 300 |
-
{
|
| 301 |
-
if (is_array($value)) {
|
| 302 |
-
$value = implode('|', $value);
|
| 303 |
-
}
|
| 304 |
-
$this->field['product_skus'] = $value;
|
| 305 |
-
return $this;
|
| 306 |
-
}
|
| 307 |
-
|
| 308 |
-
/**
|
| 309 |
-
*
|
| 310 |
-
* @param type $value
|
| 311 |
-
* @return \EdroneEventOrder
|
| 312 |
-
*/
|
| 313 |
-
public function productIds($value)
|
| 314 |
-
{
|
| 315 |
-
if (is_array($value)) {
|
| 316 |
-
$value = implode('|', $value);
|
| 317 |
-
}
|
| 318 |
-
$this->field['product_ids'] = $value;
|
| 319 |
-
return $this;
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
/**
|
| 323 |
-
*
|
| 324 |
-
* @param type $value
|
| 325 |
-
* @return \EdroneEventOrder
|
| 326 |
-
*/
|
| 327 |
-
public function productTitles($value)
|
| 328 |
-
{
|
| 329 |
-
if (is_array($value)) {
|
| 330 |
-
$value = implode('|', $value);
|
| 331 |
-
}
|
| 332 |
-
$this->field['product_titles'] = $value;
|
| 333 |
-
return $this;
|
| 334 |
-
}
|
| 335 |
-
|
| 336 |
-
/**
|
| 337 |
-
*
|
| 338 |
-
* @param type $value
|
| 339 |
-
* @return \EdroneEventOrder
|
| 340 |
-
*/
|
| 341 |
-
public function productImages($value)
|
| 342 |
-
{
|
| 343 |
-
if (is_array($value)) {
|
| 344 |
-
$value = implode('|', $value);
|
| 345 |
-
}
|
| 346 |
-
$this->field['product_images'] = $value;
|
| 347 |
-
return $this;
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
/**
|
| 351 |
-
*
|
| 352 |
-
* @param type $value
|
| 353 |
-
* @return \EdroneEventOrder
|
| 354 |
-
*/
|
| 355 |
-
public function productUrls($value)
|
| 356 |
-
{
|
| 357 |
-
if (is_array($value)) {
|
| 358 |
-
$value = implode('|', $value);
|
| 359 |
-
}
|
| 360 |
-
$this->field['product_urls'] = $value;
|
| 361 |
-
return $this;
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
/**
|
| 365 |
-
*
|
| 366 |
-
* @param type $value
|
| 367 |
-
* @return \EdroneEventOrder
|
| 368 |
-
*/
|
| 369 |
-
public function productCounts($value)
|
| 370 |
-
{
|
| 371 |
-
if (is_array($value)) {
|
| 372 |
-
$value = implode('|', $value);
|
| 373 |
-
}
|
| 374 |
-
$this->field['product_counts'] = $value;
|
| 375 |
-
return $this;
|
| 376 |
-
}
|
| 377 |
-
|
| 378 |
-
/**
|
| 379 |
-
*
|
| 380 |
-
* @param type $value
|
| 381 |
-
* @return \EdroneEventOrder
|
| 382 |
-
*/
|
| 383 |
-
public function productCategoryIds($value)
|
| 384 |
-
{
|
| 385 |
-
if (is_array($value)) {
|
| 386 |
-
$value = implode('|', $value);
|
| 387 |
-
}
|
| 388 |
-
$this->field['product_category_ids'] = $value;
|
| 389 |
-
return $this;
|
| 390 |
-
}
|
| 391 |
-
|
| 392 |
-
/**
|
| 393 |
-
*
|
| 394 |
-
* @param type $value
|
| 395 |
-
* @return \EdroneEventOrder
|
| 396 |
-
*/
|
| 397 |
-
public function productCategoryNames($value)
|
| 398 |
-
{
|
| 399 |
-
if (is_array($value)) {
|
| 400 |
-
$value = implode('|', $value);
|
| 401 |
-
}
|
| 402 |
-
$this->field['product_category_names'] = $value;
|
| 403 |
-
return $this;
|
| 404 |
-
}
|
| 405 |
-
|
| 406 |
-
public function orderId($value)
|
| 407 |
-
{
|
| 408 |
-
$this->field['order_id'] = $value;
|
| 409 |
-
return $this;
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
public function orderPaymentValue($value)
|
| 413 |
-
{
|
| 414 |
-
$this->field['order_payment_value'] = $value;
|
| 415 |
-
return $this;
|
| 416 |
-
}
|
| 417 |
-
|
| 418 |
-
public function orderBasePaymentValue($value)
|
| 419 |
-
{
|
| 420 |
-
$this->field['base_payment_value'] = $value;
|
| 421 |
-
return $this;
|
| 422 |
-
}
|
| 423 |
-
|
| 424 |
-
public function orderDetails($value)
|
| 425 |
-
{
|
| 426 |
-
$this->field['order_details'] = $value;
|
| 427 |
-
return $this;
|
| 428 |
-
}
|
| 429 |
-
|
| 430 |
-
public function orderCurrency($value)
|
| 431 |
-
{
|
| 432 |
-
$this->field['order_currency'] = $value;
|
| 433 |
-
return $this;
|
| 434 |
-
}
|
| 435 |
-
|
| 436 |
-
public function orderBaseCurrency($value)
|
| 437 |
-
{
|
| 438 |
-
$this->field['base_currency'] = $value;
|
| 439 |
-
return $this;
|
| 440 |
-
}
|
| 441 |
-
|
| 442 |
-
/**
|
| 443 |
-
* @return EdroneEventOrder
|
| 444 |
-
*/
|
| 445 |
-
public static function create()
|
| 446 |
-
{
|
| 447 |
-
return new EdroneEventOrder();
|
| 448 |
-
}
|
| 449 |
-
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
class EdroneIns
|
| 453 |
-
{
|
| 454 |
-
|
| 455 |
-
/** @var string AppId */
|
| 456 |
-
private $appid = '';
|
| 457 |
-
|
| 458 |
-
/** @var string $secret Secret */
|
| 459 |
-
private $secret = '';
|
| 460 |
-
|
| 461 |
-
/** @var string Trace url. def https://api.edrone.me/trace */
|
| 462 |
-
private $trace_url = '';
|
| 463 |
-
|
| 464 |
-
/** @var array Array of request field */
|
| 465 |
-
private $fiels = array();
|
| 466 |
-
|
| 467 |
-
/** @var array Prepared request array */
|
| 468 |
-
private $preparedpack = array();
|
| 469 |
-
|
| 470 |
-
/** @var Closure Closure method called on error */
|
| 471 |
-
private $errorHandle = null;
|
| 472 |
-
|
| 473 |
-
/** @var Closure Closure method called on success */
|
| 474 |
-
private $readyHandle = null;
|
| 475 |
-
|
| 476 |
-
/** @var Array Last request information */
|
| 477 |
-
private $lastRequest = null;
|
| 478 |
-
|
| 479 |
-
/**
|
| 480 |
-
* Construct new Edrone Request instace
|
| 481 |
-
* @param string $appid AppId of tracker
|
| 482 |
-
* @param string $secret Secret of tracer
|
| 483 |
-
* @param string $trace_url def https://api.edrone.me/trace
|
| 484 |
-
* @since 1.0.0
|
| 485 |
-
*/
|
| 486 |
-
function __construct($appid, $secret, $trace_url = 'https://api.edrone.me/trace.php')
|
| 487 |
-
{
|
| 488 |
-
$this->appid = $appid;
|
| 489 |
-
$this->secret = $secret;
|
| 490 |
-
$this->trace_url = $trace_url;
|
| 491 |
-
}
|
| 492 |
-
|
| 493 |
-
/**
|
| 494 |
-
*
|
| 495 |
-
* Prepare event to send
|
| 496 |
-
*
|
| 497 |
-
* @param EdroneEvent $event Use object of EdroneEventAddToCart,EdroneEventOrder,EdroneEventOrder,EdroneEventOther
|
| 498 |
-
* @return EdroneIns
|
| 499 |
-
* @since 1.0.0
|
| 500 |
-
*/
|
| 501 |
-
public function prepare($event)
|
| 502 |
-
{
|
| 503 |
-
if (!($event instanceof EdroneEvent )) {
|
| 504 |
-
throw new Exception('Event must by child EdroneEvent class ');
|
| 505 |
-
$this->preparedpack = array();
|
| 506 |
-
return;
|
| 507 |
-
}
|
| 508 |
-
$event->pre_init();
|
| 509 |
-
$event->init();
|
| 510 |
-
$this->preparedpack = array_merge($event->get(), array(
|
| 511 |
-
"app_id" => $this->appid,
|
| 512 |
-
"version" => EDRONE_SDK_VERSION,
|
| 513 |
-
"sender_type" => 'server',
|
| 514 |
-
));
|
| 515 |
-
//Calc sign - beta
|
| 516 |
-
/*ksort($this->preparedpack);
|
| 517 |
-
$sign = '';
|
| 518 |
-
foreach ($this->preparedpack as $key => $value) {
|
| 519 |
-
$sign .= $value;
|
| 520 |
-
}
|
| 521 |
-
$this->preparedpack['sign'] = md5($this->secret . $sign);*/
|
| 522 |
-
//
|
| 523 |
-
return $this;
|
| 524 |
-
}
|
| 525 |
-
|
| 526 |
-
/**
|
| 527 |
-
*
|
| 528 |
-
* Force send prepared data
|
| 529 |
-
* @since 1.0.0
|
| 530 |
-
*/
|
| 531 |
-
public function send()
|
| 532 |
-
{
|
| 533 |
-
$ch = curl_init();
|
| 534 |
-
curl_setopt($ch, CURLOPT_URL, $this->trace_url);
|
| 535 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 536 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
| 537 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->preparedpack));
|
| 538 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
| 539 |
-
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
| 540 |
-
$data = curl_exec($ch);
|
| 541 |
-
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 542 |
-
$report = curl_getinfo($ch);
|
| 543 |
-
curl_close($ch);
|
| 544 |
-
$this->lastRequest = array("code" => $httpcode, "response" => $data, "info" => $report, 'fields' => $this->preparedpack);
|
| 545 |
-
if (($httpcode !== 200) && ($this->errorHandle !== null)) {
|
| 546 |
-
call_user_func_array($this->errorHandle, array($this));
|
| 547 |
-
} elseif (($httpcode === 200) && ($this->readyHandle !== null)) {
|
| 548 |
-
call_user_func_array($this->readyHandle, array($this));
|
| 549 |
-
}
|
| 550 |
-
}
|
| 551 |
-
|
| 552 |
-
/**
|
| 553 |
-
* Return last request as array (debug)
|
| 554 |
-
* @return array
|
| 555 |
-
* @since 1.0.0
|
| 556 |
-
*/
|
| 557 |
-
public function getLastRequest()
|
| 558 |
-
{
|
| 559 |
-
return $this->lastRequest;
|
| 560 |
-
}
|
| 561 |
-
|
| 562 |
-
/**
|
| 563 |
-
* Set Callbacks for error action and ready action
|
| 564 |
-
* @param \Closure $errorHandle
|
| 565 |
-
* @param \Closure $readyHandle
|
| 566 |
-
* @since 1.0.0
|
| 567 |
-
*/
|
| 568 |
-
public function setCallbacks($errorHandle = null, $readyHandle = null)
|
| 569 |
-
{
|
| 570 |
-
$this->errorHandle = $errorHandle;
|
| 571 |
-
$this->readyHandle = $readyHandle;
|
| 572 |
-
}
|
| 573 |
-
|
| 574 |
-
}
|
| 575 |
-
|
| 576 |
-
}
|
| 577 |
-
|
| 578 |
class Edrone_Base_Model_Observer
|
| 579 |
{
|
| 580 |
|
|
@@ -589,10 +14,10 @@ class Edrone_Base_Model_Observer
|
|
| 589 |
|
| 590 |
Mage::getModel('core/session')->setProductToShoppingCart(
|
| 591 |
new Varien_Object(array(
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
))
|
| 597 |
);
|
| 598 |
}
|
|
@@ -606,11 +31,14 @@ class Edrone_Base_Model_Observer
|
|
| 606 |
$product_category_ids = array();
|
| 607 |
$product_counts = array();
|
| 608 |
|
| 609 |
-
|
|
|
|
|
|
|
|
|
|
| 610 |
foreach ($order->getAllVisibleItems() as $item) {
|
| 611 |
-
$parentIds =
|
| 612 |
if(count($parentIds) > 0){
|
| 613 |
-
$product =
|
| 614 |
$skus[] = $product->getSku();
|
| 615 |
$ids[] = $product->getId();
|
| 616 |
$titles[] = $product->getName();
|
|
@@ -618,14 +46,14 @@ class Edrone_Base_Model_Observer
|
|
| 618 |
$product_counts[] = (int)$item->getQtyOrdered();
|
| 619 |
$categoryId = array_pop($categoryIds);
|
| 620 |
if(is_numeric($categoryId)){
|
| 621 |
-
$category =
|
| 622 |
$product_category_names[] = $category->getName();
|
| 623 |
$product_category_ids[] = $categoryId;
|
| 624 |
|
| 625 |
}
|
| 626 |
$images[] = ($product) ? (string)Mage::helper('catalog/image')->init($product, 'image')->resize(438) : '';
|
| 627 |
}else{
|
| 628 |
-
$product =
|
| 629 |
$skus[] = $product->getSku();
|
| 630 |
$ids[] = $product->getId();
|
| 631 |
$titles[] = $product->getName();
|
|
@@ -633,7 +61,7 @@ class Edrone_Base_Model_Observer
|
|
| 633 |
$product_counts[] = (int)$item->getQtyOrdered();
|
| 634 |
$categoryId = array_pop($categoryIds);
|
| 635 |
if(is_numeric($categoryId)){
|
| 636 |
-
$category =
|
| 637 |
$product_category_names[] = $category->getName();
|
| 638 |
$product_category_ids[] = $categoryId;
|
| 639 |
|
|
@@ -670,14 +98,15 @@ class Edrone_Base_Model_Observer
|
|
| 670 |
{
|
| 671 |
try {
|
| 672 |
$configHelper = Mage::helper('edrone/config');
|
| 673 |
-
|
|
|
|
| 674 |
$edrone->setCallbacks(function($obj) {
|
| 675 |
-
|
| 676 |
}, function() {
|
| 677 |
|
| 678 |
});
|
| 679 |
$edrone->prepare(
|
| 680 |
-
|
| 681 |
userFirstName(($customerData['first_name']))->
|
| 682 |
userLastName(($customerData['last_name']))->
|
| 683 |
userEmail($customerData['email'])->
|
|
@@ -692,7 +121,7 @@ class Edrone_Base_Model_Observer
|
|
| 692 |
productCounts($orderData['product_counts'])
|
| 693 |
)->send();
|
| 694 |
} catch (Exception $e) {
|
| 695 |
-
|
| 696 |
}
|
| 697 |
return json_encode($edrone->getLastRequest());
|
| 698 |
}
|
|
@@ -707,6 +136,7 @@ class Edrone_Base_Model_Observer
|
|
| 707 |
|
| 708 |
public function newsletterSubscriberChange($observer)
|
| 709 |
{
|
|
|
|
| 710 |
$subscriber = $observer->getEvent()->getSubscriber();
|
| 711 |
$sub = 0;
|
| 712 |
if ($subscriber->isSubscribed()) {
|
|
@@ -714,21 +144,23 @@ class Edrone_Base_Model_Observer
|
|
| 714 |
$email = $subscriber->getEmail();
|
| 715 |
try {
|
| 716 |
$configHelper = Mage::helper('edrone/config');
|
| 717 |
-
|
|
|
|
| 718 |
$edrone->setCallbacks(function($obj) {
|
| 719 |
-
|
| 720 |
-
}, function() {
|
| 721 |
-
|
| 722 |
});
|
| 723 |
$edrone->prepare(
|
| 724 |
-
|
| 725 |
userEmail($email)->
|
| 726 |
userSubscriberStatus($sub)
|
| 727 |
)->send();
|
| 728 |
} catch (Exception $e) {
|
| 729 |
-
|
| 730 |
}
|
| 731 |
}
|
|
|
|
|
|
|
| 732 |
}
|
| 733 |
|
| 734 |
}
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Edrone_Base_Model_Observer
|
| 4 |
{
|
| 5 |
|
| 14 |
|
| 15 |
Mage::getModel('core/session')->setProductToShoppingCart(
|
| 16 |
new Varien_Object(array(
|
| 17 |
+
'sku' => $product->getSku(),
|
| 18 |
+
'title' => $product->getName(),
|
| 19 |
+
'image' => (string) Mage::helper('catalog/image')->init($product, 'image')->resize(438),
|
| 20 |
+
'id' => $product->getId(),
|
| 21 |
))
|
| 22 |
);
|
| 23 |
}
|
| 31 |
$product_category_ids = array();
|
| 32 |
$product_counts = array();
|
| 33 |
|
| 34 |
+
$m_product_type_configurable = Mage::getModel('catalog/product_type_configurable');
|
| 35 |
+
$m_product = Mage::getModel("catalog/product");
|
| 36 |
+
$m_category = Mage::getModel('catalog/category');
|
| 37 |
+
|
| 38 |
foreach ($order->getAllVisibleItems() as $item) {
|
| 39 |
+
$parentIds = $m_product_type_configurable->getParentIdsByChild($item->getProductId());
|
| 40 |
if(count($parentIds) > 0){
|
| 41 |
+
$product = $m_product->load( $parentIds[0] );
|
| 42 |
$skus[] = $product->getSku();
|
| 43 |
$ids[] = $product->getId();
|
| 44 |
$titles[] = $product->getName();
|
| 46 |
$product_counts[] = (int)$item->getQtyOrdered();
|
| 47 |
$categoryId = array_pop($categoryIds);
|
| 48 |
if(is_numeric($categoryId)){
|
| 49 |
+
$category = $m_category->load($categoryId);
|
| 50 |
$product_category_names[] = $category->getName();
|
| 51 |
$product_category_ids[] = $categoryId;
|
| 52 |
|
| 53 |
}
|
| 54 |
$images[] = ($product) ? (string)Mage::helper('catalog/image')->init($product, 'image')->resize(438) : '';
|
| 55 |
}else{
|
| 56 |
+
$product = $m_product->load( $item->getProductId() );
|
| 57 |
$skus[] = $product->getSku();
|
| 58 |
$ids[] = $product->getId();
|
| 59 |
$titles[] = $product->getName();
|
| 61 |
$product_counts[] = (int)$item->getQtyOrdered();
|
| 62 |
$categoryId = array_pop($categoryIds);
|
| 63 |
if(is_numeric($categoryId)){
|
| 64 |
+
$category = $m_category->load($categoryId);
|
| 65 |
$product_category_names[] = $category->getName();
|
| 66 |
$product_category_ids[] = $categoryId;
|
| 67 |
|
| 98 |
{
|
| 99 |
try {
|
| 100 |
$configHelper = Mage::helper('edrone/config');
|
| 101 |
+
if(!$configHelper->isSSSync()){ return; };
|
| 102 |
+
$edrone = new Edrone_Base_Model_Utilities_EdroneIns($configHelper->getAppId(), '');
|
| 103 |
$edrone->setCallbacks(function($obj) {
|
| 104 |
+
Mage::log("EDRONEPHPSDK ERROR - wrong request:" . json_encode($obj->getLastRequest()));
|
| 105 |
}, function() {
|
| 106 |
|
| 107 |
});
|
| 108 |
$edrone->prepare(
|
| 109 |
+
Edrone_Base_Model_Utilities_EdroneEventOrder::create()->
|
| 110 |
userFirstName(($customerData['first_name']))->
|
| 111 |
userLastName(($customerData['last_name']))->
|
| 112 |
userEmail($customerData['email'])->
|
| 121 |
productCounts($orderData['product_counts'])
|
| 122 |
)->send();
|
| 123 |
} catch (Exception $e) {
|
| 124 |
+
Mage::log("EDRONEPHPSDK ERROR:" . $e->getMessage() . ' more :' . json_encode($e));
|
| 125 |
}
|
| 126 |
return json_encode($edrone->getLastRequest());
|
| 127 |
}
|
| 136 |
|
| 137 |
public function newsletterSubscriberChange($observer)
|
| 138 |
{
|
| 139 |
+
|
| 140 |
$subscriber = $observer->getEvent()->getSubscriber();
|
| 141 |
$sub = 0;
|
| 142 |
if ($subscriber->isSubscribed()) {
|
| 144 |
$email = $subscriber->getEmail();
|
| 145 |
try {
|
| 146 |
$configHelper = Mage::helper('edrone/config');
|
| 147 |
+
if(!$configHelper->isSSSync()){ return; };
|
| 148 |
+
$edrone = new Edrone_Base_Model_Utilities_EdroneIns($configHelper->getAppId(), '');
|
| 149 |
$edrone->setCallbacks(function($obj) {
|
| 150 |
+
Mage::log("EDRONEPHPSDK ERROR - wrong request:" . json_encode($obj->getLastRequest()));
|
| 151 |
+
}, function($obj) {
|
|
|
|
| 152 |
});
|
| 153 |
$edrone->prepare(
|
| 154 |
+
Edrone_Base_Model_Utilities_EdroneEventSubscribe::create()->
|
| 155 |
userEmail($email)->
|
| 156 |
userSubscriberStatus($sub)
|
| 157 |
)->send();
|
| 158 |
} catch (Exception $e) {
|
| 159 |
+
Mage::log("EDRONEPHPSDK ERROR:" . $e->getMessage() . ' more :' . json_encode($e));
|
| 160 |
}
|
| 161 |
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
}
|
| 165 |
|
| 166 |
}
|
app/code/local/Edrone/Base/Model/Utilities/EdroneEvent.php
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
abstract class Edrone_Base_Model_Utilities_EdroneEvent
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected $field = array();
|
| 7 |
+
|
| 8 |
+
abstract public function init();
|
| 9 |
+
|
| 10 |
+
public function pre_init()
|
| 11 |
+
{
|
| 12 |
+
//preInitObject
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public function userCid($value)
|
| 16 |
+
{
|
| 17 |
+
$this->field['c_id'] = trim('phpsd_' . $value);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function userEmail($value)
|
| 21 |
+
{
|
| 22 |
+
$this->field['email'] = trim($value);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function userFirstName($value)
|
| 26 |
+
{
|
| 27 |
+
$this->field['first_name'] = trim($value);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function userLastName($value)
|
| 31 |
+
{
|
| 32 |
+
$this->field['last_name'] = trim($value);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
public function userSubscriberStatus($value)
|
| 36 |
+
{
|
| 37 |
+
$this->field['subscriber_status'] = trim($value);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public function userCountry($value)
|
| 41 |
+
{
|
| 42 |
+
$this->field['country'] = trim($value);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public function userCity($value)
|
| 46 |
+
{
|
| 47 |
+
$this->field['city'] = trim($value);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function userPhone($value)
|
| 51 |
+
{
|
| 52 |
+
$this->field['phone'] = trim($value);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
public function userTag($value)
|
| 56 |
+
{
|
| 57 |
+
$this->field['customer_tags'] = trim($value);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
public function get()
|
| 61 |
+
{
|
| 62 |
+
return $this->field;
|
| 63 |
+
return $this;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
}
|
app/code/local/Edrone/Base/Model/Utilities/EdroneEventOrder.php
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Edrone_Base_Model_Utilities_EdroneEventOrder extends Edrone_Base_Model_Utilities_EdroneEvent
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function init()
|
| 7 |
+
{
|
| 8 |
+
$this->field['action_type'] = 'order';
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
*
|
| 13 |
+
* @param type $value
|
| 14 |
+
* @return \EdroneEventOrder
|
| 15 |
+
*/
|
| 16 |
+
public function userCid($value)
|
| 17 |
+
{
|
| 18 |
+
parent::userCid($value);
|
| 19 |
+
return $this;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
*
|
| 24 |
+
* @param type $value
|
| 25 |
+
* @return \EdroneEventOrder
|
| 26 |
+
*/
|
| 27 |
+
public function userEmail($value)
|
| 28 |
+
{
|
| 29 |
+
parent::userEmail($value);
|
| 30 |
+
return $this;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
*
|
| 35 |
+
* @param type $value
|
| 36 |
+
* @return \EdroneEventOrder
|
| 37 |
+
*/
|
| 38 |
+
public function userFirstName($value)
|
| 39 |
+
{
|
| 40 |
+
parent::userFirstName($value);
|
| 41 |
+
return $this;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
*
|
| 46 |
+
* @param type $value
|
| 47 |
+
* @return \EdroneEventOrder
|
| 48 |
+
*/
|
| 49 |
+
public function userLastName($value)
|
| 50 |
+
{
|
| 51 |
+
parent::userLastName($value);
|
| 52 |
+
return $this;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
*
|
| 57 |
+
* @param type $value
|
| 58 |
+
* @return \EdroneEventOrder
|
| 59 |
+
*/
|
| 60 |
+
public function userSubscriberStatus($value)
|
| 61 |
+
{
|
| 62 |
+
parent::userSubscriberStatus($value);
|
| 63 |
+
return $this;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
*
|
| 68 |
+
* @param type $value
|
| 69 |
+
* @return \EdroneEventOrder
|
| 70 |
+
*/
|
| 71 |
+
public function userCountry($value)
|
| 72 |
+
{
|
| 73 |
+
parent::userCountry($value);
|
| 74 |
+
return $this;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
*
|
| 79 |
+
* @param type $value
|
| 80 |
+
* @return \EdroneEventOrder
|
| 81 |
+
*/
|
| 82 |
+
public function userCity($value)
|
| 83 |
+
{
|
| 84 |
+
parent::userCity($value);
|
| 85 |
+
return $this;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
*
|
| 90 |
+
* @param type $value
|
| 91 |
+
* @return \EdroneEventOrder
|
| 92 |
+
*/
|
| 93 |
+
public function userOrder($value)
|
| 94 |
+
{
|
| 95 |
+
parent::userPhone($value);
|
| 96 |
+
return $this;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
*
|
| 101 |
+
* @param type $value
|
| 102 |
+
* @return \EdroneEventOther
|
| 103 |
+
*/
|
| 104 |
+
public function userTag($value)
|
| 105 |
+
{
|
| 106 |
+
parent::userTag($value);
|
| 107 |
+
return $this;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
*
|
| 112 |
+
* @param type $value
|
| 113 |
+
* @return \EdroneEventOrder Description
|
| 114 |
+
*/
|
| 115 |
+
public function productSkus($value)
|
| 116 |
+
{
|
| 117 |
+
if (is_array($value)) {
|
| 118 |
+
$value = implode('|', $value);
|
| 119 |
+
}
|
| 120 |
+
$this->field['product_skus'] = $value;
|
| 121 |
+
return $this;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
*
|
| 126 |
+
* @param type $value
|
| 127 |
+
* @return \EdroneEventOrder
|
| 128 |
+
*/
|
| 129 |
+
public function productIds($value)
|
| 130 |
+
{
|
| 131 |
+
if (is_array($value)) {
|
| 132 |
+
$value = implode('|', $value);
|
| 133 |
+
}
|
| 134 |
+
$this->field['product_ids'] = $value;
|
| 135 |
+
return $this;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
*
|
| 140 |
+
* @param type $value
|
| 141 |
+
* @return \EdroneEventOrder
|
| 142 |
+
*/
|
| 143 |
+
public function productTitles($value)
|
| 144 |
+
{
|
| 145 |
+
if (is_array($value)) {
|
| 146 |
+
$value = implode('|', $value);
|
| 147 |
+
}
|
| 148 |
+
$this->field['product_titles'] = $value;
|
| 149 |
+
return $this;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
*
|
| 154 |
+
* @param type $value
|
| 155 |
+
* @return \EdroneEventOrder
|
| 156 |
+
*/
|
| 157 |
+
public function productImages($value)
|
| 158 |
+
{
|
| 159 |
+
if (is_array($value)) {
|
| 160 |
+
$value = implode('|', $value);
|
| 161 |
+
}
|
| 162 |
+
$this->field['product_images'] = $value;
|
| 163 |
+
return $this;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
*
|
| 168 |
+
* @param type $value
|
| 169 |
+
* @return \EdroneEventOrder
|
| 170 |
+
*/
|
| 171 |
+
public function productUrls($value)
|
| 172 |
+
{
|
| 173 |
+
if (is_array($value)) {
|
| 174 |
+
$value = implode('|', $value);
|
| 175 |
+
}
|
| 176 |
+
$this->field['product_urls'] = $value;
|
| 177 |
+
return $this;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
*
|
| 182 |
+
* @param type $value
|
| 183 |
+
* @return \EdroneEventOrder
|
| 184 |
+
*/
|
| 185 |
+
public function productCounts($value)
|
| 186 |
+
{
|
| 187 |
+
if (is_array($value)) {
|
| 188 |
+
$value = implode('|', $value);
|
| 189 |
+
}
|
| 190 |
+
$this->field['product_counts'] = $value;
|
| 191 |
+
return $this;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
*
|
| 196 |
+
* @param type $value
|
| 197 |
+
* @return \EdroneEventOrder
|
| 198 |
+
*/
|
| 199 |
+
public function productCategoryIds($value)
|
| 200 |
+
{
|
| 201 |
+
if (is_array($value)) {
|
| 202 |
+
$value = implode('|', $value);
|
| 203 |
+
}
|
| 204 |
+
$this->field['product_category_ids'] = $value;
|
| 205 |
+
return $this;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
*
|
| 210 |
+
* @param type $value
|
| 211 |
+
* @return \EdroneEventOrder
|
| 212 |
+
*/
|
| 213 |
+
public function productCategoryNames($value)
|
| 214 |
+
{
|
| 215 |
+
if (is_array($value)) {
|
| 216 |
+
$value = implode('|', $value);
|
| 217 |
+
}
|
| 218 |
+
$this->field['product_category_names'] = $value;
|
| 219 |
+
return $this;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
public function orderId($value)
|
| 223 |
+
{
|
| 224 |
+
$this->field['order_id'] = $value;
|
| 225 |
+
return $this;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
public function orderPaymentValue($value)
|
| 229 |
+
{
|
| 230 |
+
$this->field['order_payment_value'] = $value;
|
| 231 |
+
return $this;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
public function orderBasePaymentValue($value)
|
| 235 |
+
{
|
| 236 |
+
$this->field['base_payment_value'] = $value;
|
| 237 |
+
return $this;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
public function orderDetails($value)
|
| 241 |
+
{
|
| 242 |
+
$this->field['order_details'] = $value;
|
| 243 |
+
return $this;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
public function orderCurrency($value)
|
| 247 |
+
{
|
| 248 |
+
$this->field['order_currency'] = $value;
|
| 249 |
+
return $this;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
public function orderBaseCurrency($value)
|
| 253 |
+
{
|
| 254 |
+
$this->field['base_currency'] = $value;
|
| 255 |
+
return $this;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/**
|
| 259 |
+
* @return EdroneEventOrder
|
| 260 |
+
*/
|
| 261 |
+
public static function create()
|
| 262 |
+
{
|
| 263 |
+
return new Edrone_Base_Model_Utilities_EdroneEventOrder();
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
}
|
app/code/local/Edrone/Base/Model/Utilities/EdroneEventSubscribe.php
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Edrone_Base_Model_Utilities_EdroneEventSubscribe extends Edrone_Base_Model_Utilities_EdroneEvent
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function init()
|
| 7 |
+
{
|
| 8 |
+
$this->field['action_type'] = 'subscribe';
|
| 9 |
+
$this->field['customer_tags'] = 'From PopUp';
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
*
|
| 14 |
+
* @param type $value
|
| 15 |
+
* @return \EdroneEventOrder
|
| 16 |
+
*/
|
| 17 |
+
public function userCid($value)
|
| 18 |
+
{
|
| 19 |
+
parent::userCid($value);
|
| 20 |
+
return $this;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
*
|
| 25 |
+
* @param type $value
|
| 26 |
+
* @return \EdroneEventOrder
|
| 27 |
+
*/
|
| 28 |
+
public function userEmail($value)
|
| 29 |
+
{
|
| 30 |
+
parent::userEmail($value);
|
| 31 |
+
return $this;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
*
|
| 36 |
+
* @param type $value
|
| 37 |
+
* @return \EdroneEventOrder
|
| 38 |
+
*/
|
| 39 |
+
public function userFirstName($value)
|
| 40 |
+
{
|
| 41 |
+
parent::userFirstName($value);
|
| 42 |
+
return $this;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
*
|
| 47 |
+
* @param type $value
|
| 48 |
+
* @return \EdroneEventOrder
|
| 49 |
+
*/
|
| 50 |
+
public function userLastName($value)
|
| 51 |
+
{
|
| 52 |
+
parent::userLastName($value);
|
| 53 |
+
return $this;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
*
|
| 58 |
+
* @param type $value
|
| 59 |
+
* @return \EdroneEventOrder
|
| 60 |
+
*/
|
| 61 |
+
public function userSubscriberStatus($value)
|
| 62 |
+
{
|
| 63 |
+
parent::userSubscriberStatus($value);
|
| 64 |
+
return $this;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
*
|
| 69 |
+
* @param type $value
|
| 70 |
+
* @return \EdroneEventOrder
|
| 71 |
+
*/
|
| 72 |
+
public function userCountry($value)
|
| 73 |
+
{
|
| 74 |
+
parent::userCountry($value);
|
| 75 |
+
return $this;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
*
|
| 80 |
+
* @param type $value
|
| 81 |
+
* @return \EdroneEventOrder
|
| 82 |
+
*/
|
| 83 |
+
public function userCity($value)
|
| 84 |
+
{
|
| 85 |
+
parent::userCity($value);
|
| 86 |
+
return $this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
*
|
| 91 |
+
* @param type $value
|
| 92 |
+
* @return \EdroneEventOrder
|
| 93 |
+
*/
|
| 94 |
+
public function userOrder($value)
|
| 95 |
+
{
|
| 96 |
+
parent::userPhone($value);
|
| 97 |
+
return $this;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
*
|
| 102 |
+
* @param type $value
|
| 103 |
+
* @return \EdroneEventOther
|
| 104 |
+
*/
|
| 105 |
+
public function userTag($value)
|
| 106 |
+
{
|
| 107 |
+
parent::userTag($value);
|
| 108 |
+
return $this;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* @return EdroneEventOther
|
| 113 |
+
*/
|
| 114 |
+
public static function create()
|
| 115 |
+
{
|
| 116 |
+
return new Edrone_Base_Model_Utilities_EdroneEventSubscribe();
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
}
|
app/code/local/Edrone/Base/Model/Utilities/EdroneIns.php
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
if (!defined('EDRONE_SDK_VERSION')) {
|
| 3 |
+
define('EDRONE_SDK_VERSION', 'PHPSDK_1.0.0');
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
class Edrone_Base_Model_Utilities_EdroneIns
|
| 7 |
+
{
|
| 8 |
+
|
| 9 |
+
/** @var string AppId */
|
| 10 |
+
private $appid = '';
|
| 11 |
+
|
| 12 |
+
/** @var string $secret Secret */
|
| 13 |
+
private $secret = '';
|
| 14 |
+
|
| 15 |
+
/** @var string Trace url. def https://api.edrone.me/trace */
|
| 16 |
+
private $trace_url = '';
|
| 17 |
+
|
| 18 |
+
/** @var array Array of request field */
|
| 19 |
+
private $fiels = array();
|
| 20 |
+
|
| 21 |
+
/** @var array Prepared request array */
|
| 22 |
+
private $preparedpack = array();
|
| 23 |
+
|
| 24 |
+
/** @var Closure Closure method called on error */
|
| 25 |
+
private $errorHandle = null;
|
| 26 |
+
|
| 27 |
+
/** @var Closure Closure method called on success */
|
| 28 |
+
private $readyHandle = null;
|
| 29 |
+
|
| 30 |
+
/** @var Array Last request information */
|
| 31 |
+
private $lastRequest = null;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Construct new Edrone Request instace
|
| 35 |
+
* @param string $appid AppId of tracker
|
| 36 |
+
* @param string $secret Secret of tracer
|
| 37 |
+
* @param string $trace_url def https://api.edrone.me/trace
|
| 38 |
+
* @since 1.0.0
|
| 39 |
+
*/
|
| 40 |
+
function __construct($appid, $secret, $trace_url = 'https://api-test.edrone.me/trace.php')
|
| 41 |
+
{
|
| 42 |
+
$this->appid = $appid;
|
| 43 |
+
$this->secret = $secret;
|
| 44 |
+
$this->trace_url = $trace_url;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
*
|
| 49 |
+
* Prepare event to send
|
| 50 |
+
*
|
| 51 |
+
* @param EdroneEvent $event Use object of EdroneEventAddToCart,EdroneEventOrder,EdroneEventOrder,EdroneEventOther
|
| 52 |
+
* @return EdroneIns
|
| 53 |
+
* @since 1.0.0
|
| 54 |
+
*/
|
| 55 |
+
public function prepare($event)
|
| 56 |
+
{
|
| 57 |
+
if (!($event instanceof Edrone_Base_Model_Utilities_EdroneEvent )) {
|
| 58 |
+
throw new Exception('Event must by child EdroneEvent class ');
|
| 59 |
+
$this->preparedpack = array();
|
| 60 |
+
return;
|
| 61 |
+
}
|
| 62 |
+
$event->pre_init();
|
| 63 |
+
$event->init();
|
| 64 |
+
$this->preparedpack = array_merge($event->get(), array(
|
| 65 |
+
"app_id" => $this->appid,
|
| 66 |
+
"version" => EDRONE_SDK_VERSION,
|
| 67 |
+
"sender_type" => 'server',
|
| 68 |
+
));
|
| 69 |
+
return $this;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
*
|
| 74 |
+
* Force send prepared data
|
| 75 |
+
* @since 1.0.0
|
| 76 |
+
*/
|
| 77 |
+
public function send()
|
| 78 |
+
{
|
| 79 |
+
if(!in_array ('curl', get_loaded_extensions())) { return; }
|
| 80 |
+
$ch = curl_init();
|
| 81 |
+
curl_setopt($ch, CURLOPT_URL, $this->trace_url);
|
| 82 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 83 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
| 84 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->preparedpack));
|
| 85 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
|
| 86 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
|
| 87 |
+
$data = curl_exec($ch);
|
| 88 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 89 |
+
$report = curl_getinfo($ch);
|
| 90 |
+
curl_close($ch);
|
| 91 |
+
$this->lastRequest = array("code" => $httpcode, "response" => $data, "info" => $report, 'fields' => $this->preparedpack);
|
| 92 |
+
if (($httpcode !== 200) && ($this->errorHandle !== null)) {
|
| 93 |
+
call_user_func_array($this->errorHandle, array($this));
|
| 94 |
+
} elseif (($httpcode === 200) && ($this->readyHandle !== null)) {
|
| 95 |
+
call_user_func_array($this->readyHandle, array($this));
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Return last request as array (debug)
|
| 101 |
+
* @return array
|
| 102 |
+
* @since 1.0.0
|
| 103 |
+
*/
|
| 104 |
+
public function getLastRequest()
|
| 105 |
+
{
|
| 106 |
+
return $this->lastRequest;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* Set Callbacks for error action and ready action
|
| 111 |
+
* @param \Closure $errorHandle
|
| 112 |
+
* @param \Closure $readyHandle
|
| 113 |
+
* @since 1.0.0
|
| 114 |
+
*/
|
| 115 |
+
public function setCallbacks($errorHandle = null, $readyHandle = null)
|
| 116 |
+
{
|
| 117 |
+
$this->errorHandle = $errorHandle;
|
| 118 |
+
$this->readyHandle = $readyHandle;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
}
|
app/code/local/Edrone/Base/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Edrone_Base>
|
| 5 |
-
<version>1.1.
|
| 6 |
</Edrone_Base>
|
| 7 |
</modules>
|
| 8 |
<global>
|
|
@@ -14,8 +14,13 @@
|
|
| 14 |
<helpers>
|
| 15 |
<edrone>
|
| 16 |
<class>Edrone_Base_Helper</class>
|
| 17 |
-
</edrone>
|
| 18 |
</helpers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</global>
|
| 20 |
<frontend>
|
| 21 |
<layout>
|
|
@@ -99,6 +104,7 @@
|
|
| 99 |
<app_secret>INSERT_APP_SECRET_HERE</app_secret>
|
| 100 |
<external_script_url>//d3bo67muzbfgtl.cloudfront.net/edrone_2_0.js</external_script_url>
|
| 101 |
<collector_url>https://api.edrone.me/trace</collector_url>
|
|
|
|
| 102 |
</base>
|
| 103 |
</edrone>
|
| 104 |
</default>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Edrone_Base>
|
| 5 |
+
<version>1.1.19</version>
|
| 6 |
</Edrone_Base>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 14 |
<helpers>
|
| 15 |
<edrone>
|
| 16 |
<class>Edrone_Base_Helper</class>
|
| 17 |
+
</edrone>
|
| 18 |
</helpers>
|
| 19 |
+
<models>
|
| 20 |
+
<edrone>
|
| 21 |
+
<class>Edrone_Base_Model</class>
|
| 22 |
+
</edrone>
|
| 23 |
+
</models>
|
| 24 |
</global>
|
| 25 |
<frontend>
|
| 26 |
<layout>
|
| 104 |
<app_secret>INSERT_APP_SECRET_HERE</app_secret>
|
| 105 |
<external_script_url>//d3bo67muzbfgtl.cloudfront.net/edrone_2_0.js</external_script_url>
|
| 106 |
<collector_url>https://api.edrone.me/trace</collector_url>
|
| 107 |
+
<serverside_order>1</serverside_order>
|
| 108 |
</base>
|
| 109 |
</edrone>
|
| 110 |
</default>
|
app/code/local/Edrone/Base/etc/system.xml
CHANGED
|
@@ -56,9 +56,10 @@
|
|
| 56 |
<show_in_store>1</show_in_store>
|
| 57 |
</collector_url>
|
| 58 |
<serverside_order>
|
| 59 |
-
<label>Send
|
| 60 |
-
<frontend_type>
|
| 61 |
-
<
|
|
|
|
| 62 |
<show_in_default>1</show_in_default>
|
| 63 |
<show_in_website>1</show_in_website>
|
| 64 |
<show_in_store>1</show_in_store>
|
| 56 |
<show_in_store>1</show_in_store>
|
| 57 |
</collector_url>
|
| 58 |
<serverside_order>
|
| 59 |
+
<label>Send data via curl (serverside method)</label>
|
| 60 |
+
<frontend_type>select</frontend_type>
|
| 61 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 62 |
+
<sort_order>40</sort_order>
|
| 63 |
<show_in_default>1</show_in_default>
|
| 64 |
<show_in_website>1</show_in_website>
|
| 65 |
<show_in_store>1</show_in_store>
|
app/design/frontend/base/default/template/edrone/cart_view.phtml
CHANGED
|
@@ -11,7 +11,7 @@ $productData = $this->getProductData();
|
|
| 11 |
(function (srcjs) {
|
| 12 |
window._edrone = window._edrone || {};
|
| 13 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 14 |
-
_edrone.version = '1.1.
|
| 15 |
_edrone.platform = 'Magento';
|
| 16 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 17 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
|
@@ -50,7 +50,7 @@ $productData = $this->getProductData();
|
|
| 50 |
(function (srcjs) {
|
| 51 |
window._edrone = window._edrone || {};
|
| 52 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 53 |
-
_edrone.version = '1.1.
|
| 54 |
_edrone.platform = 'Magento';
|
| 55 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 56 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
| 11 |
(function (srcjs) {
|
| 12 |
window._edrone = window._edrone || {};
|
| 13 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 14 |
+
_edrone.version = '1.1.19';
|
| 15 |
_edrone.platform = 'Magento';
|
| 16 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 17 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
| 50 |
(function (srcjs) {
|
| 51 |
window._edrone = window._edrone || {};
|
| 52 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 53 |
+
_edrone.version = '1.1.19';
|
| 54 |
_edrone.platform = 'Magento';
|
| 55 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 56 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
app/design/frontend/base/default/template/edrone/default.phtml
CHANGED
|
@@ -9,7 +9,7 @@ $customerData = $this->getCustomerData();
|
|
| 9 |
(function (srcjs) {
|
| 10 |
window._edrone = window._edrone || {};
|
| 11 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 12 |
-
_edrone.version = '1.1.
|
| 13 |
_edrone.platform = 'Magento';
|
| 14 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 15 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
| 9 |
(function (srcjs) {
|
| 10 |
window._edrone = window._edrone || {};
|
| 11 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 12 |
+
_edrone.version = '1.1.19';
|
| 13 |
_edrone.platform = 'Magento';
|
| 14 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 15 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
app/design/frontend/base/default/template/edrone/product_view.phtml
CHANGED
|
@@ -10,7 +10,7 @@ $productData = $this->getProductData();
|
|
| 10 |
(function (srcjs) {
|
| 11 |
window._edrone = window._edrone || {};
|
| 12 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 13 |
-
_edrone.version = '1.1.
|
| 14 |
_edrone.platform = 'Magento';
|
| 15 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 16 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
| 10 |
(function (srcjs) {
|
| 11 |
window._edrone = window._edrone || {};
|
| 12 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 13 |
+
_edrone.version = '1.1.19';
|
| 14 |
_edrone.platform = 'Magento';
|
| 15 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 16 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
app/design/frontend/base/default/template/edrone/success_view.phtml
CHANGED
|
@@ -4,7 +4,6 @@ $helper = $this->getConfigHelper();
|
|
| 4 |
$helper2 = Mage::helper('edrone');
|
| 5 |
$customerData = $this->getCustomerData();
|
| 6 |
$orderData = $this->getOrderData();
|
| 7 |
-
$this->sendDataToServer($orderData, $customerData);
|
| 8 |
?>
|
| 9 |
|
| 10 |
<?php if(!empty($orderData)): ?>
|
|
@@ -12,7 +11,7 @@ $this->sendDataToServer($orderData, $customerData);
|
|
| 12 |
(function (srcjs) {
|
| 13 |
window._edrone = window._edrone || {};
|
| 14 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 15 |
-
_edrone.version = '1.1.
|
| 16 |
_edrone.platform = 'Magento';
|
| 17 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 18 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
| 4 |
$helper2 = Mage::helper('edrone');
|
| 5 |
$customerData = $this->getCustomerData();
|
| 6 |
$orderData = $this->getOrderData();
|
|
|
|
| 7 |
?>
|
| 8 |
|
| 9 |
<?php if(!empty($orderData)): ?>
|
| 11 |
(function (srcjs) {
|
| 12 |
window._edrone = window._edrone || {};
|
| 13 |
_edrone.app_id = '<?php echo $helper->getAppId() ?>';
|
| 14 |
+
_edrone.version = '1.1.19';
|
| 15 |
_edrone.platform = 'Magento';
|
| 16 |
_edrone.platform_version = '<?php echo Mage::getVersion(); ?>';
|
| 17 |
_edrone.trace_url = '<?php echo $helper->getCollectorUrl() ?>';
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>edroneCRM</name>
|
| 4 |
-
<version>1.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>edrone - first CRM for e-commerce Maintain clients & increase customer retention with dynamic e-CRM.</summary>
|
| 10 |
<description>edrone is collecting and analyzing Magento visitors and customers data. The plugin allows processing personal data in the real-time in order to communicate with them through dynamic and personalized e-mail.</description>
|
| 11 |
-
<notes>
|
| 12 |
<authors><author><name>Michał Blak</name><user>MAG002993376</user><email>admin@edrone.me</email></author></authors>
|
| 13 |
-
<date>2017-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="Edrone"><dir name="Base"><dir name="Block"><file name="Base.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>edroneCRM</name>
|
| 4 |
+
<version>1.1.19</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>edrone - first CRM for e-commerce Maintain clients & increase customer retention with dynamic e-CRM.</summary>
|
| 10 |
<description>edrone is collecting and analyzing Magento visitors and customers data. The plugin allows processing personal data in the real-time in order to communicate with them through dynamic and personalized e-mail.</description>
|
| 11 |
+
<notes>drone magento module - release 1.1.19</notes>
|
| 12 |
<authors><author><name>Michał Blak</name><user>MAG002993376</user><email>admin@edrone.me</email></author></authors>
|
| 13 |
+
<date>2017-02-21</date>
|
| 14 |
+
<time>11:00:48</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Edrone"><dir name="Base"><dir name="Block"><file name="Base.php" hash="b8bb2e9911274dbbabaddeeb2cca3995"/><file name="Cart.php" hash="f7231eb0745811a3b800fe459023f55b"/><file name="Order.php" hash="a36d6c8814e1c70da745017b464f231d"/><file name="Product.php" hash="605c872360cc0eea5441ec756d8d3018"/></dir><dir name="Helper"><file name="Config.php" hash="7fd2037f7bc61a5f3ede07a74cce6c23"/><file name="Data.php" hash="a9040014b1b54a1d3cc7ebf401f489c0"/></dir><dir name="Model"><file name="Observer.php" hash="d0adc50f52614ec7e881250844bbb743"/><dir name="Utilities"><file name="EdroneEvent.php" hash="eb773f00798edfff0427eabd7dfd3f20"/><file name="EdroneEventOrder.php" hash="72bdf73789386364fb1ba6b43bc2b437"/><file name="EdroneEventSubscribe.php" hash="f594f42e535936bafbbf50d98c0bab3b"/><file name="EdroneIns.php" hash="1a7dd27766342190c6a013b77771731d"/></dir></dir><dir name="controllers"><file name="EdroneproductController.php" hash="1039efa581923b65565c1ee656cd9385"/><file name="NewsletterController.php" hash="fa9e82363c785ce94e005a7aad141162"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0e715e76c00295dc4e555411455fedfb"/><file name="config.xml" hash="67627ba75e44a4b7cef25c5b51e47c41"/><file name="system.xml" hash="5d55e543ce1f7360be406127fe20b083"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="edrone"><file name="cart_view.phtml" hash="d299c6d220553cdb323350d64e50f061"/><file name="default.phtml" hash="035d73fe0080a5d37d457d1d4c75d35b"/><file name="product_view.phtml" hash="5896c14453252bea4575108089d12af4"/><file name="success_view.phtml" hash="6f1d1793da74eb6daca1a65fbc8f5212"/></dir></dir><dir name="layout"><file name="edrone.xml" hash="48e37d1c01507337f8dc33eb9e03af34"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Edrone_Base.xml" hash="29d3699c3a83fa4fea848a6cb7800872"/></dir></dir></target><target name="magelocale"><dir name="pl_PL"><file name="Edrone.csv" hash="b8aa59d39815f4d92738129cc9fbdf34"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
