@@ -3,12 +3,12 @@ discard block |
||
| 3 | 3 | require('includes/application_top.php'); |
| 4 | 4 | |
| 5 | 5 | define('TABLE_PAGANTIS_CONFIG', 'pagantis_config'); |
| 6 | -define('TABLE_PRODUCTS_DESCRIPTIONS','products_description'); |
|
| 6 | +define('TABLE_PRODUCTS_DESCRIPTIONS', 'products_description'); |
|
| 7 | 7 | |
| 8 | 8 | //Check if module is installed |
| 9 | -$result = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_key='MODULE_PAYMENT_PAGANTIS_STATUS'"); |
|
| 9 | +$result = tep_db_query("select * from ".TABLE_CONFIGURATION." where configuration_key='MODULE_PAYMENT_PAGANTIS_STATUS'"); |
|
| 10 | 10 | $resultSelect = tep_db_fetch_array($result); |
| 11 | -if (tep_db_num_rows($result) == 0 || $resultSelect['configuration_value'] !=='True') { |
|
| 11 | +if (tep_db_num_rows($result) == 0 || $resultSelect['configuration_value'] !== 'True') { |
|
| 12 | 12 | tep_redirect('/admin/index.php'); |
| 13 | 13 | } |
| 14 | 14 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $resultSelect = tep_db_fetch_array($result); |
| 32 | 32 | if ($resultSelect['value'] == '') { |
| 33 | 33 | $promotedProducts = array(); |
| 34 | - } else { |
|
| 34 | + }else { |
|
| 35 | 35 | $promotedProducts = array_values((array)unserialize($resultSelect['value'])); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function checkPagantisOrderId() |
| 141 | 141 | { |
| 142 | - $orderId=0; |
|
| 142 | + $orderId = 0; |
|
| 143 | 143 | $notifyUrl = self::OSCURL.self::NOTIFICATION_FOLDER.'?order='.$orderId; |
| 144 | 144 | $this->assertNotEmpty($notifyUrl, $notifyUrl); |
| 145 | 145 | $response = Request::post($notifyUrl)->expects('json')->send(); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $this->assertEquals( |
| 150 | 150 | $response->body->merchant_order_id, |
| 151 | 151 | $orderId, |
| 152 | - $response->body->merchant_order_id.'!='. $orderId |
|
| 152 | + $response->body->merchant_order_id.'!='.$orderId |
|
| 153 | 153 | ); |
| 154 | 154 | $this->assertContains( |
| 155 | 155 | NoIdentificationException::ERROR_MESSAGE, |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (strpos($_SERVER[REQUEST_URI], "checkout_payment.php") <= 0) { |
| 66 | 66 | $this->title = MODULE_PAYMENT_PAGANTIS_TEXT_ADMIN_TITLE; // Payment module title in Admin |
| 67 | - } else { |
|
| 68 | - $this->title = $this->extraConfig['PAGANTIS_TITLE'] .'<br/><br/><div class="buttonSet" style="display:none"></div><br/>'; // Payment module title in Catalog |
|
| 67 | + }else { |
|
| 68 | + $this->title = $this->extraConfig['PAGANTIS_TITLE'].'<br/><br/><div class="buttonSet" style="display:none"></div><br/>'; // Payment module title in Catalog |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $this->enabled = ((MODULE_PAYMENT_PAGANTIS_STATUS == 'True') ? true : false); |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | "%s://%s%s%s", |
| 76 | 76 | isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', |
| 77 | 77 | $_SERVER['SERVER_NAME'], |
| 78 | - isset($_SERVER['SERVER_PORT']) ? ":" . $_SERVER['SERVER_PORT'] : '', |
|
| 78 | + isset($_SERVER['SERVER_PORT']) ? ":".$_SERVER['SERVER_PORT'] : '', |
|
| 79 | 79 | $_SERVER['REQUEST_URI'] |
| 80 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - $this->form_action_url = $this->base_url . '/ext/modules/payment/pagantis/bypass.php'; |
|
| 83 | + $this->form_action_url = $this->base_url.'/ext/modules/payment/pagantis/bypass.php'; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /*************** |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | throw new UnknownException("Order not found"); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $id_hash = time() . serialize($order->products) . '' . serialize($order->customer) . '' . serialize($order->delivery); |
|
| 182 | + $id_hash = time().serialize($order->products).''.serialize($order->customer).''.serialize($order->delivery); |
|
| 183 | 183 | $this->os_order_reference = md5($id_hash); |
| 184 | 184 | $_SESSION['order_id'] = $this->os_order_reference; |
| 185 | 185 | |
| 186 | 186 | $userAddress = new Address(); |
| 187 | 187 | $userAddress |
| 188 | 188 | ->setZipCode($order->billing['postcode']) |
| 189 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 189 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 190 | 190 | ->setCountryCode('ES') |
| 191 | 191 | ->setCity($order->billing['city']) |
| 192 | 192 | ->setAddress($order->billing['street_address']) |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $orderShippingAddress = new Address(); |
| 199 | 199 | $orderShippingAddress |
| 200 | 200 | ->setZipCode($order->delivery['postcode']) |
| 201 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 201 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 202 | 202 | ->setCountryCode('ES') |
| 203 | 203 | ->setCity($order->delivery['city']) |
| 204 | 204 | ->setAddress($order->delivery['street_address']) |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $orderUser = new \Pagantis\OrdersApiClient\Model\Order\User(); |
| 209 | 209 | $orderUser |
| 210 | 210 | ->setAddress($userAddress) |
| 211 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 211 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 212 | 212 | ->setBillingAddress($orderBillingAddress) |
| 213 | 213 | ->setEmail($order->customer['email_address']) |
| 214 | 214 | ->setFixPhone($order->customer['telephone']) |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | ->setQuantity(intval($item['qty'])) |
| 248 | 248 | ->setDescription($item['name']); |
| 249 | 249 | if ($promotedProduct) { |
| 250 | - $promotedAmount+=$product->getAmount(); |
|
| 250 | + $promotedAmount += $product->getAmount(); |
|
| 251 | 251 | $promotedMessage = $product->getDescription()."-Price:".$item['final_price']."-Qty:".$product->getQuantity(); |
| 252 | 252 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 253 | 253 | } |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | ); |
| 268 | 268 | |
| 269 | 269 | $cancelUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false)); |
| 270 | - if ($this->extraConfig['PAGANTIS_URL_KO']!='') { |
|
| 270 | + if ($this->extraConfig['PAGANTIS_URL_KO'] != '') { |
|
| 271 | 271 | $koUrl = $this->extraConfig['PAGANTIS_URL_KO']; |
| 272 | - } else { |
|
| 272 | + }else { |
|
| 273 | 273 | $koUrl = $cancelUrl; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -305,16 +305,16 @@ discard block |
||
| 305 | 305 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 306 | 306 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 307 | 307 | $this->insertRow($this->os_order_reference, $pagantisOrder->getId(), serialize($global_vars)); |
| 308 | - } else { |
|
| 308 | + }else { |
|
| 309 | 309 | throw new OrderNotFoundException(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | if ($url == "") { |
| 313 | 313 | throw new UnknownException(_("No ha sido posible obtener una respuesta de Pagantis")); |
| 314 | - } else { |
|
| 314 | + }else { |
|
| 315 | 315 | $output = "\n"; |
| 316 | - $output .= tep_draw_hidden_field("formUrl", $url) . "\n"; |
|
| 317 | - $output .= tep_draw_hidden_field("cancelUrl", $cancelUrl) . "\n"; |
|
| 316 | + $output .= tep_draw_hidden_field("formUrl", $url)."\n"; |
|
| 317 | + $output .= tep_draw_hidden_field("cancelUrl", $cancelUrl)."\n"; |
|
| 318 | 318 | return $output; |
| 319 | 319 | |
| 320 | 320 | } //TODO IFRAME |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | return 'failed'; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 383 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 384 | 384 | ( |
| 385 | 385 | configuration_title, |
| 386 | 386 | configuration_key, |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | ', |
| 404 | 404 | now() |
| 405 | 405 | )"); |
| 406 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 406 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 407 | 407 | ( |
| 408 | 408 | configuration_title, |
| 409 | 409 | configuration_key, |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | '0', |
| 424 | 424 | now() |
| 425 | 425 | )"); |
| 426 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 426 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 427 | 427 | ( |
| 428 | 428 | configuration_title, |
| 429 | 429 | configuration_key, |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | '0', |
| 444 | 444 | now() |
| 445 | 445 | )"); |
| 446 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 446 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 447 | 447 | ( |
| 448 | 448 | configuration_title, |
| 449 | 449 | configuration_key, |
@@ -475,14 +475,14 @@ discard block |
||
| 475 | 475 | */ |
| 476 | 476 | private function installPagantisTables() |
| 477 | 477 | { |
| 478 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_LOG . " ( |
|
| 478 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_LOG." ( |
|
| 479 | 479 | id int NOT NULL AUTO_INCREMENT, |
| 480 | 480 | log text NOT NULL, |
| 481 | 481 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 482 | 482 | UNIQUE KEY id (id))"; |
| 483 | 483 | tep_db_query($sql); |
| 484 | 484 | |
| 485 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONFIG . " ( |
|
| 485 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONFIG." ( |
|
| 486 | 486 | id int NOT NULL AUTO_INCREMENT, |
| 487 | 487 | config varchar(60) NOT NULL, |
| 488 | 488 | value varchar(200) NOT NULL, |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | tep_db_query($sql); |
| 491 | 491 | |
| 492 | 492 | // check if table has records |
| 493 | - $check_query = tep_db_query("select value from " . TABLE_PAGANTIS_CONFIG); |
|
| 493 | + $check_query = tep_db_query("select value from ".TABLE_PAGANTIS_CONFIG); |
|
| 494 | 494 | if (tep_db_num_rows($check_query) === 0) { |
| 495 | 495 | foreach ((array)$this->defaultConfigs as $configKey => $configValue) { |
| 496 | - $query = "INSERT INTO " . TABLE_PAGANTIS_CONFIG . " |
|
| 496 | + $query = "INSERT INTO ".TABLE_PAGANTIS_CONFIG." |
|
| 497 | 497 | ( |
| 498 | 498 | config, |
| 499 | 499 | value |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_ORDERS . " ( |
|
| 510 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_ORDERS." ( |
|
| 511 | 511 | id int NOT NULL AUTO_INCREMENT, |
| 512 | 512 | os_order_id varchar(50), |
| 513 | 513 | os_order_reference varchar(50) NOT NULL, |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | UNIQUE KEY id(id))"; |
| 517 | 517 | tep_db_query($sql); |
| 518 | 518 | |
| 519 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONCURRENCY . " ( |
|
| 519 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONCURRENCY." ( |
|
| 520 | 520 | id varchar(50) NOT NULL, |
| 521 | 521 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 522 | 522 | UNIQUE KEY id(id))"; |
@@ -528,29 +528,29 @@ discard block |
||
| 528 | 528 | */ |
| 529 | 529 | public function remove() |
| 530 | 530 | { |
| 531 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_LOG . "'"); |
|
| 531 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_LOG."'"); |
|
| 532 | 532 | if (tep_db_num_rows($checkTable) > 0) { |
| 533 | - tep_db_query("drop table " . TABLE_PAGANTIS_LOG); |
|
| 533 | + tep_db_query("drop table ".TABLE_PAGANTIS_LOG); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONFIG . "'"); |
|
| 536 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'"); |
|
| 537 | 537 | if (tep_db_num_rows($checkTable) > 0) { |
| 538 | - tep_db_query("drop table " . TABLE_PAGANTIS_CONFIG); |
|
| 538 | + tep_db_query("drop table ".TABLE_PAGANTIS_CONFIG); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_ORDERS . "'"); |
|
| 541 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_ORDERS."'"); |
|
| 542 | 542 | if (tep_db_num_rows($checkTable) > 0) { |
| 543 | - tep_db_query("drop table " . TABLE_PAGANTIS_ORDERS); |
|
| 543 | + tep_db_query("drop table ".TABLE_PAGANTIS_ORDERS); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONCURRENCY . "'"); |
|
| 546 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONCURRENCY."'"); |
|
| 547 | 547 | if (tep_db_num_rows($checkTable) > 0) { |
| 548 | - tep_db_query("drop table " . TABLE_PAGANTIS_CONCURRENCY); |
|
| 548 | + tep_db_query("drop table ".TABLE_PAGANTIS_CONCURRENCY); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - tep_db_query("DELETE FROM ". TABLE_CONFIGURATION ." where configuration_key in ('MODULE_PAYMENT_PAGANTIS_STATUS','MODULE_PAYMENT_PAGANTIS_PK','MODULE_PAYMENT_PAGANTIS_SK')"); |
|
| 551 | + tep_db_query("DELETE FROM ".TABLE_CONFIGURATION." where configuration_key in ('MODULE_PAYMENT_PAGANTIS_STATUS','MODULE_PAYMENT_PAGANTIS_PK','MODULE_PAYMENT_PAGANTIS_SK')"); |
|
| 552 | 552 | |
| 553 | - $query = "delete from " . TABLE_CONFIGURATION . " where configuration_key like '%_PAGANTIS_%'"; |
|
| 553 | + $query = "delete from ".TABLE_CONFIGURATION." where configuration_key like '%_PAGANTIS_%'"; |
|
| 554 | 554 | tep_db_query($query); |
| 555 | 555 | |
| 556 | 556 | $this->uninstallSimulator(); |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | private function insertRow($orderId, $pagantisOrderId, $globalVars) |
| 607 | 607 | { |
| 608 | - $query = "select * from " . TABLE_PAGANTIS_ORDERS . " where os_order_reference='$orderId'"; |
|
| 608 | + $query = "select * from ".TABLE_PAGANTIS_ORDERS." where os_order_reference='$orderId'"; |
|
| 609 | 609 | $resultsSelect = tep_db_query($query); |
| 610 | 610 | $countResults = tep_db_num_rows($resultsSelect); |
| 611 | 611 | if ($countResults == 0) { |
| 612 | - $query = "INSERT INTO " . TABLE_PAGANTIS_ORDERS . " |
|
| 612 | + $query = "INSERT INTO ".TABLE_PAGANTIS_ORDERS." |
|
| 613 | 613 | (os_order_reference, pagantis_order_id, globals) values ('$orderId', '$pagantisOrderId','$globalVars')"; |
| 614 | - } else { |
|
| 614 | + }else { |
|
| 615 | 615 | $query = "UPDATE ".TABLE_PAGANTIS_ORDERS." set pagantis_order_id='$pagantisOrderId' |
| 616 | 616 | where os_order_reference='$orderId'"; |
| 617 | 617 | } |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if ($this->extraConfig['PAGANTIS_PROMOTION'] == '') { |
| 654 | 654 | $promotedProducts = array(); |
| 655 | - } else { |
|
| 655 | + }else { |
|
| 656 | 656 | $promotedProducts = array_values((array)unserialize($this->extraConfig['PAGANTIS_PROMOTION'])); |
| 657 | 657 | } |
| 658 | 658 | |
@@ -665,13 +665,13 @@ discard block |
||
| 665 | 665 | private function getDescription() |
| 666 | 666 | { |
| 667 | 667 | $descriptionCode = "<img src=\"images/icon_info.gif\" border=\"0\" alt=\"Info\" title=\"Info\"> <strong>Module version:</strong> $this->version<br/><br/>"; |
| 668 | - $descriptionCode.= "<img src=\"images/icon_info.gif\" border=\"0\"> <a href='https://developer.pagantis.com/' target=\"_blank\" style=\"text-decoration: underline; font-weight: bold;\">View Online Documentation</a><br/><br/>"; |
|
| 669 | - $descriptionCode.= "<img src='images/icon_popup.gif' border='0'> <a href='http://pagantis.com' target='_blank' style='text-decoration: underline; font-weight: bold;'>Visit Pagantis Website</a><br/><br/><br/>"; |
|
| 668 | + $descriptionCode .= "<img src=\"images/icon_info.gif\" border=\"0\"> <a href='https://developer.pagantis.com/' target=\"_blank\" style=\"text-decoration: underline; font-weight: bold;\">View Online Documentation</a><br/><br/>"; |
|
| 669 | + $descriptionCode .= "<img src='images/icon_popup.gif' border='0'> <a href='http://pagantis.com' target='_blank' style='text-decoration: underline; font-weight: bold;'>Visit Pagantis Website</a><br/><br/><br/>"; |
|
| 670 | 670 | |
| 671 | 671 | if (MODULE_PAYMENT_PAGANTIS_STATUS == 'True' && $this->isPromoted(null)) { |
| 672 | 672 | $pagantisPromotionUrl = $this->base_url.'/admin/promotion.php'; |
| 673 | 673 | $linkDescription = "Si desea gestionar los productos promocionados pulse aquí"; |
| 674 | - $descriptionCode.= "<a href='$pagantisPromotionUrl'>$linkDescription</a>"; |
|
| 674 | + $descriptionCode .= "<a href='$pagantisPromotionUrl'>$linkDescription</a>"; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | return $descriptionCode; |
@@ -682,34 +682,34 @@ discard block |
||
| 682 | 682 | */ |
| 683 | 683 | private function installSimulator() |
| 684 | 684 | { |
| 685 | - $checkSimulator = tep_db_query("select configuration_key, configuration_value from " .TABLE_CONFIGURATION ." |
|
| 685 | + $checkSimulator = tep_db_query("select configuration_key, configuration_value from ".TABLE_CONFIGURATION." |
|
| 686 | 686 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED' |
| 687 | 687 | and configuration_value like '%ht_pagantis.php%';"); |
| 688 | 688 | if (tep_db_num_rows($checkSimulator) > 0) { |
| 689 | 689 | return true; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - $query = "UPDATE " . TABLE_CONFIGURATION . " set configuration_value = concat(configuration_value, ';ht_pagantis.php') |
|
| 692 | + $query = "UPDATE ".TABLE_CONFIGURATION." set configuration_value = concat(configuration_value, ';ht_pagantis.php') |
|
| 693 | 693 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED'"; |
| 694 | 694 | tep_db_query($query); |
| 695 | 695 | |
| 696 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Pagantis Module', 'MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'True', '', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
| 696 | + tep_db_query("insert into ".TABLE_CONFIGURATION." (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Pagantis Module', 'MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'True', '', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | private function uninstallSimulator() |
| 700 | 700 | { |
| 701 | - $checkSimulator = tep_db_query("select configuration_key, configuration_value from " .TABLE_CONFIGURATION ." |
|
| 701 | + $checkSimulator = tep_db_query("select configuration_key, configuration_value from ".TABLE_CONFIGURATION." |
|
| 702 | 702 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED' |
| 703 | 703 | and configuration_value like '%ht_pagantis.php%';"); |
| 704 | 704 | if (tep_db_num_rows($checkSimulator) == 0) { |
| 705 | 705 | return true; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - $query = "UPDATE " . TABLE_CONFIGURATION . " set configuration_value = REPLACE(configuration_value, ';ht_pagantis.php', '') |
|
| 708 | + $query = "UPDATE ".TABLE_CONFIGURATION." set configuration_value = REPLACE(configuration_value, ';ht_pagantis.php', '') |
|
| 709 | 709 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED'"; |
| 710 | 710 | tep_db_query($query); |
| 711 | 711 | |
| 712 | - $query = "delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_HEADER_TAGS_PAGANTIS_STATUS'"; |
|
| 712 | + $query = "delete from ".TABLE_CONFIGURATION." where configuration_key = 'MODULE_HEADER_TAGS_PAGANTIS_STATUS'"; |
|
| 713 | 713 | tep_db_query($query); |
| 714 | 714 | } |
| 715 | 715 | } |
@@ -32,23 +32,23 @@ discard block |
||
| 32 | 32 | public $pgNotify; |
| 33 | 33 | |
| 34 | 34 | public $defaultConfigs = array('PAGANTIS_TITLE'=>'Instant Financing', |
| 35 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE', |
|
| 36 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE', |
|
| 37 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 38 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 39 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 40 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 41 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'pgSDK.simulator.positions.INNER', |
|
| 42 | - 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'default', |
|
| 43 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'default', |
|
| 44 | - 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR_CHECKOUT'=>'default', |
|
| 45 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 46 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 47 | - 'PAGANTIS_URL_OK'=>'', |
|
| 48 | - 'PAGANTIS_URL_KO'=>'', |
|
| 49 | - 'PAGANTIS_TITLE_EXTRA' => 'Paga hasta en 12 cómodas cuotas con Paga+Tarde. Solicitud totalmente online y sin papeleos,¡y la respuesta es inmediata!', |
|
| 50 | - 'PAGANTIS_PROMOTION' => '', |
|
| 51 | - 'PAGANTIS_PROMOTED_PRODUCT_CODE' => '<p>PRODUCTO PROMOCIONADO AL 0%</p>' |
|
| 35 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE', |
|
| 36 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE', |
|
| 37 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
|
| 38 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
|
| 39 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
|
| 40 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
|
| 41 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'pgSDK.simulator.positions.INNER', |
|
| 42 | + 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'default', |
|
| 43 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'default', |
|
| 44 | + 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR_CHECKOUT'=>'default', |
|
| 45 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
|
| 46 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
|
| 47 | + 'PAGANTIS_URL_OK'=>'', |
|
| 48 | + 'PAGANTIS_URL_KO'=>'', |
|
| 49 | + 'PAGANTIS_TITLE_EXTRA' => 'Paga hasta en 12 cómodas cuotas con Paga+Tarde. Solicitud totalmente online y sin papeleos,¡y la respuesta es inmediata!', |
|
| 50 | + 'PAGANTIS_PROMOTION' => '', |
|
| 51 | + 'PAGANTIS_PROMOTED_PRODUCT_CODE' => '<p>PRODUCTO PROMOCIONADO AL 0%</p>' |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | try { |
| 160 | 160 | include_once('./ext/modules/payment/pagantis/vendor/autoload.php'); |
| 161 | 161 | global $order, $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, |
| 162 | - $payment, $comments, $customer_default_address_id, $cartID; |
|
| 162 | + $payment, $comments, $customer_default_address_id, $cartID; |
|
| 163 | 163 | $global_vars = array(); |
| 164 | 164 | $global_vars['customer_id'] = serialize($customer_id); |
| 165 | 165 | $global_vars['sendTo'] = serialize($sendto); |
@@ -83,22 +83,22 @@ discard block |
||
| 83 | 83 | $jsonResponse->setException($exception); |
| 84 | 84 | $this->insertLog($exception); |
| 85 | 85 | |
| 86 | - if ($this->extraConfig['PAGANTIS_URL_KO'] =! '') { |
|
| 86 | + if ($this->extraConfig['PAGANTIS_URL_KO'] = !'') { |
|
| 87 | 87 | $koUrl = $this->extraConfig['PAGANTIS_URL_KO']; |
| 88 | - } else { |
|
| 88 | + }else { |
|
| 89 | 89 | $koUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false)); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ($this->origin == 'notify') { |
| 93 | 93 | $jsonResponse->printResponse(); |
| 94 | - } else { |
|
| 94 | + }else { |
|
| 95 | 95 | if ($exception->getMessage() == AlreadyProcessedException::ERROR_MESSAGE) { |
| 96 | - if ($this->extraConfig['PAGANTIS_URL_OK']!='') { |
|
| 96 | + if ($this->extraConfig['PAGANTIS_URL_OK'] != '') { |
|
| 97 | 97 | $confirmationUrl = $this->extraConfig['PAGANTIS_URL_OK']; |
| 98 | - $confirmationUrl.="?order_id=$this->merchantOrderId"; |
|
| 99 | - } else { |
|
| 98 | + $confirmationUrl .= "?order_id=$this->merchantOrderId"; |
|
| 99 | + }else { |
|
| 100 | 100 | $confirmationUrl = trim(tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, '', 'SSL', false)); |
| 101 | - $confirmationUrl.="?order_id=$this->merchantOrderId"; |
|
| 101 | + $confirmationUrl .= "?order_id=$this->merchantOrderId"; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | header("Location: $confirmationUrl"); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | if ($this->origin == 'notify') { |
| 135 | 135 | $jsonResponse->printResponse(); |
| 136 | - } else { |
|
| 136 | + }else { |
|
| 137 | 137 | return $jsonResponse; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | try { |
| 207 | 207 | $this->checkPagantisStatus(array('AUTHORIZED')); |
| 208 | 208 | } catch (\Exception $e) { |
| 209 | - if ($this->findOscommerceOrderId()!='') { |
|
| 209 | + if ($this->findOscommerceOrderId() != '') { |
|
| 210 | 210 | throw new AlreadyProcessedException(); |
| 211 | - } else { |
|
| 211 | + }else { |
|
| 212 | 212 | if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 213 | 213 | $status = $this->pagantisOrder->getStatus(); |
| 214 | - } else { |
|
| 214 | + }else { |
|
| 215 | 215 | $status = '-'; |
| 216 | 216 | } |
| 217 | 217 | throw new WrongStatusException($status); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | global $order; |
| 228 | 228 | |
| 229 | - if ($order->info['order_status']!=='1') { |
|
| 229 | + if ($order->info['order_status'] !== '1') { |
|
| 230 | 230 | throw new AlreadyProcessedException(); |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | if ($orderId == null) { |
| 304 | 304 | $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where timestamp<".(time() - 5); |
| 305 | 305 | tep_db_query($query); |
| 306 | - } elseif ($orderId!='') { |
|
| 306 | + } elseif ($orderId != '') { |
|
| 307 | 307 | $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where id='$orderId'"; |
| 308 | 308 | tep_db_query($query); |
| 309 | 309 | } |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | if (!$payed) { |
| 356 | 356 | if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 357 | 357 | $status = $this->pagantisOrder->getStatus(); |
| 358 | - } else { |
|
| 358 | + }else { |
|
| 359 | 359 | $status = '-'; |
| 360 | 360 | } |
| 361 | 361 | throw new WrongStatusException($status); |
| 362 | 362 | } |
| 363 | - } else { |
|
| 363 | + }else { |
|
| 364 | 364 | throw new OrderNotFoundException(); |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | $metadataInfo = ''; |
| 398 | 398 | foreach ($metadataOrder as $metadataKey => $metadataValue) { |
| 399 | 399 | if ($metadataKey == 'promotedProduct') { |
| 400 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
| 400 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | $comment = "Pagantis id=$this->pagantisOrderId/Via=".ucfirst($this->origin)."/".$metadataInfo; |
| 405 | - $query = "insert into ".TABLE_ORDERS_STATUS_HISTORY ."(comments, orders_id, orders_status_id, customer_notified, date_added) values |
|
| 405 | + $query = "insert into ".TABLE_ORDERS_STATUS_HISTORY."(comments, orders_id, orders_status_id, customer_notified, date_added) values |
|
| 406 | 406 | ('$comment', ".$insert_id.", '2', -1, now() )"; |
| 407 | 407 | tep_db_query($query); |
| 408 | 408 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | private function insertLog($exception) |
| 428 | 428 | { |
| 429 | 429 | if ($exception instanceof \Exception) { |
| 430 | - $logEntry= new LogEntry(); |
|
| 430 | + $logEntry = new LogEntry(); |
|
| 431 | 431 | $logEntryJson = $logEntry->error($exception)->toJson(); |
| 432 | 432 | |
| 433 | 433 | $query = "insert into ".TABLE_PAGANTIS_LOG."(log) values ('$logEntryJson')"; |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | * @package Test\Configure |
| 11 | 11 | * |
| 12 | 12 | * @group oscommerce-configure |
| 13 | - |
|
| 14 | 13 | */ |
| 15 | 14 | class ConfigureTest extends AbstractConfigure |
| 16 | 15 | { |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | * @package Test\Configure |
| 11 | 11 | * |
| 12 | 12 | * @group oscommerce-configure-ppp |
| 13 | - |
|
| 14 | 13 | */ |
| 15 | 14 | class ConfigurePPPTest extends AbstractConfigure |
| 16 | 15 | { |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function loginToBackOffice() |
| 19 | 19 | { |
| 20 | - $this->webDriver->get(self::OSCURL . self::BACKOFFICE_FOLDER); |
|
| 20 | + $this->webDriver->get(self::OSCURL.self::BACKOFFICE_FOLDER); |
|
| 21 | 21 | sleep(2); |
| 22 | 22 | |
| 23 | 23 | $usernameElementSearch = WebDriverBy::name('username'); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ) { |
| 35 | 35 | $this->enabled = ((MODULE_HEADER_TAGS_PAGANTIS_STATUS == 'True') && |
| 36 | 36 | (MODULE_PAYMENT_PAGANTIS_STATUS == 'True') && |
| 37 | - (MODULE_PAYMENT_PAGANTIS_SIMULATOR == 'True')) ; |
|
| 37 | + (MODULE_PAYMENT_PAGANTIS_SIMULATOR == 'True')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $this->extraConfig = $this->getExtraConfig(); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private function getConfig($config = '') |
| 68 | 68 | { |
| 69 | - $query = "select * from ".TABLE_CONFIGURATION . " where configuration_key ='" . $config . "'"; |
|
| 69 | + $query = "select * from ".TABLE_CONFIGURATION." where configuration_key ='".$config."'"; |
|
| 70 | 70 | $result = tep_db_query($query); |
| 71 | 71 | $resultArray = tep_db_fetch_array($result); |
| 72 | 72 | return $resultArray['configuration_value']; |
@@ -83,29 +83,29 @@ discard block |
||
| 83 | 83 | $checkoutPage = strpos($_SERVER[REQUEST_URI], "checkout_payment.php") > 0; |
| 84 | 84 | |
| 85 | 85 | //Show promoted html |
| 86 | - if ($this->isPromoted($productId) && $checkoutPage!='1') { |
|
| 86 | + if ($this->isPromoted($productId) && $checkoutPage != '1') { |
|
| 87 | 87 | echo "<div id='promotedText' style='display:none'><br/>".$this->extraConfig['PAGANTIS_PROMOTED_PRODUCT_CODE']."</div>"; |
| 88 | - echo '<script>'. PHP_EOL; |
|
| 89 | - echo ' function loadPromoted()'. PHP_EOL; |
|
| 90 | - echo ' {'. PHP_EOL; |
|
| 91 | - echo 'var positionSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']. '\';'. PHP_EOL; |
|
| 92 | - echo 'if (positionSelector === \'default\') {'. PHP_EOL; |
|
| 93 | - echo 'positionSelector = \'.buttonSet\''. PHP_EOL; |
|
| 94 | - echo '}'. PHP_EOL; |
|
| 88 | + echo '<script>'.PHP_EOL; |
|
| 89 | + echo ' function loadPromoted()'.PHP_EOL; |
|
| 90 | + echo ' {'.PHP_EOL; |
|
| 91 | + echo 'var positionSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'].'\';'.PHP_EOL; |
|
| 92 | + echo 'if (positionSelector === \'default\') {'.PHP_EOL; |
|
| 93 | + echo 'positionSelector = \'.buttonSet\''.PHP_EOL; |
|
| 94 | + echo '}'.PHP_EOL; |
|
| 95 | 95 | echo 'var docFather = document.querySelector(positionSelector);'.PHP_EOL; |
| 96 | - echo 'if (typeof docFather != \'undefined\') {'. PHP_EOL; |
|
| 96 | + echo 'if (typeof docFather != \'undefined\') {'.PHP_EOL; |
|
| 97 | 97 | echo 'var promotedNode = document.getElementById("promotedText");'.PHP_EOL; |
| 98 | 98 | echo 'docFather.appendChild(promotedNode);'.PHP_EOL; |
| 99 | - echo 'promotedNode.style.display=""' . PHP_EOL; |
|
| 100 | - echo ' clearInterval(window.OSPromotedId);'. PHP_EOL; |
|
| 101 | - echo ' return true;'. PHP_EOL; |
|
| 102 | - echo ' }'. PHP_EOL; |
|
| 103 | - echo ' return false;'. PHP_EOL; |
|
| 104 | - echo ' }'. PHP_EOL; |
|
| 105 | - echo ' window.OSPromotedId = setInterval(function () {'. PHP_EOL; |
|
| 106 | - echo ' loadPromoted();'. PHP_EOL; |
|
| 107 | - echo ' }, 2000);'. PHP_EOL; |
|
| 108 | - echo '</script>'. PHP_EOL; |
|
| 99 | + echo 'promotedNode.style.display=""'.PHP_EOL; |
|
| 100 | + echo ' clearInterval(window.OSPromotedId);'.PHP_EOL; |
|
| 101 | + echo ' return true;'.PHP_EOL; |
|
| 102 | + echo ' }'.PHP_EOL; |
|
| 103 | + echo ' return false;'.PHP_EOL; |
|
| 104 | + echo ' }'.PHP_EOL; |
|
| 105 | + echo ' window.OSPromotedId = setInterval(function () {'.PHP_EOL; |
|
| 106 | + echo ' loadPromoted();'.PHP_EOL; |
|
| 107 | + echo ' }, 2000);'.PHP_EOL; |
|
| 108 | + echo '</script>'.PHP_EOL; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (isset($productId) || $checkoutPage) { |
@@ -124,100 +124,100 @@ discard block |
||
| 124 | 124 | $productId = array_shift($productId); |
| 125 | 125 | $promotedProduct = $this->isPromoted($productId); |
| 126 | 126 | if ($promotedProduct) { |
| 127 | - $promotedAmount+=number_format(($item['price'] * $item['qty']), 2); |
|
| 127 | + $promotedAmount += number_format(($item['price'] * $item['qty']), 2); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - echo "<script src='".$this->sdkFile."'></script>". PHP_EOL; |
|
| 132 | - echo '<script>'. PHP_EOL; |
|
| 133 | - echo ' function loadSimulator()'. PHP_EOL; |
|
| 134 | - echo ' {'. PHP_EOL; |
|
| 135 | - echo ' if (typeof '.$simulatorCode.' != \'undefined\') {'. PHP_EOL; |
|
| 136 | - echo ' var positionSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']. '\';'. PHP_EOL; |
|
| 137 | - echo ' var priceSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']. '\';'. PHP_EOL; |
|
| 138 | - echo ' var checkoutPriceSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']. '\';'. PHP_EOL; |
|
| 139 | - echo ' var quantitySelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']. '\';'. PHP_EOL; |
|
| 140 | - echo ' var checkoutPage = \'' . $checkoutPage.'\';'. PHP_EOL; |
|
| 141 | - echo ' var promotedAmount = \'' . $promotedAmount.'\';'. PHP_EOL; |
|
| 142 | - |
|
| 143 | - echo ' if (positionSelector === \'default\') {'. PHP_EOL; |
|
| 144 | - echo ' positionSelector = \'.buttonSet\''. PHP_EOL; |
|
| 145 | - echo ' }'. PHP_EOL; |
|
| 146 | - |
|
| 147 | - echo ' if (priceSelector === \'default\') {'. PHP_EOL; |
|
| 148 | - echo ' priceSelector = \'#bodyContent>form>div>h1\''. PHP_EOL; |
|
| 149 | - echo ' }'. PHP_EOL; |
|
| 150 | - |
|
| 151 | - echo ' if (checkoutPriceSelector == \'default\' && checkoutPage == \'1\') {'. PHP_EOL; |
|
| 152 | - echo ' priceSelector = \'#columnRight > .infoBoxContainer > .infoBoxContents > tbody > tr:last-child > td\';'. PHP_EOL; |
|
| 153 | - echo ' }'. PHP_EOL; |
|
| 154 | - echo ' '.$simulatorCode.'.product_simulator = {};'. PHP_EOL; |
|
| 155 | - echo ' '.$simulatorCode.'.product_simulator.id = \'product-simulator\';'. PHP_EOL; |
|
| 156 | - echo ' '.$simulatorCode.'.product_simulator.publicKey = \'' . $this->pk . '\';'. PHP_EOL; |
|
| 157 | - echo ' '.$simulatorCode.'.product_simulator.selector = positionSelector;'. PHP_EOL; |
|
| 158 | - echo ' '.$simulatorCode.'.product_simulator.numInstalments = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] . '\';'. PHP_EOL; |
|
| 159 | - echo ' '.$simulatorCode.'.product_simulator.type = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'] . ';'. PHP_EOL; |
|
| 160 | - echo ' '.$simulatorCode.'.product_simulator.skin = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'] . ';'. PHP_EOL; |
|
| 161 | - echo ' '.$simulatorCode.'.product_simulator.position = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'] . ';'. PHP_EOL; |
|
| 131 | + echo "<script src='".$this->sdkFile."'></script>".PHP_EOL; |
|
| 132 | + echo '<script>'.PHP_EOL; |
|
| 133 | + echo ' function loadSimulator()'.PHP_EOL; |
|
| 134 | + echo ' {'.PHP_EOL; |
|
| 135 | + echo ' if (typeof '.$simulatorCode.' != \'undefined\') {'.PHP_EOL; |
|
| 136 | + echo ' var positionSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'].'\';'.PHP_EOL; |
|
| 137 | + echo ' var priceSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'].'\';'.PHP_EOL; |
|
| 138 | + echo ' var checkoutPriceSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'].'\';'.PHP_EOL; |
|
| 139 | + echo ' var quantitySelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'].'\';'.PHP_EOL; |
|
| 140 | + echo ' var checkoutPage = \''.$checkoutPage.'\';'.PHP_EOL; |
|
| 141 | + echo ' var promotedAmount = \''.$promotedAmount.'\';'.PHP_EOL; |
|
| 142 | + |
|
| 143 | + echo ' if (positionSelector === \'default\') {'.PHP_EOL; |
|
| 144 | + echo ' positionSelector = \'.buttonSet\''.PHP_EOL; |
|
| 145 | + echo ' }'.PHP_EOL; |
|
| 146 | + |
|
| 147 | + echo ' if (priceSelector === \'default\') {'.PHP_EOL; |
|
| 148 | + echo ' priceSelector = \'#bodyContent>form>div>h1\''.PHP_EOL; |
|
| 149 | + echo ' }'.PHP_EOL; |
|
| 150 | + |
|
| 151 | + echo ' if (checkoutPriceSelector == \'default\' && checkoutPage == \'1\') {'.PHP_EOL; |
|
| 152 | + echo ' priceSelector = \'#columnRight > .infoBoxContainer > .infoBoxContents > tbody > tr:last-child > td\';'.PHP_EOL; |
|
| 153 | + echo ' }'.PHP_EOL; |
|
| 154 | + echo ' '.$simulatorCode.'.product_simulator = {};'.PHP_EOL; |
|
| 155 | + echo ' '.$simulatorCode.'.product_simulator.id = \'product-simulator\';'.PHP_EOL; |
|
| 156 | + echo ' '.$simulatorCode.'.product_simulator.publicKey = \''.$this->pk.'\';'.PHP_EOL; |
|
| 157 | + echo ' '.$simulatorCode.'.product_simulator.selector = positionSelector;'.PHP_EOL; |
|
| 158 | + echo ' '.$simulatorCode.'.product_simulator.numInstalments = \''.$this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'].'\';'.PHP_EOL; |
|
| 159 | + echo ' '.$simulatorCode.'.product_simulator.type = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'].';'.PHP_EOL; |
|
| 160 | + echo ' '.$simulatorCode.'.product_simulator.skin = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'].';'.PHP_EOL; |
|
| 161 | + echo ' '.$simulatorCode.'.product_simulator.position = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'].';'.PHP_EOL; |
|
| 162 | 162 | |
| 163 | 163 | //Amount in product page |
| 164 | - echo ' var promotedProduct = \'' . $this->isPromoted($productId) .'\';'. PHP_EOL; |
|
| 164 | + echo ' var promotedProduct = \''.$this->isPromoted($productId).'\';'.PHP_EOL; |
|
| 165 | 165 | echo ' if(checkoutPage != \'1\' ) {'; |
| 166 | - echo ' '.$simulatorCode.'.product_simulator.itemAmountSelector = priceSelector;'. PHP_EOL; |
|
| 167 | - echo ' if(promotedProduct == \'1\') { ' . PHP_EOL; |
|
| 168 | - echo ' '.$simulatorCode.'.product_simulator.itemPromotedAmountSelector = priceSelector;'. PHP_EOL; |
|
| 169 | - echo ' }' . PHP_EOL; |
|
| 166 | + echo ' '.$simulatorCode.'.product_simulator.itemAmountSelector = priceSelector;'.PHP_EOL; |
|
| 167 | + echo ' if(promotedProduct == \'1\') { '.PHP_EOL; |
|
| 168 | + echo ' '.$simulatorCode.'.product_simulator.itemPromotedAmountSelector = priceSelector;'.PHP_EOL; |
|
| 169 | + echo ' }'.PHP_EOL; |
|
| 170 | 170 | echo ' }'; |
| 171 | 171 | |
| 172 | 172 | //Amount in checkout page |
| 173 | - echo ' if(promotedAmount != \'0\' && checkoutPage == \'1\' ) { ' . PHP_EOL; |
|
| 174 | - echo ' '.$simulatorCode.'.product_simulator.totalPromotedAmount = promotedAmount;'. PHP_EOL; |
|
| 175 | - echo ' '.$simulatorCode.'.product_simulator.totalAmountSelector = priceSelector;'. PHP_EOL; |
|
| 176 | - echo ' }' . PHP_EOL; |
|
| 177 | - |
|
| 178 | - echo ' '.$simulatorCode.'.simulator.init('.$simulatorCode.'.product_simulator);'. PHP_EOL; |
|
| 179 | - echo ' clearInterval(window.OSSimulatorId);'. PHP_EOL; |
|
| 180 | - echo ' return true;'. PHP_EOL; |
|
| 181 | - echo ' }'. PHP_EOL; |
|
| 182 | - echo ' return false;'. PHP_EOL; |
|
| 183 | - echo ' }'. PHP_EOL; |
|
| 184 | - echo ' window.OSSimulatorId = setInterval(function () {'. PHP_EOL; |
|
| 185 | - echo ' loadSimulator();'. PHP_EOL; |
|
| 186 | - echo ' }, 2000);'. PHP_EOL; |
|
| 187 | - echo '</script>'. PHP_EOL; |
|
| 173 | + echo ' if(promotedAmount != \'0\' && checkoutPage == \'1\' ) { '.PHP_EOL; |
|
| 174 | + echo ' '.$simulatorCode.'.product_simulator.totalPromotedAmount = promotedAmount;'.PHP_EOL; |
|
| 175 | + echo ' '.$simulatorCode.'.product_simulator.totalAmountSelector = priceSelector;'.PHP_EOL; |
|
| 176 | + echo ' }'.PHP_EOL; |
|
| 177 | + |
|
| 178 | + echo ' '.$simulatorCode.'.simulator.init('.$simulatorCode.'.product_simulator);'.PHP_EOL; |
|
| 179 | + echo ' clearInterval(window.OSSimulatorId);'.PHP_EOL; |
|
| 180 | + echo ' return true;'.PHP_EOL; |
|
| 181 | + echo ' }'.PHP_EOL; |
|
| 182 | + echo ' return false;'.PHP_EOL; |
|
| 183 | + echo ' }'.PHP_EOL; |
|
| 184 | + echo ' window.OSSimulatorId = setInterval(function () {'.PHP_EOL; |
|
| 185 | + echo ' loadSimulator();'.PHP_EOL; |
|
| 186 | + echo ' }, 2000);'.PHP_EOL; |
|
| 187 | + echo '</script>'.PHP_EOL; |
|
| 188 | 188 | |
| 189 | 189 | //Checkout simulator |
| 190 | 190 | if ($checkoutPage) { |
| 191 | - echo '<script>' . PHP_EOL; |
|
| 192 | - echo 'function checkSelected(value)'. PHP_EOL; |
|
| 193 | - echo '{ '. PHP_EOL; |
|
| 194 | - echo 'var simulator = document.getElementsByClassName("buttonSet");' . PHP_EOL; |
|
| 195 | - echo ' if(simulator == "undefined") { return false; } '. PHP_EOL; |
|
| 196 | - echo 'var pagantisCheckbox = document.querySelector("input[value=\'pagantis\']"); ' . PHP_EOL; |
|
| 197 | - echo 'var grandparentNode = pagantisCheckbox.parentNode.parentNode;' . PHP_EOL; |
|
| 198 | - echo 'if(grandparentNode == value) { var status="" } ' . PHP_EOL; |
|
| 199 | - echo 'else { var status="none";} '. PHP_EOL; |
|
| 200 | - echo 'simulator[0].style.display=status; ' . PHP_EOL; |
|
| 201 | - echo '}'. PHP_EOL; |
|
| 202 | - |
|
| 203 | - echo 'function showSimulator()'. PHP_EOL; |
|
| 204 | - echo '{'. PHP_EOL; |
|
| 205 | - echo 'var elements = document.querySelectorAll("tr[class^=\'moduleRow\']");' . PHP_EOL; |
|
| 206 | - echo 'if(elements == null) { return false };' . PHP_EOL; |
|
| 191 | + echo '<script>'.PHP_EOL; |
|
| 192 | + echo 'function checkSelected(value)'.PHP_EOL; |
|
| 193 | + echo '{ '.PHP_EOL; |
|
| 194 | + echo 'var simulator = document.getElementsByClassName("buttonSet");'.PHP_EOL; |
|
| 195 | + echo ' if(simulator == "undefined") { return false; } '.PHP_EOL; |
|
| 196 | + echo 'var pagantisCheckbox = document.querySelector("input[value=\'pagantis\']"); '.PHP_EOL; |
|
| 197 | + echo 'var grandparentNode = pagantisCheckbox.parentNode.parentNode;'.PHP_EOL; |
|
| 198 | + echo 'if(grandparentNode == value) { var status="" } '.PHP_EOL; |
|
| 199 | + echo 'else { var status="none";} '.PHP_EOL; |
|
| 200 | + echo 'simulator[0].style.display=status; '.PHP_EOL; |
|
| 201 | + echo '}'.PHP_EOL; |
|
| 202 | + |
|
| 203 | + echo 'function showSimulator()'.PHP_EOL; |
|
| 204 | + echo '{'.PHP_EOL; |
|
| 205 | + echo 'var elements = document.querySelectorAll("tr[class^=\'moduleRow\']");'.PHP_EOL; |
|
| 206 | + echo 'if(elements == null) { return false };'.PHP_EOL; |
|
| 207 | 207 | |
| 208 | 208 | echo 'for(var i = 0, max = elements.length; i < max; i++) { elements[i].onclick = function() { |
| 209 | 209 | checkSelected(this); |
| 210 | 210 | } }' . PHP_EOL; |
| 211 | 211 | echo 'clearInterval(window.OSdisplayId);'; |
| 212 | - echo 'return true;'. PHP_EOL; |
|
| 213 | - echo '};'. PHP_EOL; |
|
| 212 | + echo 'return true;'.PHP_EOL; |
|
| 213 | + echo '};'.PHP_EOL; |
|
| 214 | 214 | |
| 215 | - echo ' window.OSdisplayId = setInterval(function () {'. PHP_EOL; |
|
| 216 | - echo ' showSimulator();'. PHP_EOL; |
|
| 217 | - echo ' }, 2000);'. PHP_EOL; |
|
| 215 | + echo ' window.OSdisplayId = setInterval(function () {'.PHP_EOL; |
|
| 216 | + echo ' showSimulator();'.PHP_EOL; |
|
| 217 | + echo ' }, 2000);'.PHP_EOL; |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - echo '</script>'. PHP_EOL; |
|
| 220 | + echo '</script>'.PHP_EOL; |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * install |
| 241 | 241 | */ |
| 242 | 242 | function install() { |
| 243 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Pagantis Module', 'MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'True', '', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
| 243 | + tep_db_query("insert into ".TABLE_CONFIGURATION." (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Pagantis Module', 'MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'True', '', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * remove |
| 249 | 249 | */ |
| 250 | 250 | function remove() { |
| 251 | - tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); |
|
| 251 | + tep_db_query("delete from ".TABLE_CONFIGURATION." where configuration_key in ('".implode("', '", $this->keys())."')"); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | if ($this->extraConfig['PAGANTIS_PROMOTION'] == '') { |
| 276 | 276 | $promotedProducts = array(); |
| 277 | - } else { |
|
| 277 | + }else { |
|
| 278 | 278 | $promotedProducts = array_values((array)unserialize($this->extraConfig['PAGANTIS_PROMOTION'])); |
| 279 | 279 | } |
| 280 | 280 | |