Version Notes
t-appz Adapter for Magento
Download this release
Release Info
| Developer | tmobtech |
| Extension | Tmob_Tappz |
| Version | 1.0.12 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.11 to 1.0.12
- app/code/community/TmobLabs/Tappz/Model/Basket/Api.php +36 -180
- app/code/community/TmobLabs/Tappz/Model/Catalog/Api.php +10 -91
- app/code/community/TmobLabs/Tappz/Model/Customer/Address/Api.php +0 -1
- app/code/community/TmobLabs/Tappz/Model/Customer/Api.php +1 -7
- app/code/community/TmobLabs/Tappz/Model/Customer/Order/Api.php +2 -18
- app/code/community/TmobLabs/Tappz/etc/system.xml +1 -139
- package.xml +4 -4
app/code/community/TmobLabs/Tappz/Model/Basket/Api.php
CHANGED
|
@@ -39,17 +39,13 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 39 |
$basket['estimatedSupplyDate'] = null;
|
| 40 |
$basket['isGiftWrappingEnabled'] = false;
|
| 41 |
$basket['giftWrapping'] = null;
|
| 42 |
-
|
| 43 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 44 |
$quote = Mage::getModel("sales/quote")
|
| 45 |
->setStoreId($store);
|
| 46 |
-
|
| 47 |
if (isset($customerId)) {
|
| 48 |
$quote = $quote->loadByCustomer($customerId);
|
| 49 |
} elseif (isset($quoteId)) {
|
| 50 |
$quote = $quote->load($quoteId);
|
| 51 |
}
|
| 52 |
-
|
| 53 |
if (is_null($quote->getId())) {
|
| 54 |
try {
|
| 55 |
if (isset($customerId) && $customerId !== '') {
|
|
@@ -61,12 +57,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 61 |
$this->_fault('invalid_data', $e->getMessage());
|
| 62 |
}
|
| 63 |
}
|
| 64 |
-
|
| 65 |
$catalogApi = Mage::getSingleton('tappz/Catalog_Api');
|
| 66 |
$addressApi = Mage::getSingleton('tappz/Customer_Address_Api');
|
| 67 |
-
|
| 68 |
$basket['id'] = $quote->getId();
|
| 69 |
-
|
| 70 |
foreach ($quote->getAllVisibleItems() as $item) {
|
| 71 |
$line = array();
|
| 72 |
$line['productId'] = $item->getData('product_id');
|
|
@@ -75,16 +68,13 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 75 |
$line['price'] = number_format($item->getData('price'), 2, $decimalDivider, $thousandDivider);
|
| 76 |
$line['priceTotal'] = number_format($item->getData('row_total'), 2, $decimalDivider, $thousandDivider);
|
| 77 |
$line['averageDeliveryDays'] = $item->getData($lineAverageDeliveryDaysAttributeCode);
|
| 78 |
-
$line['variants'] = array()
|
| 79 |
$basket['lines'][] = $line;
|
| 80 |
}
|
| 81 |
-
|
| 82 |
$basket['currency'] = Mage::app()->getStore($quote->getStoreId())->getCurrentCurrencyCode();
|
| 83 |
-
|
| 84 |
$quoteBillingAddress = $quote->getBillingAddress();
|
| 85 |
if ($quoteBillingAddress)
|
| 86 |
$basket['delivery']['billingAddress'] = $addressApi->get($quoteBillingAddress->getData('customer_address_id'));
|
| 87 |
-
|
| 88 |
$quoteShippingAddress = $quote->getShippingAddress();
|
| 89 |
if ($quoteShippingAddress) {
|
| 90 |
$basket['delivery']['shippingAddress'] = $addressApi->get($quoteShippingAddress->getData('customer_address_id'));
|
|
@@ -96,23 +86,19 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 96 |
$basket['delivery']['shippingMethod']['priceForYou'] = null;
|
| 97 |
$basket['delivery']['shippingMethod']['shippingMethodType'] = $quoteShippingAddress->getData('shipping_method');
|
| 98 |
$basket['delivery']['shippingMethod']['imageUrl'] = null;
|
| 99 |
-
|
| 100 |
$basket['discountTotal'] = number_format($quoteShippingAddress->getData('discount_amount'), 2, $decimalDivider, $thousandDivider);
|
| 101 |
$basket['shippingTotal'] = number_format($quoteShippingAddress->getData('shipping_incl_tax'), 2, $decimalDivider, $thousandDivider);
|
| 102 |
} else {
|
| 103 |
-
|
| 104 |
}
|
| 105 |
-
|
| 106 |
$basket['itemsPriceTotal'] = number_format($quote->getData('base_subtotal'), 2, $decimalDivider, $thousandDivider);
|
| 107 |
if (!isset($basket['discountTotal']))
|
| 108 |
$basket['discountTotal'] = floatval($quote->getData('subtotal')) - floatval($quote->getData('subtotal_with_discount'));
|
| 109 |
$basket['subTotal'] = number_format($quote->getData('subtotal'), 2, $decimalDivider, $thousandDivider);
|
| 110 |
$basket['total'] = number_format($quote->getData('grand_total'), 2, $decimalDivider, $thousandDivider);
|
| 111 |
-
|
| 112 |
$basket['discounts'][0]['displayName'] = null;
|
| 113 |
$basket['discounts'][0]['discountTotal'] = $basket['discountTotal'];
|
| 114 |
$basket['discounts'][0]['promoCode'] = $quote->getData('coupon_code');
|
| 115 |
-
|
| 116 |
$payment = $quote->getPayment();
|
| 117 |
if (isset($payment)) {
|
| 118 |
$paymentData = array();
|
|
@@ -170,7 +156,7 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 170 |
$paymentData['accountNumber'] = null;
|
| 171 |
$paymentData['branch'] = null;
|
| 172 |
$paymentData['iban'] = null;
|
| 173 |
-
} else if ($method == 'stripe') {
|
| 174 |
$paymentData['methodType'] = 'ApplePay';
|
| 175 |
$paymentData['type'] = $method;
|
| 176 |
$paymentData['displayName'] = 'Apple Pay';
|
|
@@ -182,13 +168,11 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 182 |
}
|
| 183 |
$basket['payment'] = $paymentData;
|
| 184 |
}
|
| 185 |
-
|
| 186 |
$paymentOptions = array();
|
| 187 |
$paymentOptions['paypal'] = null;
|
| 188 |
$paymentOptions['creditCards'] = array();
|
| 189 |
$paymentOptions['moneyTransfers'] = array();
|
| 190 |
$paymentOptions['cashOnDelivery'] = null;
|
| 191 |
-
|
| 192 |
$methods = Mage::helper('payment')->getStoreMethods($store, $quote);
|
| 193 |
foreach ($methods as $method) {
|
| 194 |
$code = $method->getCode();
|
|
@@ -224,11 +208,10 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 224 |
$paymentOptions['cashOnDelivery']['isSMSVerification'] = false;
|
| 225 |
$paymentOptions['cashOnDelivery']['SMSCode'] = null;
|
| 226 |
$paymentOptions['cashOnDelivery']['PhoneNumber'] = null;
|
| 227 |
-
|
| 228 |
$paymentOptions['cashOnDelivery']['type'] = $code;
|
| 229 |
$paymentOptions['cashOnDelivery']['displayName'] = $method->getTitle();
|
| 230 |
-
$paymentOptions['cashOnDelivery']['additionalFee'] = '0';
|
| 231 |
-
$paymentOptions['cashOnDelivery']['description'] = 'Cash on delivery description text';
|
| 232 |
$paymentOptions['cashOnDelivery']['isSMSVerification'] = false;
|
| 233 |
$paymentOptions['cashOnDelivery']['SMSCode'] = null;
|
| 234 |
$paymentOptions['cashOnDelivery']['PhoneNumber'] = null;
|
|
@@ -247,10 +230,8 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 247 |
|
| 248 |
$shippingMethods = array();
|
| 249 |
if (isset($quoteShippingAddress)) {
|
| 250 |
-
try {
|
| 251 |
$quoteShippingAddress->collectShippingRates()->save();
|
| 252 |
$groupedRates = $quoteShippingAddress->getGroupedAllShippingRates();
|
| 253 |
-
|
| 254 |
foreach ($groupedRates as $carrierCode => $rates) {
|
| 255 |
foreach ($rates as $rate) {
|
| 256 |
$rateItem = array();
|
|
@@ -261,13 +242,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 261 |
$rateItem['priceForYou'] = null;
|
| 262 |
$rateItem['shippingMethodType'] = $rate->getData('code');
|
| 263 |
$rateItem['imageUrl'] = null;
|
| 264 |
-
|
| 265 |
$shippingMethods[] = $rateItem;
|
| 266 |
}
|
| 267 |
}
|
| 268 |
-
} catch (Mage_Core_Exception $e) {
|
| 269 |
-
|
| 270 |
-
}
|
| 271 |
}
|
| 272 |
$basket['shippingMethods'] = $shippingMethods;
|
| 273 |
|
|
@@ -276,7 +253,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 276 |
// TODO
|
| 277 |
}
|
| 278 |
$basket['giftCheques'] = $giftCheques;
|
| 279 |
-
|
| 280 |
$basket['spentGiftChequeTotal'] = number_format($quote->getData('gift_cards_amount'), 2, $decimalDivider, $thousandDivider);
|
| 281 |
$basket['usedPoints'] = null; //TODO
|
| 282 |
$basket['usedPointsAmount'] = null; //TODO
|
|
@@ -302,18 +278,13 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 302 |
public function merge($anonymousQuoteId, $customerId)
|
| 303 |
{
|
| 304 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 305 |
-
|
| 306 |
-
/* @var $anonymousQuote Mage_Sales_Model_Quote */
|
| 307 |
$anonymousQuote = Mage::getModel("sales/quote")
|
| 308 |
->setStoreId($store)
|
| 309 |
->load($anonymousQuoteId);
|
| 310 |
-
|
| 311 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 312 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 313 |
$quote = Mage::getModel("sales/quote")
|
| 314 |
->setStoreId($store)
|
| 315 |
->loadByCustomer($customer);
|
| 316 |
-
|
| 317 |
if (is_null($quote->getId())) {
|
| 318 |
try {
|
| 319 |
$quote = $quote->setStoreId($store)
|
|
@@ -325,31 +296,24 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 325 |
$this->_fault('invalid_data', $e->getMessage());
|
| 326 |
}
|
| 327 |
}
|
| 328 |
-
|
| 329 |
try {
|
| 330 |
$quote = $quote->merge($anonymousQuote);
|
| 331 |
$quote = $quote->collectTotals()->save();
|
| 332 |
} catch (Mage_Core_Exception $e) {
|
| 333 |
$this->_fault('invalid_data', $e->getMessage());
|
| 334 |
}
|
| 335 |
-
|
| 336 |
return $this->get($quote->getId());
|
| 337 |
}
|
| 338 |
|
| 339 |
public function updateItems($quoteId, $updateList)
|
| 340 |
{
|
| 341 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 342 |
-
|
| 343 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 344 |
$quote = Mage::getModel("sales/quote")
|
| 345 |
->setStoreId($store)
|
| 346 |
->load($quoteId);
|
| 347 |
-
|
| 348 |
foreach ($updateList as $item) {
|
| 349 |
$productId = $item->productId;
|
| 350 |
$qty = $item->qty;
|
| 351 |
-
|
| 352 |
-
/* @var $product Mage_Catalog_Model_Product */
|
| 353 |
$product = Mage::getModel('catalog/product')->load($productId);
|
| 354 |
$quoteItem = $quote->getItemByProduct($product);
|
| 355 |
$request = new Varien_Object(array('qty' => $qty));
|
|
@@ -361,20 +325,15 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 361 |
$quote->updateItem($quoteItem->getId(), $request);
|
| 362 |
}
|
| 363 |
}
|
| 364 |
-
|
| 365 |
$quote->setTotalsCollectedFlag(false)->collectTotals()->save();
|
| 366 |
return $this->get($quote->getId());
|
| 367 |
}
|
| 368 |
-
|
| 369 |
public function setAddress($quoteId, $shippingAddressId, $billingAddressId, $shippingMethodId)
|
| 370 |
{
|
| 371 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 372 |
-
|
| 373 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 374 |
-
$quote = Mage::getModel("sales/quote")
|
| 375 |
->setStoreId($store)
|
| 376 |
->load($quoteId);
|
| 377 |
-
|
| 378 |
if (!is_null($billingAddressId)) {
|
| 379 |
/* @var $address Mage_Customer_Model_Address */
|
| 380 |
$customerBillingAddress = Mage::getModel('customer/address')
|
|
@@ -386,34 +345,26 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 386 |
}
|
| 387 |
|
| 388 |
if (!is_null($shippingAddressId)) {
|
| 389 |
-
/* @var $address Mage_Customer_Model_Address */
|
| 390 |
$customerShippingAddress = Mage::getModel('customer/address')
|
| 391 |
->load($shippingAddressId);
|
| 392 |
-
/* @var $shippingAddress Mage_Sales_Model_Quote_Address */
|
| 393 |
$shippingAddress = Mage::getModel('sales/quote_address')
|
| 394 |
->importCustomerAddress($customerShippingAddress)
|
| 395 |
->implodeStreetAddress();
|
| 396 |
-
|
| 397 |
-
/* @var $customer Mage_Customer_Model_Customer */
|
| 398 |
$customer = Mage::getModel('customer/customer')->load($shippingAddress->getCustomerId());
|
| 399 |
$quote->setCustomer($customer);
|
| 400 |
-
|
| 401 |
$quote->setShippingAddress($shippingAddress)
|
| 402 |
->getShippingAddress()
|
| 403 |
->setCollectShippingRates(true);
|
| 404 |
}
|
| 405 |
-
|
| 406 |
if (!is_null($shippingMethodId)) {
|
| 407 |
$quoteShippingAddress = $quote->getShippingAddress();
|
| 408 |
if (is_null($quoteShippingAddress->getId())) {
|
| 409 |
$this->_fault('invalid_data', 'Shipping address is not found.');
|
| 410 |
}
|
| 411 |
-
|
| 412 |
$rate = $quoteShippingAddress->collectShippingRates()->getShippingRateByCode($shippingMethodId);
|
| 413 |
if (!$rate) {
|
| 414 |
$this->_fault('invalid_data', 'Shipping rate is not found.');
|
| 415 |
}
|
| 416 |
-
|
| 417 |
try {
|
| 418 |
$quote->getShippingAddress()->setShippingMethod($shippingMethodId);
|
| 419 |
} catch (Mage_Core_Exception $e) {
|
|
@@ -428,12 +379,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 428 |
public function setGiftWrapping($quoteId, $isSelected, $message)
|
| 429 |
{
|
| 430 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 431 |
-
|
| 432 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 433 |
$quote = Mage::getModel("sales/quote")
|
| 434 |
->setStoreId($store)
|
| 435 |
->load($quoteId);
|
| 436 |
-
|
| 437 |
if (!$isSelected) {
|
| 438 |
$quote->setGiftMessageId(0);
|
| 439 |
} else {
|
|
@@ -442,7 +390,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 442 |
$giftMessages = array($quoteId => $giftMessage);
|
| 443 |
$request = new Mage_Core_Controller_Request_Http();
|
| 444 |
$request->setParam("giftmessage", $giftMessages);
|
| 445 |
-
|
| 446 |
Mage::dispatchEvent(
|
| 447 |
'checkout_controller_onepage_save_shipping_method',
|
| 448 |
array('request' => $request, 'quote' => $quote)
|
|
@@ -450,12 +397,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 450 |
}
|
| 451 |
return $this->get($quote->getId());
|
| 452 |
}
|
| 453 |
-
|
| 454 |
public function useDiscount($quoteId, $promoCode)
|
| 455 |
{
|
| 456 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 457 |
-
|
| 458 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 459 |
$quote = Mage::getModel("sales/quote")
|
| 460 |
->setStoreId($store)
|
| 461 |
->load($quoteId)
|
|
@@ -463,19 +407,14 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 463 |
->setTotalsCollectedFlag(false)
|
| 464 |
->collectTotals()
|
| 465 |
->save();
|
| 466 |
-
|
| 467 |
if ($quote->getCouponCode() != $promoCode) {
|
| 468 |
$this->_fault('invalid_data', 'Discount code is unavailable.');
|
| 469 |
}
|
| 470 |
-
|
| 471 |
return $this->get($quote->getId());
|
| 472 |
}
|
| 473 |
-
|
| 474 |
public function deleteDiscount($quoteId)
|
| 475 |
{
|
| 476 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 477 |
-
|
| 478 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 479 |
$quote = Mage::getModel("sales/quote")
|
| 480 |
->setStoreId($store)
|
| 481 |
->load($quoteId)
|
|
@@ -483,70 +422,48 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 483 |
->setTotalsCollectedFlag(false)
|
| 484 |
->collectTotals()
|
| 485 |
->save();
|
| 486 |
-
|
| 487 |
if (strlen($quote->getCouponCode()) > 0) {
|
| 488 |
$this->_fault('invalid_data', 'Discount code cannot be deleted.');
|
| 489 |
}
|
| 490 |
-
|
| 491 |
return $this->get($quote->getId());
|
| 492 |
}
|
| 493 |
-
|
| 494 |
public function useGiftCheques($quoteId, $code)
|
| 495 |
{
|
| 496 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 497 |
-
|
| 498 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 499 |
$quote = Mage::getModel("sales/quote")
|
| 500 |
->setStoreId($store)
|
| 501 |
->load($quoteId);
|
| 502 |
-
|
| 503 |
-
// TODO - set gift cheque to the quote for enterprise edition
|
| 504 |
-
|
| 505 |
return $this->get($quote->getId());
|
| 506 |
}
|
| 507 |
-
|
| 508 |
public function deleteGiftCheques($quoteId)
|
| 509 |
{
|
| 510 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 511 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 512 |
$quote = Mage::getModel("sales/quote")
|
| 513 |
->setStoreId($store)
|
| 514 |
->load($quoteId);
|
| 515 |
-
|
| 516 |
-
// TODO - delete gift cheque from the quote for enterprise edition
|
| 517 |
-
|
| 518 |
return $this->get($quote->getId());
|
| 519 |
}
|
| 520 |
-
|
| 521 |
public function useUserPoints($quoteId, $points)
|
| 522 |
{
|
| 523 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 524 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 525 |
$quote = Mage::getModel("sales/quote")
|
| 526 |
->setStoreId($store)
|
| 527 |
->load($quoteId);
|
| 528 |
-
|
| 529 |
-
// TODO - use customer's reward points
|
| 530 |
-
|
| 531 |
-
return $this->get($quote->getId());
|
| 532 |
}
|
| 533 |
-
|
| 534 |
public function selectPaymentMethod($quoteId, $payment)
|
| 535 |
{
|
| 536 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 537 |
$creditCardPaymentType = Mage::getStoreConfig('tappz/basket/creditcardpaymenttype');
|
| 538 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 539 |
$quote = Mage::getModel("sales/quote")
|
| 540 |
->setStoreId($store)
|
| 541 |
->load($quoteId);
|
| 542 |
-
|
| 543 |
$paymentData = array();
|
| 544 |
-
|
| 545 |
switch ($payment->methodType) {
|
| 546 |
case "CreditCard":
|
| 547 |
$creditCard = $payment->creditCard;
|
| 548 |
$type = null;
|
| 549 |
-
|
| 550 |
if (!is_null($creditCard)) {
|
| 551 |
switch ($creditCard->type) {
|
| 552 |
case '1':
|
|
@@ -568,18 +485,13 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 568 |
$paymentData['cc_exp_month'] = $creditCard->month;
|
| 569 |
$paymentData['cc_exp_year'] = $creditCard->year;
|
| 570 |
$paymentData['cc_cid'] = $creditCard->cvv;
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
// if(true) { // TODO : grinet ise girsen
|
| 574 |
$session->setData('ccNumber', $creditCard->number);
|
| 575 |
$session->setData('ccType', $type);
|
| 576 |
$session->setData('expYear', $creditCard->year);
|
| 577 |
$session->setData('expMonth', $creditCard->month);
|
| 578 |
-
// }
|
| 579 |
} else {
|
| 580 |
return $this->get($quote->getId());
|
| 581 |
}
|
| 582 |
-
|
| 583 |
$paymentMethod = $creditCardPaymentType;
|
| 584 |
break;
|
| 585 |
case "CashOnDelivery":
|
|
@@ -641,11 +553,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 641 |
}
|
| 642 |
}
|
| 643 |
}
|
| 644 |
-
|
| 645 |
try {
|
| 646 |
$payment = $quote->getPayment();
|
| 647 |
$payment->importData($paymentData);
|
| 648 |
-
|
| 649 |
$quote = $quote->setIsActive(true)
|
| 650 |
->setTotalsCollectedFlag(false)
|
| 651 |
->collectTotals()
|
|
@@ -653,39 +563,36 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 653 |
} catch (Mage_Core_Exception $e) {
|
| 654 |
$this->_fault('invalid_data', $e->getMessage());
|
| 655 |
}
|
| 656 |
-
|
| 657 |
return $quote;
|
| 658 |
}
|
| 659 |
-
|
| 660 |
-
protected function _canUsePaymentMethod($method, $quote)
|
| 661 |
-
{
|
| 662 |
/* @var $quote Mage_Sales_Model_Quote */
|
| 663 |
/** @var $method Mage_Payment_Model_Method_Abstract */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
if (!$method->canUseForCountry($quote->getBillingAddress()->getCountry())) {
|
| 665 |
return false;
|
| 666 |
}
|
| 667 |
-
|
| 668 |
if (!$method->canUseForCurrency(Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode())) {
|
| 669 |
return false;
|
| 670 |
}
|
| 671 |
-
|
| 672 |
-
/**
|
| 673 |
-
* Checking for min/max order total for assigned payment method
|
| 674 |
-
*/
|
| 675 |
$total = $quote->getBaseGrandTotal();
|
| 676 |
$minTotal = $method->getConfigData('min_order_total');
|
| 677 |
$maxTotal = $method->getConfigData('max_order_total');
|
| 678 |
-
|
| 679 |
if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
|
| 680 |
return false;
|
| 681 |
}
|
| 682 |
-
|
| 683 |
return true;
|
| 684 |
}
|
| 685 |
-
|
|
|
|
|
|
|
|
|
|
| 686 |
protected function purchase($quote)
|
| 687 |
{
|
| 688 |
-
/** @var $quote Mage_Sales_Model_Quote */
|
| 689 |
if ($quote->getIsMultiShipping()) {
|
| 690 |
$this->_fault('invalid_data', 'invalid_checkout_type');
|
| 691 |
}
|
|
@@ -694,16 +601,12 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 694 |
) {
|
| 695 |
$this->_fault('invalid_data', 'guest_checkout_is_not_enabled');
|
| 696 |
}
|
| 697 |
-
/** @var $customerResource Mage_Checkout_Model_Api_Resource_Customer */
|
| 698 |
$customerResource = Mage::getModel("checkout/api_resource_customer");
|
| 699 |
$isNewCustomer = $customerResource->prepareCustomerForQuote($quote);
|
| 700 |
-
|
| 701 |
try {
|
| 702 |
$quote->collectTotals();
|
| 703 |
-
/** @var $service Mage_Sales_Model_Service_Quote */
|
| 704 |
$service = Mage::getModel('sales/service_quote', $quote);
|
| 705 |
$service->submitAll();
|
| 706 |
-
|
| 707 |
if ($isNewCustomer) {
|
| 708 |
try {
|
| 709 |
$customerResource->involveNewCustomer($quote);
|
|
@@ -711,19 +614,15 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 711 |
Mage::logException($e);
|
| 712 |
}
|
| 713 |
}
|
| 714 |
-
|
| 715 |
$order = $service->getOrder();
|
| 716 |
if ($order) {
|
| 717 |
-
|
| 718 |
$status = $order->getStatus();
|
| 719 |
$state = $order->getState();
|
| 720 |
if ($status == 'canceled' || $state == 'canceled') {
|
| 721 |
$this->_fault('invalid_data', "Order is not completed. Please try again.");
|
| 722 |
}
|
| 723 |
-
|
| 724 |
Mage::dispatchEvent('checkout_type_onepage_save_order_after',
|
| 725 |
array('order' => $order, 'quote' => $quote));
|
| 726 |
-
|
| 727 |
try {
|
| 728 |
$order->queueNewOrderEmail();
|
| 729 |
} catch (Exception $e) {
|
|
@@ -741,15 +640,15 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 741 |
$quote->setIsActive(false)->save();
|
| 742 |
return $order->getIncrementId();
|
| 743 |
}
|
|
|
|
|
|
|
| 744 |
|
| 745 |
public function getContract($quoteId)
|
| 746 |
{
|
| 747 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 748 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 749 |
$quote = Mage::getModel("sales/quote")
|
| 750 |
->setStoreId($store)
|
| 751 |
->load($quoteId);
|
| 752 |
-
|
| 753 |
$agreements = array();
|
| 754 |
if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
|
| 755 |
$agreementsCollection = Mage::getModel('checkout/agreement')->getCollection()
|
|
@@ -757,7 +656,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 757 |
->addFieldToFilter('is_active', 1);
|
| 758 |
|
| 759 |
foreach ($agreementsCollection as $_a) {
|
| 760 |
-
/** @var $_a Mage_Checkout_Model_Agreement */
|
| 761 |
$agreements[] = $_a;
|
| 762 |
}
|
| 763 |
}
|
|
@@ -767,33 +665,28 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 767 |
$contract['termOfUse'] = $agreements[1]['content'];
|
| 768 |
return $contract;
|
| 769 |
}
|
| 770 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
public function purchaseCreditCard($quoteId)
|
| 772 |
{
|
| 773 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 774 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 775 |
$quote = Mage::getModel("sales/quote")
|
| 776 |
->setStoreId($store)
|
| 777 |
->load($quoteId);
|
| 778 |
-
|
| 779 |
try {
|
| 780 |
$session = Mage::getSingleton('checkout/session');
|
| 781 |
-
// $session->setData('ccNumber', $creditCard->number);
|
| 782 |
-
// $session->setData('ccType', $type);
|
| 783 |
-
// $session->setData('expYear', $creditCard->year);
|
| 784 |
-
// $session->setData('expMonth', $creditCard->month);
|
| 785 |
-
|
| 786 |
$ch = curl_init();
|
| 787 |
curl_setopt($ch, CURLOPT_URL, 'http://www.annelutfen.com/gtrpay/grinet/teb_payment/');
|
| 788 |
curl_setopt($ch, CURLOPT_POST, 1);
|
| 789 |
-
// curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
|
| 790 |
$token_result_json = curl_exec($ch);
|
| 791 |
curl_close($ch);
|
| 792 |
$token_result = json_decode($token_result_json);
|
| 793 |
} catch (Mage_Core_Exception $e) {
|
| 794 |
$this->_fault('invalid_data', $e->getMessage());
|
| 795 |
}
|
| 796 |
-
|
| 797 |
$orderId = $this->purchase($quote);
|
| 798 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 799 |
}
|
|
@@ -801,45 +694,38 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 801 |
public function purchaseMoneyOrder($quoteId, $moneyOrderType)
|
| 802 |
{
|
| 803 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 804 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 805 |
$quote = Mage::getModel("sales/quote")
|
| 806 |
->setStoreId($store)
|
| 807 |
->load($quoteId);
|
| 808 |
-
|
| 809 |
$orderId = $this->purchase($quote);
|
| 810 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 811 |
}
|
| 812 |
-
|
| 813 |
public function purchaseCashOnDelivery($quoteId, $cashOnDelivery)
|
| 814 |
{
|
| 815 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 816 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 817 |
$quote = Mage::getModel("sales/quote")
|
| 818 |
->setStoreId($store)
|
| 819 |
->load($quoteId);
|
| 820 |
-
|
| 821 |
$orderId = $this->purchase($quote);
|
| 822 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 823 |
}
|
| 824 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
public function createNewOrder($quote)
|
| 826 |
{
|
| 827 |
Mage::getSingleton('checkout/session')->replaceQuote($quote);
|
| 828 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 829 |
-
/* @var $convert Mage_Sales_Model_Convert_Quote */
|
| 830 |
-
/* @var $transaction Mage_Core_Model_Resource_Transaction */
|
| 831 |
$convert = Mage::getModel('sales/convert_quote');
|
| 832 |
$transaction = Mage::getModel('core/resource_transaction');
|
| 833 |
-
|
| 834 |
$quote->setIsActive(false);
|
| 835 |
-
|
| 836 |
if ($quote->getCustomerId()) {
|
| 837 |
$transaction->addObject($quote->getCustomer());
|
| 838 |
-
}
|
| 839 |
-
//$quote->setTotalsCollectedFlag(true);
|
| 840 |
$transaction->addObject($quote);
|
| 841 |
$quote->reserveOrderId();
|
| 842 |
-
|
| 843 |
if ($quote->isVirtual()) {
|
| 844 |
$order = $convert->addressToOrder($quote->getBillingAddress());
|
| 845 |
} else {
|
|
@@ -855,12 +741,9 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 855 |
$order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
|
| 856 |
}
|
| 857 |
}
|
| 858 |
-
|
| 859 |
$order->setPayment($convert->paymentToOrderPayment($quote->getPayment()));
|
| 860 |
$order->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
|
| 861 |
-
|
| 862 |
foreach ($quote->getAllItems() as $item) {
|
| 863 |
-
/** @var Mage_Sales_Model_Order_Item $item */
|
| 864 |
$orderItem = $convert->itemToOrderItem($item);
|
| 865 |
if ($item->getParentItem()) {
|
| 866 |
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
|
@@ -905,26 +788,21 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 905 |
}
|
| 906 |
Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $quote));
|
| 907 |
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order' => $order, 'quote' => $quote));
|
| 908 |
-
|
| 909 |
return $order;
|
| 910 |
}
|
| 911 |
-
|
| 912 |
public function purchaseWithPayPal($quoteId, $transactionId)
|
| 913 |
{
|
| 914 |
$paypalIsSandBox = (bool)Mage::getStoreConfig('tappz/basket/paypalissandbox');
|
| 915 |
$paypalClientId = Mage::getStoreConfig('tappz/basket/paypalclientid');
|
| 916 |
$paypalSecret = Mage::getStoreConfig('tappz/basket/paypalSecret');
|
| 917 |
-
|
| 918 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 919 |
/* @var $quote Mage_Sales_Model_Quote */
|
| 920 |
$quote = Mage::getModel("sales/quote")
|
| 921 |
->setStoreId($store)
|
| 922 |
->load($quoteId);
|
| 923 |
-
|
| 924 |
$url = $paypalIsSandBox
|
| 925 |
? "https://api.sandbox.paypal.com/v1/"
|
| 926 |
: "https://api.paypal.com/v1/";
|
| 927 |
-
|
| 928 |
$payment_result = array();
|
| 929 |
try {
|
| 930 |
$ch = curl_init();
|
|
@@ -956,10 +834,8 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 956 |
} catch (Exception $e) {
|
| 957 |
$this->_fault('invalid_data', $e->getMessage());
|
| 958 |
}
|
| 959 |
-
|
| 960 |
$transactionState = $payment_result['state'];
|
| 961 |
$saleState = $payment_result['transactions'][0]['related_resources'][0]['sale']['state'];
|
| 962 |
-
|
| 963 |
if ($transactionState == 'approved' && $saleState == 'completed') {
|
| 964 |
$quote->getPayment()->setTransactionId($transactionId)->save();
|
| 965 |
$order = $this->createNewOrder($quote);
|
|
@@ -968,28 +844,23 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 968 |
$this->_fault('invalid_data', 'PayPal transaction is not completed.');
|
| 969 |
}
|
| 970 |
}
|
| 971 |
-
|
| 972 |
public function purchaseWithApplePay($quoteId, $tokenId)
|
| 973 |
{
|
| 974 |
$stripeIsTest = (bool)Mage::getStoreConfig('tappz/basket/stripeistest');
|
| 975 |
$stripeTestSecretKey = Mage::getStoreConfig('tappz/basket/stripetestsecret');
|
| 976 |
$stripeLiveSecretKey = Mage::getStoreConfig('tappz/basket/stripelivesecret');
|
| 977 |
-
|
| 978 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 979 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 980 |
$quote = Mage::getModel("sales/quote")
|
| 981 |
->setStoreId($store)
|
| 982 |
->load($quoteId);
|
| 983 |
-
|
| 984 |
$secretKey = $stripeIsTest ? $stripeTestSecretKey : $stripeLiveSecretKey;
|
| 985 |
-
|
| 986 |
$fields = array(
|
| 987 |
'amount' => $quote->getGrandTotal(),
|
| 988 |
'currency' => $quote->getQuoteCurrencyCode(),
|
| 989 |
'source' => $tokenId,
|
| 990 |
'description' => 't-appz Apple Pay',
|
| 991 |
);
|
| 992 |
-
|
| 993 |
$field_string = http_build_query($fields);
|
| 994 |
$charge = array();
|
| 995 |
try {
|
|
@@ -1014,9 +885,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1014 |
} catch (Exception $e) {
|
| 1015 |
$this->_fault('invalid_data', $e->getMessage());
|
| 1016 |
}
|
| 1017 |
-
|
| 1018 |
-
// TODO : test
|
| 1019 |
-
|
| 1020 |
if ($charge['captured']) {
|
| 1021 |
$paymentData = array();
|
| 1022 |
$paymentData['method'] = 'ApplePay';
|
|
@@ -1033,14 +901,12 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1033 |
public function getTaksitSecenekleri($quoteId)
|
| 1034 |
{
|
| 1035 |
$bankInfos = array();
|
| 1036 |
-
|
| 1037 |
$exclude_cats = array(219, 218, 527, 217, 651, 329, 331, 678);
|
| 1038 |
$show_taksits = true;
|
| 1039 |
$cats = array();
|
| 1040 |
$cart = Mage::getModel("sales/quote")->load($quoteId);
|
| 1041 |
$cartItems = $cart->getItems();
|
| 1042 |
$tutar = $cart->getGrandTotal();
|
| 1043 |
-
|
| 1044 |
foreach ($cartItems as $item) {
|
| 1045 |
$cats[] = $item->getProduct()->getCategoryIds();
|
| 1046 |
}
|
|
@@ -1053,7 +919,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1053 |
}
|
| 1054 |
}
|
| 1055 |
}
|
| 1056 |
-
|
| 1057 |
$turkpay = Mage::getModel('Grinet_Turkpay_Model_Grinet');
|
| 1058 |
if ($turkpay) {
|
| 1059 |
$bank_avs = $turkpay->bankalar();
|
|
@@ -1062,15 +927,10 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1062 |
$bankCount = 0;
|
| 1063 |
$fark = 0;
|
| 1064 |
foreach ($bank_avs as $bank_code => $bank) {
|
| 1065 |
-
//$codes[] = $bank_code;
|
| 1066 |
-
// $bankName[] = $bank['name'];
|
| 1067 |
-
// $tutar = 200;
|
| 1068 |
$tdata = $turkpay->taksitler($bank_code, $tutar);
|
| 1069 |
$valCount = 0;
|
| 1070 |
foreach ($tdata as $tay => $toran) {
|
| 1071 |
-
/* price calculater */
|
| 1072 |
$toplam_tutar = $tutar + (($tutar / 100) * floatval($toran)) + $fark;// - ( ( $fark / 100 ) * floatval($toran) ) ;
|
| 1073 |
-
/* price calculater */
|
| 1074 |
$custom_title = Mage::getStoreConfig($bank_code . '/taksit_baslik/taksit_' . $tay);
|
| 1075 |
if (trim($custom_title) == '')
|
| 1076 |
$taksit_title = 'Tek Çekim';
|
|
@@ -1095,7 +955,6 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1095 |
if ($taksit_title == "Tek Çekim")
|
| 1096 |
break;
|
| 1097 |
}
|
| 1098 |
-
|
| 1099 |
$valCount++;
|
| 1100 |
}
|
| 1101 |
$bankCount++;
|
|
@@ -1105,27 +964,24 @@ class TmobLabs_Tappz_Model_Basket_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 1105 |
return $bankInfos;
|
| 1106 |
}
|
| 1107 |
|
|
|
|
|
|
|
|
|
|
| 1108 |
public function getSupplyDate($quoteId)
|
| 1109 |
{
|
| 1110 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 1111 |
$productAverageDeliveryDaysAttributeCode = Mage::getStoreConfig('tappz/basket/averagedeliverydaysattributecode');
|
| 1112 |
-
|
| 1113 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
| 1114 |
$quote = Mage::getModel("sales/quote")
|
| 1115 |
->setStoreId($store)
|
| 1116 |
->load($quoteId);
|
| 1117 |
-
|
| 1118 |
$set_message = array();
|
| 1119 |
foreach ($quote->getAllItems() as $item) {
|
| 1120 |
$product = Mage::getModel('catalog/product')->load($item->getData('product_id'));
|
| 1121 |
-
/* @var $product Mage_Catalog_Model_Product */
|
| 1122 |
$message = $product->getData($productAverageDeliveryDaysAttributeCode);
|
| 1123 |
if ($message)
|
| 1124 |
$set_message[] = $message;
|
| 1125 |
}
|
| 1126 |
-
|
| 1127 |
$set_message_unique = array_unique($set_message);
|
| 1128 |
-
|
| 1129 |
$by_0 = false;
|
| 1130 |
$by_3 = false;
|
| 1131 |
$by_4 = false;
|
| 39 |
$basket['estimatedSupplyDate'] = null;
|
| 40 |
$basket['isGiftWrappingEnabled'] = false;
|
| 41 |
$basket['giftWrapping'] = null;
|
|
|
|
|
|
|
| 42 |
$quote = Mage::getModel("sales/quote")
|
| 43 |
->setStoreId($store);
|
|
|
|
| 44 |
if (isset($customerId)) {
|
| 45 |
$quote = $quote->loadByCustomer($customerId);
|
| 46 |
} elseif (isset($quoteId)) {
|
| 47 |
$quote = $quote->load($quoteId);
|
| 48 |
}
|
|
|
|
| 49 |
if (is_null($quote->getId())) {
|
| 50 |
try {
|
| 51 |
if (isset($customerId) && $customerId !== '') {
|
| 57 |
$this->_fault('invalid_data', $e->getMessage());
|
| 58 |
}
|
| 59 |
}
|
|
|
|
| 60 |
$catalogApi = Mage::getSingleton('tappz/Catalog_Api');
|
| 61 |
$addressApi = Mage::getSingleton('tappz/Customer_Address_Api');
|
|
|
|
| 62 |
$basket['id'] = $quote->getId();
|
|
|
|
| 63 |
foreach ($quote->getAllVisibleItems() as $item) {
|
| 64 |
$line = array();
|
| 65 |
$line['productId'] = $item->getData('product_id');
|
| 68 |
$line['price'] = number_format($item->getData('price'), 2, $decimalDivider, $thousandDivider);
|
| 69 |
$line['priceTotal'] = number_format($item->getData('row_total'), 2, $decimalDivider, $thousandDivider);
|
| 70 |
$line['averageDeliveryDays'] = $item->getData($lineAverageDeliveryDaysAttributeCode);
|
| 71 |
+
$line['variants'] = array();
|
| 72 |
$basket['lines'][] = $line;
|
| 73 |
}
|
|
|
|
| 74 |
$basket['currency'] = Mage::app()->getStore($quote->getStoreId())->getCurrentCurrencyCode();
|
|
|
|
| 75 |
$quoteBillingAddress = $quote->getBillingAddress();
|
| 76 |
if ($quoteBillingAddress)
|
| 77 |
$basket['delivery']['billingAddress'] = $addressApi->get($quoteBillingAddress->getData('customer_address_id'));
|
|
|
|
| 78 |
$quoteShippingAddress = $quote->getShippingAddress();
|
| 79 |
if ($quoteShippingAddress) {
|
| 80 |
$basket['delivery']['shippingAddress'] = $addressApi->get($quoteShippingAddress->getData('customer_address_id'));
|
| 86 |
$basket['delivery']['shippingMethod']['priceForYou'] = null;
|
| 87 |
$basket['delivery']['shippingMethod']['shippingMethodType'] = $quoteShippingAddress->getData('shipping_method');
|
| 88 |
$basket['delivery']['shippingMethod']['imageUrl'] = null;
|
|
|
|
| 89 |
$basket['discountTotal'] = number_format($quoteShippingAddress->getData('discount_amount'), 2, $decimalDivider, $thousandDivider);
|
| 90 |
$basket['shippingTotal'] = number_format($quoteShippingAddress->getData('shipping_incl_tax'), 2, $decimalDivider, $thousandDivider);
|
| 91 |
} else {
|
| 92 |
+
|
| 93 |
}
|
|
|
|
| 94 |
$basket['itemsPriceTotal'] = number_format($quote->getData('base_subtotal'), 2, $decimalDivider, $thousandDivider);
|
| 95 |
if (!isset($basket['discountTotal']))
|
| 96 |
$basket['discountTotal'] = floatval($quote->getData('subtotal')) - floatval($quote->getData('subtotal_with_discount'));
|
| 97 |
$basket['subTotal'] = number_format($quote->getData('subtotal'), 2, $decimalDivider, $thousandDivider);
|
| 98 |
$basket['total'] = number_format($quote->getData('grand_total'), 2, $decimalDivider, $thousandDivider);
|
|
|
|
| 99 |
$basket['discounts'][0]['displayName'] = null;
|
| 100 |
$basket['discounts'][0]['discountTotal'] = $basket['discountTotal'];
|
| 101 |
$basket['discounts'][0]['promoCode'] = $quote->getData('coupon_code');
|
|
|
|
| 102 |
$payment = $quote->getPayment();
|
| 103 |
if (isset($payment)) {
|
| 104 |
$paymentData = array();
|
| 156 |
$paymentData['accountNumber'] = null;
|
| 157 |
$paymentData['branch'] = null;
|
| 158 |
$paymentData['iban'] = null;
|
| 159 |
+
} else if ($method == 'stripe') {
|
| 160 |
$paymentData['methodType'] = 'ApplePay';
|
| 161 |
$paymentData['type'] = $method;
|
| 162 |
$paymentData['displayName'] = 'Apple Pay';
|
| 168 |
}
|
| 169 |
$basket['payment'] = $paymentData;
|
| 170 |
}
|
|
|
|
| 171 |
$paymentOptions = array();
|
| 172 |
$paymentOptions['paypal'] = null;
|
| 173 |
$paymentOptions['creditCards'] = array();
|
| 174 |
$paymentOptions['moneyTransfers'] = array();
|
| 175 |
$paymentOptions['cashOnDelivery'] = null;
|
|
|
|
| 176 |
$methods = Mage::helper('payment')->getStoreMethods($store, $quote);
|
| 177 |
foreach ($methods as $method) {
|
| 178 |
$code = $method->getCode();
|
| 208 |
$paymentOptions['cashOnDelivery']['isSMSVerification'] = false;
|
| 209 |
$paymentOptions['cashOnDelivery']['SMSCode'] = null;
|
| 210 |
$paymentOptions['cashOnDelivery']['PhoneNumber'] = null;
|
|
|
|
| 211 |
$paymentOptions['cashOnDelivery']['type'] = $code;
|
| 212 |
$paymentOptions['cashOnDelivery']['displayName'] = $method->getTitle();
|
| 213 |
+
$paymentOptions['cashOnDelivery']['additionalFee'] = '0';
|
| 214 |
+
$paymentOptions['cashOnDelivery']['description'] = 'Cash on delivery description text';
|
| 215 |
$paymentOptions['cashOnDelivery']['isSMSVerification'] = false;
|
| 216 |
$paymentOptions['cashOnDelivery']['SMSCode'] = null;
|
| 217 |
$paymentOptions['cashOnDelivery']['PhoneNumber'] = null;
|
| 230 |
|
| 231 |
$shippingMethods = array();
|
| 232 |
if (isset($quoteShippingAddress)) {
|
|
|
|
| 233 |
$quoteShippingAddress->collectShippingRates()->save();
|
| 234 |
$groupedRates = $quoteShippingAddress->getGroupedAllShippingRates();
|
|
|
|
| 235 |
foreach ($groupedRates as $carrierCode => $rates) {
|
| 236 |
foreach ($rates as $rate) {
|
| 237 |
$rateItem = array();
|
| 242 |
$rateItem['priceForYou'] = null;
|
| 243 |
$rateItem['shippingMethodType'] = $rate->getData('code');
|
| 244 |
$rateItem['imageUrl'] = null;
|
|
|
|
| 245 |
$shippingMethods[] = $rateItem;
|
| 246 |
}
|
| 247 |
}
|
|
|
|
|
|
|
|
|
|
| 248 |
}
|
| 249 |
$basket['shippingMethods'] = $shippingMethods;
|
| 250 |
|
| 253 |
// TODO
|
| 254 |
}
|
| 255 |
$basket['giftCheques'] = $giftCheques;
|
|
|
|
| 256 |
$basket['spentGiftChequeTotal'] = number_format($quote->getData('gift_cards_amount'), 2, $decimalDivider, $thousandDivider);
|
| 257 |
$basket['usedPoints'] = null; //TODO
|
| 258 |
$basket['usedPointsAmount'] = null; //TODO
|
| 278 |
public function merge($anonymousQuoteId, $customerId)
|
| 279 |
{
|
| 280 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
|
|
|
| 281 |
$anonymousQuote = Mage::getModel("sales/quote")
|
| 282 |
->setStoreId($store)
|
| 283 |
->load($anonymousQuoteId);
|
|
|
|
| 284 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
|
|
|
| 285 |
$quote = Mage::getModel("sales/quote")
|
| 286 |
->setStoreId($store)
|
| 287 |
->loadByCustomer($customer);
|
|
|
|
| 288 |
if (is_null($quote->getId())) {
|
| 289 |
try {
|
| 290 |
$quote = $quote->setStoreId($store)
|
| 296 |
$this->_fault('invalid_data', $e->getMessage());
|
| 297 |
}
|
| 298 |
}
|
|
|
|
| 299 |
try {
|
| 300 |
$quote = $quote->merge($anonymousQuote);
|
| 301 |
$quote = $quote->collectTotals()->save();
|
| 302 |
} catch (Mage_Core_Exception $e) {
|
| 303 |
$this->_fault('invalid_data', $e->getMessage());
|
| 304 |
}
|
|
|
|
| 305 |
return $this->get($quote->getId());
|
| 306 |
}
|
| 307 |
|
| 308 |
public function updateItems($quoteId, $updateList)
|
| 309 |
{
|
| 310 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
|
|
|
| 311 |
$quote = Mage::getModel("sales/quote")
|
| 312 |
->setStoreId($store)
|
| 313 |
->load($quoteId);
|
|
|
|
| 314 |
foreach ($updateList as $item) {
|
| 315 |
$productId = $item->productId;
|
| 316 |
$qty = $item->qty;
|
|
|
|
|
|
|
| 317 |
$product = Mage::getModel('catalog/product')->load($productId);
|
| 318 |
$quoteItem = $quote->getItemByProduct($product);
|
| 319 |
$request = new Varien_Object(array('qty' => $qty));
|
| 325 |
$quote->updateItem($quoteItem->getId(), $request);
|
| 326 |
}
|
| 327 |
}
|
|
|
|
| 328 |
$quote->setTotalsCollectedFlag(false)->collectTotals()->save();
|
| 329 |
return $this->get($quote->getId());
|
| 330 |
}
|
|
|
|
| 331 |
public function setAddress($quoteId, $shippingAddressId, $billingAddressId, $shippingMethodId)
|
| 332 |
{
|
| 333 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 334 |
+
$quote = Mage::getModel("sales/quote")
|
|
|
|
|
|
|
| 335 |
->setStoreId($store)
|
| 336 |
->load($quoteId);
|
|
|
|
| 337 |
if (!is_null($billingAddressId)) {
|
| 338 |
/* @var $address Mage_Customer_Model_Address */
|
| 339 |
$customerBillingAddress = Mage::getModel('customer/address')
|
| 345 |
}
|
| 346 |
|
| 347 |
if (!is_null($shippingAddressId)) {
|
|
|
|
| 348 |
$customerShippingAddress = Mage::getModel('customer/address')
|
| 349 |
->load($shippingAddressId);
|
|
|
|
| 350 |
$shippingAddress = Mage::getModel('sales/quote_address')
|
| 351 |
->importCustomerAddress($customerShippingAddress)
|
| 352 |
->implodeStreetAddress();
|
|
|
|
|
|
|
| 353 |
$customer = Mage::getModel('customer/customer')->load($shippingAddress->getCustomerId());
|
| 354 |
$quote->setCustomer($customer);
|
|
|
|
| 355 |
$quote->setShippingAddress($shippingAddress)
|
| 356 |
->getShippingAddress()
|
| 357 |
->setCollectShippingRates(true);
|
| 358 |
}
|
|
|
|
| 359 |
if (!is_null($shippingMethodId)) {
|
| 360 |
$quoteShippingAddress = $quote->getShippingAddress();
|
| 361 |
if (is_null($quoteShippingAddress->getId())) {
|
| 362 |
$this->_fault('invalid_data', 'Shipping address is not found.');
|
| 363 |
}
|
|
|
|
| 364 |
$rate = $quoteShippingAddress->collectShippingRates()->getShippingRateByCode($shippingMethodId);
|
| 365 |
if (!$rate) {
|
| 366 |
$this->_fault('invalid_data', 'Shipping rate is not found.');
|
| 367 |
}
|
|
|
|
| 368 |
try {
|
| 369 |
$quote->getShippingAddress()->setShippingMethod($shippingMethodId);
|
| 370 |
} catch (Mage_Core_Exception $e) {
|
| 379 |
public function setGiftWrapping($quoteId, $isSelected, $message)
|
| 380 |
{
|
| 381 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
|
|
|
| 382 |
$quote = Mage::getModel("sales/quote")
|
| 383 |
->setStoreId($store)
|
| 384 |
->load($quoteId);
|
|
|
|
| 385 |
if (!$isSelected) {
|
| 386 |
$quote->setGiftMessageId(0);
|
| 387 |
} else {
|
| 390 |
$giftMessages = array($quoteId => $giftMessage);
|
| 391 |
$request = new Mage_Core_Controller_Request_Http();
|
| 392 |
$request->setParam("giftmessage", $giftMessages);
|
|
|
|
| 393 |
Mage::dispatchEvent(
|
| 394 |
'checkout_controller_onepage_save_shipping_method',
|
| 395 |
array('request' => $request, 'quote' => $quote)
|
| 397 |
}
|
| 398 |
return $this->get($quote->getId());
|
| 399 |
}
|
|
|
|
| 400 |
public function useDiscount($quoteId, $promoCode)
|
| 401 |
{
|
| 402 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
|
|
|
| 403 |
$quote = Mage::getModel("sales/quote")
|
| 404 |
->setStoreId($store)
|
| 405 |
->load($quoteId)
|
| 407 |
->setTotalsCollectedFlag(false)
|
| 408 |
->collectTotals()
|
| 409 |
->save();
|
|
|
|
| 410 |
if ($quote->getCouponCode() != $promoCode) {
|
| 411 |
$this->_fault('invalid_data', 'Discount code is unavailable.');
|
| 412 |
}
|
|
|
|
| 413 |
return $this->get($quote->getId());
|
| 414 |
}
|
|
|
|
| 415 |
public function deleteDiscount($quoteId)
|
| 416 |
{
|
| 417 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
|
|
|
| 418 |
$quote = Mage::getModel("sales/quote")
|
| 419 |
->setStoreId($store)
|
| 420 |
->load($quoteId)
|
| 422 |
->setTotalsCollectedFlag(false)
|
| 423 |
->collectTotals()
|
| 424 |
->save();
|
|
|
|
| 425 |
if (strlen($quote->getCouponCode()) > 0) {
|
| 426 |
$this->_fault('invalid_data', 'Discount code cannot be deleted.');
|
| 427 |
}
|
|
|
|
| 428 |
return $this->get($quote->getId());
|
| 429 |
}
|
|
|
|
| 430 |
public function useGiftCheques($quoteId, $code)
|
| 431 |
{
|
| 432 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 433 |
+
|
|
|
|
| 434 |
$quote = Mage::getModel("sales/quote")
|
| 435 |
->setStoreId($store)
|
| 436 |
->load($quoteId);
|
|
|
|
|
|
|
|
|
|
| 437 |
return $this->get($quote->getId());
|
| 438 |
}
|
|
|
|
| 439 |
public function deleteGiftCheques($quoteId)
|
| 440 |
{
|
| 441 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 442 |
$quote = Mage::getModel("sales/quote")
|
| 443 |
->setStoreId($store)
|
| 444 |
->load($quoteId);
|
|
|
|
|
|
|
|
|
|
| 445 |
return $this->get($quote->getId());
|
| 446 |
}
|
|
|
|
| 447 |
public function useUserPoints($quoteId, $points)
|
| 448 |
{
|
| 449 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 450 |
$quote = Mage::getModel("sales/quote")
|
| 451 |
->setStoreId($store)
|
| 452 |
->load($quoteId);
|
| 453 |
+
return $this->get($quote->getId());
|
|
|
|
|
|
|
|
|
|
| 454 |
}
|
|
|
|
| 455 |
public function selectPaymentMethod($quoteId, $payment)
|
| 456 |
{
|
| 457 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 458 |
$creditCardPaymentType = Mage::getStoreConfig('tappz/basket/creditcardpaymenttype');
|
|
|
|
| 459 |
$quote = Mage::getModel("sales/quote")
|
| 460 |
->setStoreId($store)
|
| 461 |
->load($quoteId);
|
|
|
|
| 462 |
$paymentData = array();
|
|
|
|
| 463 |
switch ($payment->methodType) {
|
| 464 |
case "CreditCard":
|
| 465 |
$creditCard = $payment->creditCard;
|
| 466 |
$type = null;
|
|
|
|
| 467 |
if (!is_null($creditCard)) {
|
| 468 |
switch ($creditCard->type) {
|
| 469 |
case '1':
|
| 485 |
$paymentData['cc_exp_month'] = $creditCard->month;
|
| 486 |
$paymentData['cc_exp_year'] = $creditCard->year;
|
| 487 |
$paymentData['cc_cid'] = $creditCard->cvv;
|
|
|
|
|
|
|
|
|
|
| 488 |
$session->setData('ccNumber', $creditCard->number);
|
| 489 |
$session->setData('ccType', $type);
|
| 490 |
$session->setData('expYear', $creditCard->year);
|
| 491 |
$session->setData('expMonth', $creditCard->month);
|
|
|
|
| 492 |
} else {
|
| 493 |
return $this->get($quote->getId());
|
| 494 |
}
|
|
|
|
| 495 |
$paymentMethod = $creditCardPaymentType;
|
| 496 |
break;
|
| 497 |
case "CashOnDelivery":
|
| 553 |
}
|
| 554 |
}
|
| 555 |
}
|
|
|
|
| 556 |
try {
|
| 557 |
$payment = $quote->getPayment();
|
| 558 |
$payment->importData($paymentData);
|
|
|
|
| 559 |
$quote = $quote->setIsActive(true)
|
| 560 |
->setTotalsCollectedFlag(false)
|
| 561 |
->collectTotals()
|
| 563 |
} catch (Mage_Core_Exception $e) {
|
| 564 |
$this->_fault('invalid_data', $e->getMessage());
|
| 565 |
}
|
|
|
|
| 566 |
return $quote;
|
| 567 |
}
|
|
|
|
|
|
|
|
|
|
| 568 |
/* @var $quote Mage_Sales_Model_Quote */
|
| 569 |
/** @var $method Mage_Payment_Model_Method_Abstract */
|
| 570 |
+
/**
|
| 571 |
+
* Checking for min/max order total for assigned payment method
|
| 572 |
+
*/
|
| 573 |
+
|
| 574 |
+
protected function _canUsePaymentMethod($method, $quote)
|
| 575 |
+
{
|
| 576 |
if (!$method->canUseForCountry($quote->getBillingAddress()->getCountry())) {
|
| 577 |
return false;
|
| 578 |
}
|
|
|
|
| 579 |
if (!$method->canUseForCurrency(Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode())) {
|
| 580 |
return false;
|
| 581 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
$total = $quote->getBaseGrandTotal();
|
| 583 |
$minTotal = $method->getConfigData('min_order_total');
|
| 584 |
$maxTotal = $method->getConfigData('max_order_total');
|
|
|
|
| 585 |
if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
|
| 586 |
return false;
|
| 587 |
}
|
|
|
|
| 588 |
return true;
|
| 589 |
}
|
| 590 |
+
/** @var $quote Mage_Sales_Model_Quote */
|
| 591 |
+
/** @var $customerResource Mage_Checkout_Model_Api_Resource_Customer */
|
| 592 |
+
/** @var $service Mage_Sales_Model_Service_Quote */
|
| 593 |
+
|
| 594 |
protected function purchase($quote)
|
| 595 |
{
|
|
|
|
| 596 |
if ($quote->getIsMultiShipping()) {
|
| 597 |
$this->_fault('invalid_data', 'invalid_checkout_type');
|
| 598 |
}
|
| 601 |
) {
|
| 602 |
$this->_fault('invalid_data', 'guest_checkout_is_not_enabled');
|
| 603 |
}
|
|
|
|
| 604 |
$customerResource = Mage::getModel("checkout/api_resource_customer");
|
| 605 |
$isNewCustomer = $customerResource->prepareCustomerForQuote($quote);
|
|
|
|
| 606 |
try {
|
| 607 |
$quote->collectTotals();
|
|
|
|
| 608 |
$service = Mage::getModel('sales/service_quote', $quote);
|
| 609 |
$service->submitAll();
|
|
|
|
| 610 |
if ($isNewCustomer) {
|
| 611 |
try {
|
| 612 |
$customerResource->involveNewCustomer($quote);
|
| 614 |
Mage::logException($e);
|
| 615 |
}
|
| 616 |
}
|
|
|
|
| 617 |
$order = $service->getOrder();
|
| 618 |
if ($order) {
|
|
|
|
| 619 |
$status = $order->getStatus();
|
| 620 |
$state = $order->getState();
|
| 621 |
if ($status == 'canceled' || $state == 'canceled') {
|
| 622 |
$this->_fault('invalid_data', "Order is not completed. Please try again.");
|
| 623 |
}
|
|
|
|
| 624 |
Mage::dispatchEvent('checkout_type_onepage_save_order_after',
|
| 625 |
array('order' => $order, 'quote' => $quote));
|
|
|
|
| 626 |
try {
|
| 627 |
$order->queueNewOrderEmail();
|
| 628 |
} catch (Exception $e) {
|
| 640 |
$quote->setIsActive(false)->save();
|
| 641 |
return $order->getIncrementId();
|
| 642 |
}
|
| 643 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 644 |
+
/** @var $_a Mage_Checkout_Model_Agreement */
|
| 645 |
|
| 646 |
public function getContract($quoteId)
|
| 647 |
{
|
| 648 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 649 |
$quote = Mage::getModel("sales/quote")
|
| 650 |
->setStoreId($store)
|
| 651 |
->load($quoteId);
|
|
|
|
| 652 |
$agreements = array();
|
| 653 |
if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
|
| 654 |
$agreementsCollection = Mage::getModel('checkout/agreement')->getCollection()
|
| 656 |
->addFieldToFilter('is_active', 1);
|
| 657 |
|
| 658 |
foreach ($agreementsCollection as $_a) {
|
|
|
|
| 659 |
$agreements[] = $_a;
|
| 660 |
}
|
| 661 |
}
|
| 665 |
$contract['termOfUse'] = $agreements[1]['content'];
|
| 666 |
return $contract;
|
| 667 |
}
|
| 668 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 669 |
+
// $session->setData('ccNumber', $creditCard->number);
|
| 670 |
+
// $session->setData('ccType', $type);
|
| 671 |
+
// $session->setData('expYear', $creditCard->year);
|
| 672 |
+
// $session->setData('expMonth', $creditCard->month);
|
| 673 |
public function purchaseCreditCard($quoteId)
|
| 674 |
{
|
| 675 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 676 |
$quote = Mage::getModel("sales/quote")
|
| 677 |
->setStoreId($store)
|
| 678 |
->load($quoteId);
|
|
|
|
| 679 |
try {
|
| 680 |
$session = Mage::getSingleton('checkout/session');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
$ch = curl_init();
|
| 682 |
curl_setopt($ch, CURLOPT_URL, 'http://www.annelutfen.com/gtrpay/grinet/teb_payment/');
|
| 683 |
curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
| 684 |
$token_result_json = curl_exec($ch);
|
| 685 |
curl_close($ch);
|
| 686 |
$token_result = json_decode($token_result_json);
|
| 687 |
} catch (Mage_Core_Exception $e) {
|
| 688 |
$this->_fault('invalid_data', $e->getMessage());
|
| 689 |
}
|
|
|
|
| 690 |
$orderId = $this->purchase($quote);
|
| 691 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 692 |
}
|
| 694 |
public function purchaseMoneyOrder($quoteId, $moneyOrderType)
|
| 695 |
{
|
| 696 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 697 |
$quote = Mage::getModel("sales/quote")
|
| 698 |
->setStoreId($store)
|
| 699 |
->load($quoteId);
|
|
|
|
| 700 |
$orderId = $this->purchase($quote);
|
| 701 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 702 |
}
|
| 703 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 704 |
public function purchaseCashOnDelivery($quoteId, $cashOnDelivery)
|
| 705 |
{
|
| 706 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 707 |
$quote = Mage::getModel("sales/quote")
|
| 708 |
->setStoreId($store)
|
| 709 |
->load($quoteId);
|
|
|
|
| 710 |
$orderId = $this->purchase($quote);
|
| 711 |
return Mage::getSingleton('tappz/Customer_Order_Api')->info($orderId);
|
| 712 |
}
|
| 713 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 714 |
+
/* @var $convert Mage_Sales_Model_Convert_Quote */
|
| 715 |
+
/* @var $transaction Mage_Core_Model_Resource_Transaction */
|
| 716 |
+
//$quote->setTotalsCollectedFlag(true);
|
| 717 |
+
/** @var Mage_Sales_Model_Order_Item $item */
|
| 718 |
public function createNewOrder($quote)
|
| 719 |
{
|
| 720 |
Mage::getSingleton('checkout/session')->replaceQuote($quote);
|
|
|
|
|
|
|
|
|
|
| 721 |
$convert = Mage::getModel('sales/convert_quote');
|
| 722 |
$transaction = Mage::getModel('core/resource_transaction');
|
|
|
|
| 723 |
$quote->setIsActive(false);
|
|
|
|
| 724 |
if ($quote->getCustomerId()) {
|
| 725 |
$transaction->addObject($quote->getCustomer());
|
| 726 |
+
}
|
|
|
|
| 727 |
$transaction->addObject($quote);
|
| 728 |
$quote->reserveOrderId();
|
|
|
|
| 729 |
if ($quote->isVirtual()) {
|
| 730 |
$order = $convert->addressToOrder($quote->getBillingAddress());
|
| 731 |
} else {
|
| 741 |
$order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
|
| 742 |
}
|
| 743 |
}
|
|
|
|
| 744 |
$order->setPayment($convert->paymentToOrderPayment($quote->getPayment()));
|
| 745 |
$order->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
|
|
|
|
| 746 |
foreach ($quote->getAllItems() as $item) {
|
|
|
|
| 747 |
$orderItem = $convert->itemToOrderItem($item);
|
| 748 |
if ($item->getParentItem()) {
|
| 749 |
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
| 788 |
}
|
| 789 |
Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $quote));
|
| 790 |
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order' => $order, 'quote' => $quote));
|
|
|
|
| 791 |
return $order;
|
| 792 |
}
|
|
|
|
| 793 |
public function purchaseWithPayPal($quoteId, $transactionId)
|
| 794 |
{
|
| 795 |
$paypalIsSandBox = (bool)Mage::getStoreConfig('tappz/basket/paypalissandbox');
|
| 796 |
$paypalClientId = Mage::getStoreConfig('tappz/basket/paypalclientid');
|
| 797 |
$paypalSecret = Mage::getStoreConfig('tappz/basket/paypalSecret');
|
|
|
|
| 798 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 799 |
/* @var $quote Mage_Sales_Model_Quote */
|
| 800 |
$quote = Mage::getModel("sales/quote")
|
| 801 |
->setStoreId($store)
|
| 802 |
->load($quoteId);
|
|
|
|
| 803 |
$url = $paypalIsSandBox
|
| 804 |
? "https://api.sandbox.paypal.com/v1/"
|
| 805 |
: "https://api.paypal.com/v1/";
|
|
|
|
| 806 |
$payment_result = array();
|
| 807 |
try {
|
| 808 |
$ch = curl_init();
|
| 834 |
} catch (Exception $e) {
|
| 835 |
$this->_fault('invalid_data', $e->getMessage());
|
| 836 |
}
|
|
|
|
| 837 |
$transactionState = $payment_result['state'];
|
| 838 |
$saleState = $payment_result['transactions'][0]['related_resources'][0]['sale']['state'];
|
|
|
|
| 839 |
if ($transactionState == 'approved' && $saleState == 'completed') {
|
| 840 |
$quote->getPayment()->setTransactionId($transactionId)->save();
|
| 841 |
$order = $this->createNewOrder($quote);
|
| 844 |
$this->_fault('invalid_data', 'PayPal transaction is not completed.');
|
| 845 |
}
|
| 846 |
}
|
| 847 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 848 |
public function purchaseWithApplePay($quoteId, $tokenId)
|
| 849 |
{
|
| 850 |
$stripeIsTest = (bool)Mage::getStoreConfig('tappz/basket/stripeistest');
|
| 851 |
$stripeTestSecretKey = Mage::getStoreConfig('tappz/basket/stripetestsecret');
|
| 852 |
$stripeLiveSecretKey = Mage::getStoreConfig('tappz/basket/stripelivesecret');
|
|
|
|
| 853 |
$store = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 854 |
$quote = Mage::getModel("sales/quote")
|
| 855 |
->setStoreId($store)
|
| 856 |
->load($quoteId);
|
|
|
|
| 857 |
$secretKey = $stripeIsTest ? $stripeTestSecretKey : $stripeLiveSecretKey;
|
|
|
|
| 858 |
$fields = array(
|
| 859 |
'amount' => $quote->getGrandTotal(),
|
| 860 |
'currency' => $quote->getQuoteCurrencyCode(),
|
| 861 |
'source' => $tokenId,
|
| 862 |
'description' => 't-appz Apple Pay',
|
| 863 |
);
|
|
|
|
| 864 |
$field_string = http_build_query($fields);
|
| 865 |
$charge = array();
|
| 866 |
try {
|
| 885 |
} catch (Exception $e) {
|
| 886 |
$this->_fault('invalid_data', $e->getMessage());
|
| 887 |
}
|
|
|
|
|
|
|
|
|
|
| 888 |
if ($charge['captured']) {
|
| 889 |
$paymentData = array();
|
| 890 |
$paymentData['method'] = 'ApplePay';
|
| 901 |
public function getTaksitSecenekleri($quoteId)
|
| 902 |
{
|
| 903 |
$bankInfos = array();
|
|
|
|
| 904 |
$exclude_cats = array(219, 218, 527, 217, 651, 329, 331, 678);
|
| 905 |
$show_taksits = true;
|
| 906 |
$cats = array();
|
| 907 |
$cart = Mage::getModel("sales/quote")->load($quoteId);
|
| 908 |
$cartItems = $cart->getItems();
|
| 909 |
$tutar = $cart->getGrandTotal();
|
|
|
|
| 910 |
foreach ($cartItems as $item) {
|
| 911 |
$cats[] = $item->getProduct()->getCategoryIds();
|
| 912 |
}
|
| 919 |
}
|
| 920 |
}
|
| 921 |
}
|
|
|
|
| 922 |
$turkpay = Mage::getModel('Grinet_Turkpay_Model_Grinet');
|
| 923 |
if ($turkpay) {
|
| 924 |
$bank_avs = $turkpay->bankalar();
|
| 927 |
$bankCount = 0;
|
| 928 |
$fark = 0;
|
| 929 |
foreach ($bank_avs as $bank_code => $bank) {
|
|
|
|
|
|
|
|
|
|
| 930 |
$tdata = $turkpay->taksitler($bank_code, $tutar);
|
| 931 |
$valCount = 0;
|
| 932 |
foreach ($tdata as $tay => $toran) {
|
|
|
|
| 933 |
$toplam_tutar = $tutar + (($tutar / 100) * floatval($toran)) + $fark;// - ( ( $fark / 100 ) * floatval($toran) ) ;
|
|
|
|
| 934 |
$custom_title = Mage::getStoreConfig($bank_code . '/taksit_baslik/taksit_' . $tay);
|
| 935 |
if (trim($custom_title) == '')
|
| 936 |
$taksit_title = 'Tek Çekim';
|
| 955 |
if ($taksit_title == "Tek Çekim")
|
| 956 |
break;
|
| 957 |
}
|
|
|
|
| 958 |
$valCount++;
|
| 959 |
}
|
| 960 |
$bankCount++;
|
| 964 |
return $bankInfos;
|
| 965 |
}
|
| 966 |
|
| 967 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
| 968 |
+
/* @var $product Mage_Catalog_Model_Product */
|
| 969 |
+
|
| 970 |
public function getSupplyDate($quoteId)
|
| 971 |
{
|
| 972 |
$store = Mage::getStoreConfig('tappz/general/store');
|
| 973 |
$productAverageDeliveryDaysAttributeCode = Mage::getStoreConfig('tappz/basket/averagedeliverydaysattributecode');
|
|
|
|
|
|
|
| 974 |
$quote = Mage::getModel("sales/quote")
|
| 975 |
->setStoreId($store)
|
| 976 |
->load($quoteId);
|
|
|
|
| 977 |
$set_message = array();
|
| 978 |
foreach ($quote->getAllItems() as $item) {
|
| 979 |
$product = Mage::getModel('catalog/product')->load($item->getData('product_id'));
|
|
|
|
| 980 |
$message = $product->getData($productAverageDeliveryDaysAttributeCode);
|
| 981 |
if ($message)
|
| 982 |
$set_message[] = $message;
|
| 983 |
}
|
|
|
|
| 984 |
$set_message_unique = array_unique($set_message);
|
|
|
|
| 985 |
$by_0 = false;
|
| 986 |
$by_3 = false;
|
| 987 |
$by_4 = false;
|
app/code/community/TmobLabs/Tappz/Model/Catalog/Api.php
CHANGED
|
@@ -5,25 +5,9 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 5 |
public function getFrontPage()
|
| 6 |
{
|
| 7 |
$sampleEx['ads'][0]['name'] = null;
|
| 8 |
-
$sampleEx['ads'][0]['image'] =
|
| 9 |
-
$sampleEx['ads'][0]['type'] =
|
| 10 |
-
$sampleEx['ads'][0]['value'] =
|
| 11 |
-
|
| 12 |
-
$sampleEx['ads'][1]['name'] = null;
|
| 13 |
-
$sampleEx['ads'][1]['image'] = Mage::getBaseUrl('media') . 'tappz/' . Mage::getStoreConfig('tappz/catalog/bannerImage2');
|
| 14 |
-
$sampleEx['ads'][1]['type'] = Mage::getStoreConfig('tappz/catalog/bannerActionType2');
|
| 15 |
-
$sampleEx['ads'][1]['value'] = Mage::getStoreConfig('tappz/catalog/bannerActionValue2');
|
| 16 |
-
|
| 17 |
-
$sampleEx['ads'][2]['name'] = null;
|
| 18 |
-
$sampleEx['ads'][2]['image'] = Mage::getBaseUrl('media') . 'tappz/' . Mage::getStoreConfig('tappz/catalog/bannerImage3');
|
| 19 |
-
$sampleEx['ads'][2]['type'] = Mage::getStoreConfig('tappz/catalog/bannerActionType3');
|
| 20 |
-
$sampleEx['ads'][2]['value'] = Mage::getStoreConfig('tappz/catalog/bannerActionValue3');
|
| 21 |
-
|
| 22 |
-
$sampleEx['ads'][3]['name'] = null;
|
| 23 |
-
$sampleEx['ads'][3]['image'] = Mage::getBaseUrl('media') . 'tappz/' . Mage::getStoreConfig('tappz/catalog/bannerImage4');
|
| 24 |
-
$sampleEx['ads'][3]['type'] = Mage::getStoreConfig('tappz/catalog/bannerActionType4');
|
| 25 |
-
$sampleEx['ads'][3]['value'] = Mage::getStoreConfig('tappz/catalog/bannerActionValue4');
|
| 26 |
-
|
| 27 |
$frontPageCategory1 = Mage::getStoreConfig('tappz/catalog/catalog1');
|
| 28 |
if ($frontPageCategory1) {
|
| 29 |
$category = $this->getCategory($frontPageCategory1);
|
|
@@ -33,7 +17,6 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 33 |
$group['products'] = $productList['products'];
|
| 34 |
$sampleEx['groups'][] = $group;
|
| 35 |
}
|
| 36 |
-
|
| 37 |
$frontPageCategory2 = Mage::getStoreConfig('tappz/catalog/catalog2');
|
| 38 |
if ($frontPageCategory2) {
|
| 39 |
$category = $this->getCategory($frontPageCategory2);
|
|
@@ -43,7 +26,6 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 43 |
$group['products'] = $productList['products'];
|
| 44 |
$sampleEx['groups'][] = $group;
|
| 45 |
}
|
| 46 |
-
|
| 47 |
$frontPageCategory3 = Mage::getStoreConfig('tappz/catalog/catalog3');
|
| 48 |
if ($frontPageCategory3) {
|
| 49 |
$category = $this->getCategory($frontPageCategory3);
|
|
@@ -53,7 +35,6 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 53 |
$group['products'] = $productList['products'];
|
| 54 |
$sampleEx['groups'][] = $group;
|
| 55 |
}
|
| 56 |
-
|
| 57 |
$frontPageCategory4 = Mage::getStoreConfig('tappz/catalog/catalog4');
|
| 58 |
if ($frontPageCategory4) {
|
| 59 |
$category = $this->getCategory($frontPageCategory4);
|
|
@@ -63,7 +44,6 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 63 |
$group['products'] = $productList['products'];
|
| 64 |
$sampleEx['groups'][] = $group;
|
| 65 |
}
|
| 66 |
-
|
| 67 |
return $sampleEx;
|
| 68 |
}
|
| 69 |
|
|
@@ -73,7 +53,7 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 73 |
if ($storeId <= 0) {
|
| 74 |
$storeId = 1;
|
| 75 |
}
|
| 76 |
-
|
| 77 |
/** @var Mage_Core_Model_Store $store */
|
| 78 |
$store = Mage::getModel('core/store')->load($storeId);
|
| 79 |
|
|
@@ -84,27 +64,21 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 84 |
$rootCategory = $this->getCategory($rootCategoryId);
|
| 85 |
return $rootCategory['children'];
|
| 86 |
}
|
| 87 |
-
|
| 88 |
public function getCategory($categoryId)
|
| 89 |
{
|
| 90 |
$storeId = Mage::getStoreConfig('tappz/general/store');
|
| 91 |
-
/* @var $tree Mage_Catalog_Model_Resource_Category_Tree */
|
| 92 |
$tree = Mage::getResourceSingleton('catalog/category_tree')
|
| 93 |
->load();
|
| 94 |
-
|
| 95 |
-
/** @var Mage_Catalog_Model_Category $root */
|
| 96 |
$root = $tree->getNodeById($categoryId);
|
| 97 |
-
|
| 98 |
if ($root && $root->getId() == 1) {
|
| 99 |
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 100 |
}
|
| 101 |
-
|
| 102 |
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 103 |
->setStoreId($this->_getStoreId($storeId))
|
| 104 |
->addAttributeToSelect('name')
|
| 105 |
->addAttributeToSelect('is_active')
|
| 106 |
-
->addIsActiveFilter();
|
| 107 |
|
|
|
|
| 108 |
$tree->addCollectionData($collection, true);
|
| 109 |
return $this->categoryToModel($root);
|
| 110 |
}
|
|
@@ -158,15 +132,15 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 158 |
$collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left');
|
| 159 |
$collection->addAttributeToFilter('category_id', array('eq' => $categoryId));
|
| 160 |
}
|
| 161 |
-
|
| 162 |
$total = $collection->getSize();
|
| 163 |
if (!empty($sort)) {
|
| 164 |
$sortArr = explode("-", $sort);
|
| 165 |
$collection->addAttributeToSort($sortArr[0], $sortArr[1]);
|
| 166 |
}
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
if (empty($pageNumber))
|
| 169 |
-
$pageNumber = 0;
|
| 170 |
if (empty($pageSize))
|
| 171 |
$pageSize = 6;
|
| 172 |
|
|
@@ -177,37 +151,11 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 177 |
$result['filters'] = array();
|
| 178 |
$result['sortList'] = array();
|
| 179 |
$result['products'] = array();
|
| 180 |
-
|
| 181 |
$result['total'] = $total;
|
| 182 |
-
|
| 183 |
-
// TODO : mcgoncu - filter ekle
|
| 184 |
-
// $attributeCodeList = array('manufacturer');
|
| 185 |
-
// foreach ($attributeCodeList as $attributeCode) {
|
| 186 |
-
// $attribute = Mage::getModel('eav/entity_attribute')
|
| 187 |
-
// ->loadByCode('catalog_product', $attributeCode);
|
| 188 |
-
//
|
| 189 |
-
// $attributeOptionList = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
| 190 |
-
// ->setAttributeFilter($attribute->getData('attribute_id'));
|
| 191 |
-
//
|
| 192 |
-
// $group = array();
|
| 193 |
-
// $group['id'] = $attribute['code'];
|
| 194 |
-
// $group['name'] = $attribute['label'];
|
| 195 |
-
// $group['selected'] = ''; // TODO set selected
|
| 196 |
-
// $group['values'] = array();
|
| 197 |
-
// foreach ($attributeOptionList as $attributeOption) {
|
| 198 |
-
// $feature = array();
|
| 199 |
-
// $feature['id'] = $attributeOption['value'];
|
| 200 |
-
// $feature['name'] = $attributeOption['label'];
|
| 201 |
-
// $group['values'][] = $feature;
|
| 202 |
-
// }
|
| 203 |
-
// $result['filters'][] = $group;
|
| 204 |
-
// }
|
| 205 |
-
|
| 206 |
$result['sortList'][] = array('id' => 'name-asc', 'name' => 'Name (Ascending)');
|
| 207 |
$result['sortList'][] = array('id' => 'name-desc', 'name' => 'Name (Descending)');
|
| 208 |
$result['sortList'][] = array('id' => 'price-asc', 'name' => 'Price (Ascending)');
|
| 209 |
$result['sortList'][] = array('id' => 'price-desc', 'name' => 'Price (Descending)');
|
| 210 |
-
|
| 211 |
if (!empty($collection)) {
|
| 212 |
foreach ($collection as $_product) {
|
| 213 |
$result['products'][] = $this->getProduct($_product->getId());
|
|
@@ -215,20 +163,14 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 215 |
}
|
| 216 |
return $result;
|
| 217 |
}
|
| 218 |
-
|
| 219 |
public function getProduct($productId)
|
| 220 |
{
|
| 221 |
$storeId = (int)Mage::getStoreConfig('tappz/general/store');
|
| 222 |
if ($storeId <= 0) {
|
| 223 |
$storeId = 1;
|
| 224 |
}
|
| 225 |
-
|
| 226 |
-
/** @var Mage_Core_Model_Store $store */
|
| 227 |
-
$store = Mage::getModel('core/store')->load($storeId);
|
| 228 |
-
|
| 229 |
-
/** @var Mage_Catalog_Model_Product $product */
|
| 230 |
$product = Mage::getModel('catalog/product')->load($productId);
|
| 231 |
-
|
| 232 |
$productInfo = array();
|
| 233 |
$productInfo['id'] = null;
|
| 234 |
$productInfo['productName'] = null;
|
|
@@ -252,10 +194,8 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 252 |
$productInfo['variants'] = array();
|
| 253 |
$productInfo['shipmentInformation'] = null;
|
| 254 |
$productInfo['actions'] = array();
|
| 255 |
-
|
| 256 |
$productInfo['id'] = $product->getId();
|
| 257 |
$productInfo['productName'] = $product->getName();
|
| 258 |
-
|
| 259 |
$specialPrice = sprintf("%0.2f", $product->getData('special_price'));
|
| 260 |
$listPrice = sprintf("%0.2f", $product->getPrice());
|
| 261 |
$productInfo['listPrice'] = array();
|
|
@@ -266,16 +206,13 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 266 |
$productInfo['strikeoutPrice']['amount'] = $specialPrice > 0 ? $listPrice : 0;
|
| 267 |
$productInfo['strikeoutPrice']['amountDefaultCurrency'] = '';
|
| 268 |
$productInfo['strikeoutPrice']['currency'] = $store->getCurrentCurrencyCode();
|
| 269 |
-
|
| 270 |
if ($specialPrice > 0) {
|
| 271 |
$actionDiscount = array();
|
| 272 |
$actionDiscount['id'] = 'discount';
|
| 273 |
$actionDiscount['name'] = sprintf("%d%%", (($listPrice - $specialPrice) / $listPrice) * 100);
|
| 274 |
$productInfo['actions'][] = $actionDiscount;
|
| 275 |
}
|
| 276 |
-
|
| 277 |
-
$productInfo['picture'] = Mage::helper('catalog/image')->init($product, 'small_image')->resize(450, 450);
|
| 278 |
-
|
| 279 |
$mediaGallery = $product->getMediaGalleryImages();
|
| 280 |
if (count($mediaGallery) > 0) {
|
| 281 |
foreach ($mediaGallery as $mediaGal) {
|
|
@@ -299,39 +236,30 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 299 |
$productAttributeCodeIsShippingFree = Mage::getStoreConfig('tappz/catalog/productAttributeCodeShippingInfo');
|
| 300 |
$productInfo['isShipmentFree'] = $product->getData($productAttributeCodeIsShippingFree);
|
| 301 |
$productInfo['productUrl'] = $product->getProductUrl();
|
| 302 |
-
|
| 303 |
if ($productInfo['isShipmentFree']) {
|
| 304 |
$action = array();
|
| 305 |
$action['id'] = 'popper';
|
| 306 |
$action['name'] = 'Free Shipping';
|
| 307 |
$productInfo['actions'][] = $action;
|
| 308 |
}
|
| 309 |
-
|
| 310 |
-
//variants
|
| 311 |
$productType = $product->getTypeId();;
|
| 312 |
if ($productType == 'configurable') {
|
| 313 |
$instanceConf = $product->getTypeInstance();
|
| 314 |
$configurableAttributesData = $instanceConf->getConfigurableAttributesAsArray();
|
| 315 |
-
|
| 316 |
foreach ($configurableAttributesData as $dt => $val) {
|
| 317 |
$group = array();
|
| 318 |
$group['id'] = null;
|
| 319 |
$group['name'] = null;
|
| 320 |
$group['selected'] = null;
|
| 321 |
$group['values'] = array();
|
| 322 |
-
|
| 323 |
$group['id'] = $val['attribute_code'];
|
| 324 |
$group['name'] = $val['label'];
|
| 325 |
-
|
| 326 |
-
// TODO : mcgoncu - annelutfen icin ekle
|
| 327 |
if ($val['attribute_code'] == 'beden')
|
| 328 |
$productInfo['additionalDetail'] = "<a href=\"http://annelutfen.com/skin/frontend/purple/purple/images/olcu_tablosu_gri.png\">Ölçü tablosu</a>";
|
| 329 |
-
|
| 330 |
foreach ($val['values'] as $vv) {
|
| 331 |
$groupValue = array();
|
| 332 |
$groupValue['id'] = null;
|
| 333 |
$groupValue['name'] = null;
|
| 334 |
-
|
| 335 |
$groupValue['id'] = $vv['label'];
|
| 336 |
$groupValue['name'] = $vv['value_index'];
|
| 337 |
$group['values'][] = $groupValue;
|
|
@@ -339,10 +267,8 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 339 |
$productInfo['variants'][] = $group;
|
| 340 |
}
|
| 341 |
}
|
| 342 |
-
|
| 343 |
$productAttributeCodeShippingInfo = Mage::getStoreConfig('tappz/catalog/productAttributeCodeShippingInfo');
|
| 344 |
$productInfo['shipmentInformation'] = $product->getData($productAttributeCodeShippingInfo);
|
| 345 |
-
|
| 346 |
return $productInfo;
|
| 347 |
}
|
| 348 |
|
|
@@ -351,36 +277,29 @@ class TmobLabs_Tappz_Model_Catalog_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 351 |
$product = Mage::getModel('catalog/product')->load($productId);
|
| 352 |
$link = $product->getLinkInstance()
|
| 353 |
->setLinkTypeId(Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED);
|
| 354 |
-
|
| 355 |
$collection = $link
|
| 356 |
->getProductCollection()
|
| 357 |
->setIsStrongMode()
|
| 358 |
->setProduct($product);
|
| 359 |
-
|
| 360 |
$arData = array();
|
| 361 |
if (!empty($collection)) {
|
| 362 |
foreach ($collection as $_product):
|
| 363 |
array_push($arData, $this->getProduct($_product->getId()));
|
| 364 |
endforeach;
|
| 365 |
}
|
| 366 |
-
|
| 367 |
return $arData;
|
| 368 |
}
|
| 369 |
-
|
| 370 |
public function getChildProductId($parentProductId, $attributeList)
|
| 371 |
{
|
| 372 |
$subProductIds = Mage::getModel('catalog/product_type_configurable')
|
| 373 |
->getChildrenIds($parentProductId); //get the children ids through a simple query
|
| 374 |
$subProducts = Mage::getModel('catalog/product')->getCollection()
|
| 375 |
->addAttributeToFilter('entity_id', $subProductIds);
|
| 376 |
-
|
| 377 |
foreach ($attributeList as $attribute) {
|
| 378 |
$attributeCode = $attribute->id;
|
| 379 |
$attributeValueIndex = $attribute->values[0]->id;
|
| 380 |
-
|
| 381 |
$subProducts->addAttributeToFilter($attributeCode, $attributeValueIndex);
|
| 382 |
}
|
| 383 |
-
|
| 384 |
$product = null;
|
| 385 |
if ($subProducts->getSize() > 0) {
|
| 386 |
$product = $subProducts->getFirstItem();
|
| 5 |
public function getFrontPage()
|
| 6 |
{
|
| 7 |
$sampleEx['ads'][0]['name'] = null;
|
| 8 |
+
$sampleEx['ads'][0]['image'] ="";
|
| 9 |
+
$sampleEx['ads'][0]['type'] ="";
|
| 10 |
+
$sampleEx['ads'][0]['value'] = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
$frontPageCategory1 = Mage::getStoreConfig('tappz/catalog/catalog1');
|
| 12 |
if ($frontPageCategory1) {
|
| 13 |
$category = $this->getCategory($frontPageCategory1);
|
| 17 |
$group['products'] = $productList['products'];
|
| 18 |
$sampleEx['groups'][] = $group;
|
| 19 |
}
|
|
|
|
| 20 |
$frontPageCategory2 = Mage::getStoreConfig('tappz/catalog/catalog2');
|
| 21 |
if ($frontPageCategory2) {
|
| 22 |
$category = $this->getCategory($frontPageCategory2);
|
| 26 |
$group['products'] = $productList['products'];
|
| 27 |
$sampleEx['groups'][] = $group;
|
| 28 |
}
|
|
|
|
| 29 |
$frontPageCategory3 = Mage::getStoreConfig('tappz/catalog/catalog3');
|
| 30 |
if ($frontPageCategory3) {
|
| 31 |
$category = $this->getCategory($frontPageCategory3);
|
| 35 |
$group['products'] = $productList['products'];
|
| 36 |
$sampleEx['groups'][] = $group;
|
| 37 |
}
|
|
|
|
| 38 |
$frontPageCategory4 = Mage::getStoreConfig('tappz/catalog/catalog4');
|
| 39 |
if ($frontPageCategory4) {
|
| 40 |
$category = $this->getCategory($frontPageCategory4);
|
| 44 |
$group['products'] = $productList['products'];
|
| 45 |
$sampleEx['groups'][] = $group;
|
| 46 |
}
|
|
|
|
| 47 |
return $sampleEx;
|
| 48 |
}
|
| 49 |
|
| 53 |
if ($storeId <= 0) {
|
| 54 |
$storeId = 1;
|
| 55 |
}
|
| 56 |
+
|
| 57 |
/** @var Mage_Core_Model_Store $store */
|
| 58 |
$store = Mage::getModel('core/store')->load($storeId);
|
| 59 |
|
| 64 |
$rootCategory = $this->getCategory($rootCategoryId);
|
| 65 |
return $rootCategory['children'];
|
| 66 |
}
|
|
|
|
| 67 |
public function getCategory($categoryId)
|
| 68 |
{
|
| 69 |
$storeId = Mage::getStoreConfig('tappz/general/store');
|
|
|
|
| 70 |
$tree = Mage::getResourceSingleton('catalog/category_tree')
|
| 71 |
->load();
|
|
|
|
|
|
|
| 72 |
$root = $tree->getNodeById($categoryId);
|
|
|
|
| 73 |
if ($root && $root->getId() == 1) {
|
| 74 |
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 75 |
}
|
|
|
|
| 76 |
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 77 |
->setStoreId($this->_getStoreId($storeId))
|
| 78 |
->addAttributeToSelect('name')
|
| 79 |
->addAttributeToSelect('is_active')
|
|
|
|
| 80 |
|
| 81 |
+
->addIsActiveFilter();
|
| 82 |
$tree->addCollectionData($collection, true);
|
| 83 |
return $this->categoryToModel($root);
|
| 84 |
}
|
| 132 |
$collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left');
|
| 133 |
$collection->addAttributeToFilter('category_id', array('eq' => $categoryId));
|
| 134 |
}
|
| 135 |
+
|
| 136 |
$total = $collection->getSize();
|
| 137 |
if (!empty($sort)) {
|
| 138 |
$sortArr = explode("-", $sort);
|
| 139 |
$collection->addAttributeToSort($sortArr[0], $sortArr[1]);
|
| 140 |
}
|
| 141 |
+
$pageSize = 5;
|
| 142 |
+
empty($pageNumber) ? $pageNumber = 1 : $pageNumber +=1;
|
| 143 |
|
|
|
|
|
|
|
| 144 |
if (empty($pageSize))
|
| 145 |
$pageSize = 6;
|
| 146 |
|
| 151 |
$result['filters'] = array();
|
| 152 |
$result['sortList'] = array();
|
| 153 |
$result['products'] = array();
|
|
|
|
| 154 |
$result['total'] = $total;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
$result['sortList'][] = array('id' => 'name-asc', 'name' => 'Name (Ascending)');
|
| 156 |
$result['sortList'][] = array('id' => 'name-desc', 'name' => 'Name (Descending)');
|
| 157 |
$result['sortList'][] = array('id' => 'price-asc', 'name' => 'Price (Ascending)');
|
| 158 |
$result['sortList'][] = array('id' => 'price-desc', 'name' => 'Price (Descending)');
|
|
|
|
| 159 |
if (!empty($collection)) {
|
| 160 |
foreach ($collection as $_product) {
|
| 161 |
$result['products'][] = $this->getProduct($_product->getId());
|
| 163 |
}
|
| 164 |
return $result;
|
| 165 |
}
|
|
|
|
| 166 |
public function getProduct($productId)
|
| 167 |
{
|
| 168 |
$storeId = (int)Mage::getStoreConfig('tappz/general/store');
|
| 169 |
if ($storeId <= 0) {
|
| 170 |
$storeId = 1;
|
| 171 |
}
|
| 172 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
$product = Mage::getModel('catalog/product')->load($productId);
|
|
|
|
| 174 |
$productInfo = array();
|
| 175 |
$productInfo['id'] = null;
|
| 176 |
$productInfo['productName'] = null;
|
| 194 |
$productInfo['variants'] = array();
|
| 195 |
$productInfo['shipmentInformation'] = null;
|
| 196 |
$productInfo['actions'] = array();
|
|
|
|
| 197 |
$productInfo['id'] = $product->getId();
|
| 198 |
$productInfo['productName'] = $product->getName();
|
|
|
|
| 199 |
$specialPrice = sprintf("%0.2f", $product->getData('special_price'));
|
| 200 |
$listPrice = sprintf("%0.2f", $product->getPrice());
|
| 201 |
$productInfo['listPrice'] = array();
|
| 206 |
$productInfo['strikeoutPrice']['amount'] = $specialPrice > 0 ? $listPrice : 0;
|
| 207 |
$productInfo['strikeoutPrice']['amountDefaultCurrency'] = '';
|
| 208 |
$productInfo['strikeoutPrice']['currency'] = $store->getCurrentCurrencyCode();
|
|
|
|
| 209 |
if ($specialPrice > 0) {
|
| 210 |
$actionDiscount = array();
|
| 211 |
$actionDiscount['id'] = 'discount';
|
| 212 |
$actionDiscount['name'] = sprintf("%d%%", (($listPrice - $specialPrice) / $listPrice) * 100);
|
| 213 |
$productInfo['actions'][] = $actionDiscount;
|
| 214 |
}
|
| 215 |
+
$productInfo['picture'] = $product->getImageUrl();
|
|
|
|
|
|
|
| 216 |
$mediaGallery = $product->getMediaGalleryImages();
|
| 217 |
if (count($mediaGallery) > 0) {
|
| 218 |
foreach ($mediaGallery as $mediaGal) {
|
| 236 |
$productAttributeCodeIsShippingFree = Mage::getStoreConfig('tappz/catalog/productAttributeCodeShippingInfo');
|
| 237 |
$productInfo['isShipmentFree'] = $product->getData($productAttributeCodeIsShippingFree);
|
| 238 |
$productInfo['productUrl'] = $product->getProductUrl();
|
|
|
|
| 239 |
if ($productInfo['isShipmentFree']) {
|
| 240 |
$action = array();
|
| 241 |
$action['id'] = 'popper';
|
| 242 |
$action['name'] = 'Free Shipping';
|
| 243 |
$productInfo['actions'][] = $action;
|
| 244 |
}
|
|
|
|
|
|
|
| 245 |
$productType = $product->getTypeId();;
|
| 246 |
if ($productType == 'configurable') {
|
| 247 |
$instanceConf = $product->getTypeInstance();
|
| 248 |
$configurableAttributesData = $instanceConf->getConfigurableAttributesAsArray();
|
|
|
|
| 249 |
foreach ($configurableAttributesData as $dt => $val) {
|
| 250 |
$group = array();
|
| 251 |
$group['id'] = null;
|
| 252 |
$group['name'] = null;
|
| 253 |
$group['selected'] = null;
|
| 254 |
$group['values'] = array();
|
|
|
|
| 255 |
$group['id'] = $val['attribute_code'];
|
| 256 |
$group['name'] = $val['label'];
|
|
|
|
|
|
|
| 257 |
if ($val['attribute_code'] == 'beden')
|
| 258 |
$productInfo['additionalDetail'] = "<a href=\"http://annelutfen.com/skin/frontend/purple/purple/images/olcu_tablosu_gri.png\">Ölçü tablosu</a>";
|
|
|
|
| 259 |
foreach ($val['values'] as $vv) {
|
| 260 |
$groupValue = array();
|
| 261 |
$groupValue['id'] = null;
|
| 262 |
$groupValue['name'] = null;
|
|
|
|
| 263 |
$groupValue['id'] = $vv['label'];
|
| 264 |
$groupValue['name'] = $vv['value_index'];
|
| 265 |
$group['values'][] = $groupValue;
|
| 267 |
$productInfo['variants'][] = $group;
|
| 268 |
}
|
| 269 |
}
|
|
|
|
| 270 |
$productAttributeCodeShippingInfo = Mage::getStoreConfig('tappz/catalog/productAttributeCodeShippingInfo');
|
| 271 |
$productInfo['shipmentInformation'] = $product->getData($productAttributeCodeShippingInfo);
|
|
|
|
| 272 |
return $productInfo;
|
| 273 |
}
|
| 274 |
|
| 277 |
$product = Mage::getModel('catalog/product')->load($productId);
|
| 278 |
$link = $product->getLinkInstance()
|
| 279 |
->setLinkTypeId(Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED);
|
|
|
|
| 280 |
$collection = $link
|
| 281 |
->getProductCollection()
|
| 282 |
->setIsStrongMode()
|
| 283 |
->setProduct($product);
|
|
|
|
| 284 |
$arData = array();
|
| 285 |
if (!empty($collection)) {
|
| 286 |
foreach ($collection as $_product):
|
| 287 |
array_push($arData, $this->getProduct($_product->getId()));
|
| 288 |
endforeach;
|
| 289 |
}
|
|
|
|
| 290 |
return $arData;
|
| 291 |
}
|
|
|
|
| 292 |
public function getChildProductId($parentProductId, $attributeList)
|
| 293 |
{
|
| 294 |
$subProductIds = Mage::getModel('catalog/product_type_configurable')
|
| 295 |
->getChildrenIds($parentProductId); //get the children ids through a simple query
|
| 296 |
$subProducts = Mage::getModel('catalog/product')->getCollection()
|
| 297 |
->addAttributeToFilter('entity_id', $subProductIds);
|
|
|
|
| 298 |
foreach ($attributeList as $attribute) {
|
| 299 |
$attributeCode = $attribute->id;
|
| 300 |
$attributeValueIndex = $attribute->values[0]->id;
|
|
|
|
| 301 |
$subProducts->addAttributeToFilter($attributeCode, $attributeValueIndex);
|
| 302 |
}
|
|
|
|
| 303 |
$product = null;
|
| 304 |
if ($subProducts->getSize() > 0) {
|
| 305 |
$product = $subProducts->getFirstItem();
|
app/code/community/TmobLabs/Tappz/Model/Customer/Address/Api.php
CHANGED
|
@@ -16,7 +16,6 @@ class TmobLabs_Tappz_Model_Customer_Address_Api extends Mage_Api_Model_Resource_
|
|
| 16 |
public function getList($customerId)
|
| 17 |
{
|
| 18 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 19 |
-
/* @var $customer Mage_Customer_Model_Customer */
|
| 20 |
if (!$customer) {
|
| 21 |
$this->_fault("404.10", "Customer is not found.");
|
| 22 |
}
|
| 16 |
public function getList($customerId)
|
| 17 |
{
|
| 18 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
|
|
|
| 19 |
if (!$customer) {
|
| 20 |
$this->_fault("404.10", "Customer is not found.");
|
| 21 |
}
|
app/code/community/TmobLabs/Tappz/Model/Customer/Api.php
CHANGED
|
@@ -8,7 +8,6 @@ class TmobLabs_Tappz_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
|
|
| 8 |
$emailAttributeCode = Mage::getStoreConfig('tappz/customer/email');
|
| 9 |
$phoneAttributeCode = Mage::getStoreConfig('tappz/customer/phone');
|
| 10 |
$birthDateAttributeCode = Mage::getStoreConfig('tappz/customer/birthDate');
|
| 11 |
-
|
| 12 |
$result = array();
|
| 13 |
$result['entity_id'] = $data->customerId;
|
| 14 |
$result['firstname'] = $data->firstName;
|
|
@@ -19,7 +18,6 @@ class TmobLabs_Tappz_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
|
|
| 19 |
$result[$emailAttributeCode] = $data->email;
|
| 20 |
$result[$phoneAttributeCode] = $data->phone;
|
| 21 |
$result[$birthDateAttributeCode] = $data->birthDate;
|
| 22 |
-
|
| 23 |
return $result;
|
| 24 |
}
|
| 25 |
|
|
@@ -29,13 +27,10 @@ class TmobLabs_Tappz_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
|
|
| 29 |
$emailAttributeCode = Mage::getStoreConfig('tappz/customer/email');
|
| 30 |
$phoneAttributeCode = Mage::getStoreConfig('tappz/customer/phone');
|
| 31 |
$birthDateAttributeCode = Mage::getStoreConfig('tappz/customer/birthDate');
|
| 32 |
-
|
| 33 |
-
/* @var $customer Mage_Customer_Model_Customer */
|
| 34 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 35 |
if (!$customer) {
|
| 36 |
$this->_fault("404.10", "Customer is not found.");
|
| 37 |
}
|
| 38 |
-
|
| 39 |
$result = array();
|
| 40 |
$result['customerId'] = "";
|
| 41 |
$result['fullName'] = "";
|
|
@@ -51,7 +46,6 @@ class TmobLabs_Tappz_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
|
|
| 51 |
$result['points'] = 0;
|
| 52 |
$result['addresses'] = array();
|
| 53 |
$result['giftCheques'] = array();
|
| 54 |
-
|
| 55 |
$result['customerId'] = $customer->getId();
|
| 56 |
$result['fullName'] = $customer->getName();
|
| 57 |
$result['firstName'] = $customer->getFirstname() . ($customer->getMiddleName() ? (' ' . $customer->getMiddleName()) : '');
|
|
@@ -77,7 +71,7 @@ class TmobLabs_Tappz_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
|
|
| 77 |
$result['addresses'] = Mage::getSingleton('tappz/customer_address_api')->getList($customer->getId()); /// ??????
|
| 78 |
|
| 79 |
$result['giftCheques'] = array();
|
| 80 |
-
|
| 81 |
return $result;
|
| 82 |
}
|
| 83 |
|
| 8 |
$emailAttributeCode = Mage::getStoreConfig('tappz/customer/email');
|
| 9 |
$phoneAttributeCode = Mage::getStoreConfig('tappz/customer/phone');
|
| 10 |
$birthDateAttributeCode = Mage::getStoreConfig('tappz/customer/birthDate');
|
|
|
|
| 11 |
$result = array();
|
| 12 |
$result['entity_id'] = $data->customerId;
|
| 13 |
$result['firstname'] = $data->firstName;
|
| 18 |
$result[$emailAttributeCode] = $data->email;
|
| 19 |
$result[$phoneAttributeCode] = $data->phone;
|
| 20 |
$result[$birthDateAttributeCode] = $data->birthDate;
|
|
|
|
| 21 |
return $result;
|
| 22 |
}
|
| 23 |
|
| 27 |
$emailAttributeCode = Mage::getStoreConfig('tappz/customer/email');
|
| 28 |
$phoneAttributeCode = Mage::getStoreConfig('tappz/customer/phone');
|
| 29 |
$birthDateAttributeCode = Mage::getStoreConfig('tappz/customer/birthDate');
|
|
|
|
|
|
|
| 30 |
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 31 |
if (!$customer) {
|
| 32 |
$this->_fault("404.10", "Customer is not found.");
|
| 33 |
}
|
|
|
|
| 34 |
$result = array();
|
| 35 |
$result['customerId'] = "";
|
| 36 |
$result['fullName'] = "";
|
| 46 |
$result['points'] = 0;
|
| 47 |
$result['addresses'] = array();
|
| 48 |
$result['giftCheques'] = array();
|
|
|
|
| 49 |
$result['customerId'] = $customer->getId();
|
| 50 |
$result['fullName'] = $customer->getName();
|
| 51 |
$result['firstName'] = $customer->getFirstname() . ($customer->getMiddleName() ? (' ' . $customer->getMiddleName()) : '');
|
| 71 |
$result['addresses'] = Mage::getSingleton('tappz/customer_address_api')->getList($customer->getId()); /// ??????
|
| 72 |
|
| 73 |
$result['giftCheques'] = array();
|
| 74 |
+
|
| 75 |
return $result;
|
| 76 |
}
|
| 77 |
|
app/code/community/TmobLabs/Tappz/Model/Customer/Order/Api.php
CHANGED
|
@@ -28,29 +28,19 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 28 |
public function info($orderId)
|
| 29 |
{
|
| 30 |
$order = Mage::getModel('sales/order');
|
| 31 |
-
|
| 32 |
-
/* @var $order Mage_Sales_Model_Order */
|
| 33 |
-
|
| 34 |
$order->loadByIncrementId($orderId);
|
| 35 |
-
|
| 36 |
if (!$order->getId()) {
|
| 37 |
$this->_fault('not_exists');
|
| 38 |
}
|
| 39 |
-
|
| 40 |
$result = $this->_getAttributes($order, 'order');
|
| 41 |
-
/** @var $addressApi TmobLabs_Tappz_Model_Customer_Address_Api */
|
| 42 |
$addressApi = Mage::getSingleton('tappz/Customer_Address_Api');
|
| 43 |
-
|
| 44 |
-
|
| 45 |
$result['items'] = array();
|
| 46 |
-
|
| 47 |
foreach ($order->getAllItems() as $item) {
|
| 48 |
if ($item->getGiftMessageId() > 0) {
|
| 49 |
$item->setGiftMessage(
|
| 50 |
Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
|
| 51 |
);
|
| 52 |
}
|
| 53 |
-
|
| 54 |
$result['items'][] = $this->_getAttributes($item, 'order_item');
|
| 55 |
}
|
| 56 |
|
|
@@ -74,7 +64,6 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 74 |
$thousandDivider = Mage::getStoreConfig('tappz/general/groupSeparator');
|
| 75 |
$lineAverageDeliveryDaysAttributeCode = Mage::getStoreConfig('tappz/basket/averagedeliverydaysattributecode');
|
| 76 |
$catalogApi = Mage::getSingleton('tappz/Catalog_Api');
|
| 77 |
-
|
| 78 |
$result = array();
|
| 79 |
$result['id'] = null;
|
| 80 |
$result['currency'] = null;
|
|
@@ -102,7 +91,6 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 102 |
$result['payment']['cashOnDelivery'] = null;
|
| 103 |
$result['payment']['creditCard'] = null;
|
| 104 |
$result['lines'] = array();
|
| 105 |
-
|
| 106 |
$result['id'] = $order['increment_id'];
|
| 107 |
$result['orderDate'] = date_format(date_create($order['created_at']), 'd/m/Y');
|
| 108 |
$result['shippingStatus'] = $order['status'];
|
|
@@ -115,10 +103,9 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 115 |
$result['delivery']['shippingMethod']['id'] = $order['shipping_method'];
|
| 116 |
$result['delivery']['shippingMethod']['displayName'] = $order['shipping_description'];
|
| 117 |
$result['delivery']['shippingMethod']['price'] = $order['shipping_amount'];
|
| 118 |
-
$result['payment']['methodType'] = $order['payment']['method'];
|
| 119 |
$result['payment']['accountNumber'] = '**** **** **** ' . $order['payment']['cc_last4'];
|
| 120 |
$result['payment']['bankCode'] = $order['payment']['cc_type'];
|
| 121 |
-
|
| 122 |
if ($result['payment']['methodType'] == 'paypal_express') {
|
| 123 |
$result['payment']['methodType'] = 'PayPal';
|
| 124 |
$result['payment']['type'] = 'PayPal';
|
|
@@ -132,7 +119,6 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 132 |
$result['payment']['methodType'] = 'CreditCard';
|
| 133 |
$result['payment']['type'] = 'Credit Card';
|
| 134 |
}
|
| 135 |
-
|
| 136 |
foreach ($order['items'] as $item){
|
| 137 |
$line = array();
|
| 138 |
$line['productId'] = $item['product_id'];
|
|
@@ -141,13 +127,11 @@ class TmobLabs_Tappz_Model_Customer_Order_Api extends Mage_Sales_Model_Order_Api
|
|
| 141 |
$line['price'] = number_format($item['price_incl_tax'], 2, $decimalDivider, $thousandDivider);
|
| 142 |
$line['priceTotal'] = number_format($item['row_total_incl_tax'], 2, $decimalDivider, $thousandDivider);
|
| 143 |
$line['averageDeliveryDays'] = $item[$lineAverageDeliveryDaysAttributeCode];
|
| 144 |
-
$line['variants'] = array()
|
| 145 |
|
| 146 |
$result['lines'][] = $line;
|
| 147 |
}
|
| 148 |
-
|
| 149 |
$result['currency'] = $order['currency'];
|
| 150 |
-
|
| 151 |
return $result;
|
| 152 |
}
|
| 153 |
}
|
| 28 |
public function info($orderId)
|
| 29 |
{
|
| 30 |
$order = Mage::getModel('sales/order');
|
|
|
|
|
|
|
|
|
|
| 31 |
$order->loadByIncrementId($orderId);
|
|
|
|
| 32 |
if (!$order->getId()) {
|
| 33 |
$this->_fault('not_exists');
|
| 34 |
}
|
|
|
|
| 35 |
$result = $this->_getAttributes($order, 'order');
|
|
|
|
| 36 |
$addressApi = Mage::getSingleton('tappz/Customer_Address_Api');
|
|
|
|
|
|
|
| 37 |
$result['items'] = array();
|
|
|
|
| 38 |
foreach ($order->getAllItems() as $item) {
|
| 39 |
if ($item->getGiftMessageId() > 0) {
|
| 40 |
$item->setGiftMessage(
|
| 41 |
Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
|
| 42 |
);
|
| 43 |
}
|
|
|
|
| 44 |
$result['items'][] = $this->_getAttributes($item, 'order_item');
|
| 45 |
}
|
| 46 |
|
| 64 |
$thousandDivider = Mage::getStoreConfig('tappz/general/groupSeparator');
|
| 65 |
$lineAverageDeliveryDaysAttributeCode = Mage::getStoreConfig('tappz/basket/averagedeliverydaysattributecode');
|
| 66 |
$catalogApi = Mage::getSingleton('tappz/Catalog_Api');
|
|
|
|
| 67 |
$result = array();
|
| 68 |
$result['id'] = null;
|
| 69 |
$result['currency'] = null;
|
| 91 |
$result['payment']['cashOnDelivery'] = null;
|
| 92 |
$result['payment']['creditCard'] = null;
|
| 93 |
$result['lines'] = array();
|
|
|
|
| 94 |
$result['id'] = $order['increment_id'];
|
| 95 |
$result['orderDate'] = date_format(date_create($order['created_at']), 'd/m/Y');
|
| 96 |
$result['shippingStatus'] = $order['status'];
|
| 103 |
$result['delivery']['shippingMethod']['id'] = $order['shipping_method'];
|
| 104 |
$result['delivery']['shippingMethod']['displayName'] = $order['shipping_description'];
|
| 105 |
$result['delivery']['shippingMethod']['price'] = $order['shipping_amount'];
|
| 106 |
+
$result['payment']['methodType'] = $order['payment']['method'];
|
| 107 |
$result['payment']['accountNumber'] = '**** **** **** ' . $order['payment']['cc_last4'];
|
| 108 |
$result['payment']['bankCode'] = $order['payment']['cc_type'];
|
|
|
|
| 109 |
if ($result['payment']['methodType'] == 'paypal_express') {
|
| 110 |
$result['payment']['methodType'] = 'PayPal';
|
| 111 |
$result['payment']['type'] = 'PayPal';
|
| 119 |
$result['payment']['methodType'] = 'CreditCard';
|
| 120 |
$result['payment']['type'] = 'Credit Card';
|
| 121 |
}
|
|
|
|
| 122 |
foreach ($order['items'] as $item){
|
| 123 |
$line = array();
|
| 124 |
$line['productId'] = $item['product_id'];
|
| 127 |
$line['price'] = number_format($item['price_incl_tax'], 2, $decimalDivider, $thousandDivider);
|
| 128 |
$line['priceTotal'] = number_format($item['row_total_incl_tax'], 2, $decimalDivider, $thousandDivider);
|
| 129 |
$line['averageDeliveryDays'] = $item[$lineAverageDeliveryDaysAttributeCode];
|
| 130 |
+
$line['variants'] = array();
|
| 131 |
|
| 132 |
$result['lines'][] = $line;
|
| 133 |
}
|
|
|
|
| 134 |
$result['currency'] = $order['currency'];
|
|
|
|
| 135 |
return $result;
|
| 136 |
}
|
| 137 |
}
|
app/code/community/TmobLabs/Tappz/etc/system.xml
CHANGED
|
@@ -71,145 +71,7 @@
|
|
| 71 |
<show_in_website>1</show_in_website>
|
| 72 |
<show_in_store>1</show_in_store>
|
| 73 |
<fields>
|
| 74 |
-
|
| 75 |
-
<label>Banner 1 - Image</label>
|
| 76 |
-
<tooltip>Choose an image for the first banner.</tooltip>
|
| 77 |
-
<frontend_type>image</frontend_type>
|
| 78 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 79 |
-
<upload_dir config="system/filesystem/media" scope_info="1">tappz</upload_dir>
|
| 80 |
-
<base_url type="media" scope_info="1">tappz</base_url>
|
| 81 |
-
<sort_order>10</sort_order>
|
| 82 |
-
<show_in_default>1</show_in_default>
|
| 83 |
-
<show_in_website>1</show_in_website>
|
| 84 |
-
<show_in_store>1</show_in_store>
|
| 85 |
-
</bannerImage1>
|
| 86 |
-
<bannerActionType1>
|
| 87 |
-
<label>Banner 1 - Action Type</label>
|
| 88 |
-
<tooltip>Choose an action type for the first banner.</tooltip>
|
| 89 |
-
<frontend_type>select</frontend_type>
|
| 90 |
-
<source_model>tappz/system_config_action</source_model>
|
| 91 |
-
<sort_order>11</sort_order>
|
| 92 |
-
<show_in_default>1</show_in_default>
|
| 93 |
-
<show_in_website>1</show_in_website>
|
| 94 |
-
<show_in_store>1</show_in_store>
|
| 95 |
-
</bannerActionType1>
|
| 96 |
-
<bannerActionValue1>
|
| 97 |
-
<label>Banner 1 - Action Value</label>
|
| 98 |
-
<tooltip>Choose an action value for the first banner.</tooltip>
|
| 99 |
-
<frontend_type>text</frontend_type>
|
| 100 |
-
<sort_order>12</sort_order>
|
| 101 |
-
<show_in_default>1</show_in_default>
|
| 102 |
-
<show_in_website>1</show_in_website>
|
| 103 |
-
<show_in_store>1</show_in_store>
|
| 104 |
-
<validate>validate-length
|
| 105 |
-
minimum-length-1
|
| 106 |
-
</validate>
|
| 107 |
-
</bannerActionValue1>
|
| 108 |
-
|
| 109 |
-
<bannerImage2 translate="label tooltip">
|
| 110 |
-
<label>Banner 2 - Image</label>
|
| 111 |
-
<tooltip>Choose an image for the second banner.</tooltip>
|
| 112 |
-
<frontend_type>image</frontend_type>
|
| 113 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 114 |
-
<upload_dir config="system/filesystem/media" scope_info="1">tappz</upload_dir>
|
| 115 |
-
<base_url type="media" scope_info="1">tappz</base_url>
|
| 116 |
-
<sort_order>20</sort_order>
|
| 117 |
-
<show_in_default>1</show_in_default>
|
| 118 |
-
<show_in_website>1</show_in_website>
|
| 119 |
-
<show_in_store>1</show_in_store>
|
| 120 |
-
</bannerImage2>
|
| 121 |
-
<bannerActionType2>
|
| 122 |
-
<label>Banner 2 - Action Type</label>
|
| 123 |
-
<tooltip>Choose an action type for the second banner.</tooltip>
|
| 124 |
-
<frontend_type>select</frontend_type>
|
| 125 |
-
<source_model>tappz/system_config_action</source_model>
|
| 126 |
-
<sort_order>21</sort_order>
|
| 127 |
-
<show_in_default>1</show_in_default>
|
| 128 |
-
<show_in_website>1</show_in_website>
|
| 129 |
-
<show_in_store>1</show_in_store>
|
| 130 |
-
</bannerActionType2>
|
| 131 |
-
<bannerActionValue2>
|
| 132 |
-
<label>Banner 2 - Action Value</label>
|
| 133 |
-
<tooltip>Choose an action value for the second banner.</tooltip>
|
| 134 |
-
<frontend_type>text</frontend_type>
|
| 135 |
-
<sort_order>22</sort_order>
|
| 136 |
-
<show_in_default>1</show_in_default>
|
| 137 |
-
<show_in_website>1</show_in_website>
|
| 138 |
-
<show_in_store>1</show_in_store>
|
| 139 |
-
<validate>validate-length
|
| 140 |
-
minimum-length-1
|
| 141 |
-
</validate>
|
| 142 |
-
</bannerActionValue2>
|
| 143 |
-
|
| 144 |
-
<bannerImage3 translate="label tooltip">
|
| 145 |
-
<label>Banner 3 - Image</label>
|
| 146 |
-
<tooltip>Choose an image for the third banner.</tooltip>
|
| 147 |
-
<frontend_type>image</frontend_type>
|
| 148 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 149 |
-
<upload_dir config="system/filesystem/media" scope_info="1">tappz</upload_dir>
|
| 150 |
-
<base_url type="media" scope_info="1">tappz</base_url>
|
| 151 |
-
<sort_order>30</sort_order>
|
| 152 |
-
<show_in_default>1</show_in_default>
|
| 153 |
-
<show_in_website>1</show_in_website>
|
| 154 |
-
<show_in_store>1</show_in_store>
|
| 155 |
-
</bannerImage3>
|
| 156 |
-
<bannerActionType3>
|
| 157 |
-
<label>Banner 3 - Action Type</label>
|
| 158 |
-
<tooltip>Choose an action type for the third banner.</tooltip>
|
| 159 |
-
<frontend_type>select</frontend_type>
|
| 160 |
-
<source_model>tappz/system_config_action</source_model>
|
| 161 |
-
<sort_order>31</sort_order>
|
| 162 |
-
<show_in_default>1</show_in_default>
|
| 163 |
-
<show_in_website>1</show_in_website>
|
| 164 |
-
<show_in_store>1</show_in_store>
|
| 165 |
-
</bannerActionType3>
|
| 166 |
-
<bannerActionValue3>
|
| 167 |
-
<label>Banner 3 - Action Value</label>
|
| 168 |
-
<tooltip>Choose an action value for the third banner.</tooltip>
|
| 169 |
-
<frontend_type>text</frontend_type>
|
| 170 |
-
<sort_order>32</sort_order>
|
| 171 |
-
<show_in_default>1</show_in_default>
|
| 172 |
-
<show_in_website>1</show_in_website>
|
| 173 |
-
<show_in_store>1</show_in_store>
|
| 174 |
-
<validate>validate-length
|
| 175 |
-
minimum-length-1
|
| 176 |
-
</validate>
|
| 177 |
-
</bannerActionValue3>
|
| 178 |
-
|
| 179 |
-
<bannerImage4 translate="label tooltip">
|
| 180 |
-
<label>Banner 4 - Image</label>
|
| 181 |
-
<tooltip>Choose an image for the fourth banner.</tooltip>
|
| 182 |
-
<frontend_type>image</frontend_type>
|
| 183 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 184 |
-
<upload_dir config="system/filesystem/media" scope_info="1">tappz</upload_dir>
|
| 185 |
-
<base_url type="media" scope_info="1">tappz</base_url>
|
| 186 |
-
<sort_order>40</sort_order>
|
| 187 |
-
<show_in_default>1</show_in_default>
|
| 188 |
-
<show_in_website>1</show_in_website>
|
| 189 |
-
<show_in_store>1</show_in_store>
|
| 190 |
-
</bannerImage4>
|
| 191 |
-
<bannerActionType4>
|
| 192 |
-
<label>Banner 4 - Action Type</label>
|
| 193 |
-
<tooltip>Choose an action type for the fourth banner.</tooltip>
|
| 194 |
-
<frontend_type>select</frontend_type>
|
| 195 |
-
<source_model>tappz/system_config_action</source_model>
|
| 196 |
-
<sort_order>41</sort_order>
|
| 197 |
-
<show_in_default>1</show_in_default>
|
| 198 |
-
<show_in_website>1</show_in_website>
|
| 199 |
-
<show_in_store>1</show_in_store>
|
| 200 |
-
</bannerActionType4>
|
| 201 |
-
<bannerActionValue4>
|
| 202 |
-
<label>Banner 4 - Action Value</label>
|
| 203 |
-
<tooltip>Choose an action value for the fourth banner.</tooltip>
|
| 204 |
-
<frontend_type>text</frontend_type>
|
| 205 |
-
<sort_order>42</sort_order>
|
| 206 |
-
<show_in_default>1</show_in_default>
|
| 207 |
-
<show_in_website>1</show_in_website>
|
| 208 |
-
<show_in_store>1</show_in_store>
|
| 209 |
-
<validate>validate-length
|
| 210 |
-
minimum-length-1
|
| 211 |
-
</validate>
|
| 212 |
-
</bannerActionValue4>
|
| 213 |
|
| 214 |
<catalog1 translate="label tooltip">
|
| 215 |
<label>Front Page - Product List 1</label>
|
| 71 |
<show_in_website>1</show_in_website>
|
| 72 |
<show_in_store>1</show_in_store>
|
| 73 |
<fields>
|
| 74 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
<catalog1 translate="label tooltip">
|
| 77 |
<label>Front Page - Product List 1</label>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Tmob_Tappz</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>t-appz Adapter for Magento</description>
|
| 11 |
<notes>t-appz Adapter for Magento</notes>
|
| 12 |
<authors><author><name>tmobtech </name><user>tmobLabs</user><email>info@tmobtech.com</email></author></authors>
|
| 13 |
-
<date>
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magecommunity"><dir name="TmobLabs"><dir name="Tappz"><dir name="Block"><file name="Info.php" hash="f656ba90ea77040abb27cf8858a5e8bb"/></dir><dir name="Helper"><file name="Data.php" hash="8587ca8f702e61ae1b57dd7739a674e6"/></dir><dir name="Model"><dir name="Basket"><dir name="Api"><file name="V2.php" hash="e5860165902a6e3f0e29e238397d40f3"/></dir><file name="Api.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>Tmob_Tappz</name>
|
| 4 |
+
<version>1.0.12</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>t-appz Adapter for Magento</description>
|
| 11 |
<notes>t-appz Adapter for Magento</notes>
|
| 12 |
<authors><author><name>tmobtech </name><user>tmobLabs</user><email>info@tmobtech.com</email></author></authors>
|
| 13 |
+
<date>2016-02-15</date>
|
| 14 |
+
<time>13:01:51</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="TmobLabs"><dir name="Tappz"><dir name="Block"><file name="Info.php" hash="f656ba90ea77040abb27cf8858a5e8bb"/></dir><dir name="Helper"><file name="Data.php" hash="8587ca8f702e61ae1b57dd7739a674e6"/></dir><dir name="Model"><dir name="Basket"><dir name="Api"><file name="V2.php" hash="e5860165902a6e3f0e29e238397d40f3"/></dir><file name="Api.php" hash="58e807aa3dc14a035e69b367aa9b1dd1"/></dir><dir name="Catalog"><dir name="Api"><file name="V2.php" hash="d28a03e359966fa0a0a9c48940ff4b2b"/></dir><file name="Api.php" hash="9dc4ddec790e52410ca9273314b66ef7"/></dir><dir name="Customer"><dir name="Address"><dir name="Api"><file name="V2.php" hash="9a3ca989261966e5d9195274311db0e6"/></dir><file name="Api.php" hash="88e9a010b0bf3a348d37bf45dbfbaf19"/></dir><dir name="Api"><file name="V2.php" hash="5089c4a89f24f09ff6ed41903d04d210"/></dir><file name="Api.php" hash="ead8e221929c3f38c1ccc3a4989562cf"/><dir name="Order"><dir name="Api"><file name="V2.php" hash="9a4d34b33c98d7931c86a3af64718a88"/></dir><file name="Api.php" hash="8ef5f19e3941d12bfc4687c2d4ea1bae"/></dir></dir><dir name="System"><dir name="Config"><file name="Action.php" hash="696379a81774cc7022565d3d22c263e6"/><file name="Address.php" hash="d7aed1d204c8fa4bbf833c22ee643bc4"/><file name="Category.php" hash="eb4af019ee4494bd305195442378957e"/><file name="Customer.php" hash="14e8962dc72e73319e632e751c009193"/><file name="Divider.php" hash="3a3b599ba29e053ec9b804975cab5b21"/><file name="Enabled.php" hash="8db7b92b36d79a153fab01ceee8c53bd"/><file name="Payment.php" hash="0216068de66b431fba037923ee30a81a"/><dir name="Product"><file name="Attribute.php" hash="62800e9eed8a06444560c351a25de6e3"/></dir><file name="Store.php" hash="ac29ff3d2a9b915ed3e78e8ac4eca999"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="35aaf132195e63f958f33b59bd981b3e"/><file name="api.xml" hash="f2812af730d2d3f4ce92ef164f3b693c"/><file name="config.xml" hash="93b957b86d745252c3e9746c0df9c3c6"/><file name="system.xml" hash="9b122651372fa386e8beafd39e426696"/><file name="wsdl.xml" hash="ee6f0a1af3cebe17f7f63fa2284ec40a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TmobLabs_Tappz.xml" hash="88f02743bbc8116ca67c615803436b74"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
