@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | ) { |
| 36 | 36 | $this->enabled = ((MODULE_HEADER_TAGS_PAGANTIS_STATUS == 'True') && |
| 37 | 37 | (MODULE_PAYMENT_PAGANTIS_STATUS == 'True') && |
| 38 | - (MODULE_PAYMENT_PAGANTIS_SIMULATOR == 'True')) ; |
|
| 38 | + (MODULE_PAYMENT_PAGANTIS_SIMULATOR == 'True')); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $this->extraConfig = $this->getExtraConfig(); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | private function getConfig($config = '') |
| 73 | 73 | { |
| 74 | - $query = "select * from ".TABLE_CONFIGURATION . " where configuration_key ='" . $config . "'"; |
|
| 74 | + $query = "select * from ".TABLE_CONFIGURATION." where configuration_key ='".$config."'"; |
|
| 75 | 75 | $result = tep_db_query($query); |
| 76 | 76 | $resultArray = tep_db_fetch_array($result); |
| 77 | 77 | return $resultArray['configuration_value']; |
@@ -88,29 +88,29 @@ discard block |
||
| 88 | 88 | $checkoutPage = strpos($_SERVER[REQUEST_URI], "checkout_payment.php") > 0; |
| 89 | 89 | |
| 90 | 90 | //Show promoted html |
| 91 | - if ($this->isPromoted($productId) && $checkoutPage!='1') { |
|
| 91 | + if ($this->isPromoted($productId) && $checkoutPage != '1') { |
|
| 92 | 92 | echo "<div id='promotedText' style='display:none'><br/>".$this->extraConfig['PAGANTIS_PROMOTED_PRODUCT_CODE']."</div>"; |
| 93 | - echo '<script>'. PHP_EOL; |
|
| 94 | - echo ' function loadPromoted()'. PHP_EOL; |
|
| 95 | - echo ' {'. PHP_EOL; |
|
| 96 | - echo 'var positionSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']. '\';'. PHP_EOL; |
|
| 97 | - echo 'if (positionSelector === \'default\') {'. PHP_EOL; |
|
| 98 | - echo 'positionSelector = \'.buttonSet\''. PHP_EOL; |
|
| 99 | - echo '}'. PHP_EOL; |
|
| 93 | + echo '<script>'.PHP_EOL; |
|
| 94 | + echo ' function loadPromoted()'.PHP_EOL; |
|
| 95 | + echo ' {'.PHP_EOL; |
|
| 96 | + echo 'var positionSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'].'\';'.PHP_EOL; |
|
| 97 | + echo 'if (positionSelector === \'default\') {'.PHP_EOL; |
|
| 98 | + echo 'positionSelector = \'.buttonSet\''.PHP_EOL; |
|
| 99 | + echo '}'.PHP_EOL; |
|
| 100 | 100 | echo 'var docFather = document.querySelector(positionSelector);'.PHP_EOL; |
| 101 | - echo 'if (typeof docFather != \'undefined\') {'. PHP_EOL; |
|
| 101 | + echo 'if (typeof docFather != \'undefined\') {'.PHP_EOL; |
|
| 102 | 102 | echo 'var promotedNode = document.getElementById("promotedText");'.PHP_EOL; |
| 103 | 103 | echo 'docFather.appendChild(promotedNode);'.PHP_EOL; |
| 104 | - echo 'promotedNode.style.display=""' . PHP_EOL; |
|
| 105 | - echo ' clearInterval(window.OSPromotedId);'. PHP_EOL; |
|
| 106 | - echo ' return true;'. PHP_EOL; |
|
| 107 | - echo ' }'. PHP_EOL; |
|
| 108 | - echo ' return false;'. PHP_EOL; |
|
| 109 | - echo ' }'. PHP_EOL; |
|
| 110 | - echo ' window.OSPromotedId = setInterval(function () {'. PHP_EOL; |
|
| 111 | - echo ' loadPromoted();'. PHP_EOL; |
|
| 112 | - echo ' }, 2000);'. PHP_EOL; |
|
| 113 | - echo '</script>'. PHP_EOL; |
|
| 104 | + echo 'promotedNode.style.display=""'.PHP_EOL; |
|
| 105 | + echo ' clearInterval(window.OSPromotedId);'.PHP_EOL; |
|
| 106 | + echo ' return true;'.PHP_EOL; |
|
| 107 | + echo ' }'.PHP_EOL; |
|
| 108 | + echo ' return false;'.PHP_EOL; |
|
| 109 | + echo ' }'.PHP_EOL; |
|
| 110 | + echo ' window.OSPromotedId = setInterval(function () {'.PHP_EOL; |
|
| 111 | + echo ' loadPromoted();'.PHP_EOL; |
|
| 112 | + echo ' }, 2000);'.PHP_EOL; |
|
| 113 | + echo '</script>'.PHP_EOL; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | if (isset($productId) || $checkoutPage) { |
@@ -129,102 +129,102 @@ discard block |
||
| 129 | 129 | $productId = array_shift($productId); |
| 130 | 130 | $promotedProduct = $this->isPromoted($productId); |
| 131 | 131 | if ($promotedProduct) { |
| 132 | - $promotedAmount+=number_format(($item['price'] * $item['qty']), 2); |
|
| 132 | + $promotedAmount += number_format(($item['price'] * $item['qty']), 2); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - echo "<script src='".$this->sdkFile."'></script>". PHP_EOL; |
|
| 137 | - echo '<script>'. PHP_EOL; |
|
| 138 | - echo ' function loadSimulator()'. PHP_EOL; |
|
| 139 | - echo ' {'. PHP_EOL; |
|
| 140 | - echo ' if (typeof '.$simulatorCode.' != \'undefined\') {'. PHP_EOL; |
|
| 141 | - echo ' var positionSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']. '\';'. PHP_EOL; |
|
| 142 | - echo ' var priceSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']. '\';'. PHP_EOL; |
|
| 143 | - echo ' var checkoutPriceSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']. '\';'. PHP_EOL; |
|
| 144 | - echo ' var quantitySelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']. '\';'. PHP_EOL; |
|
| 145 | - echo ' var checkoutPage = \'' . $checkoutPage.'\';'. PHP_EOL; |
|
| 146 | - echo ' var promotedAmount = \'' . $promotedAmount.'\';'. PHP_EOL; |
|
| 147 | - echo ' var langCode = \'' . $this->langCode.'\';'. PHP_EOL; |
|
| 148 | - |
|
| 149 | - echo ' if (positionSelector === \'default\') {'. PHP_EOL; |
|
| 150 | - echo ' positionSelector = \'.buttonSet\''. PHP_EOL; |
|
| 151 | - echo ' }'. PHP_EOL; |
|
| 152 | - |
|
| 153 | - echo ' if (priceSelector === \'default\') {'. PHP_EOL; |
|
| 154 | - echo ' priceSelector = \'#bodyContent>form>div>h1\''. PHP_EOL; |
|
| 155 | - echo ' }'. PHP_EOL; |
|
| 156 | - |
|
| 157 | - echo ' if (checkoutPriceSelector == \'default\' && checkoutPage == \'1\') {'. PHP_EOL; |
|
| 158 | - echo ' priceSelector = \'#columnRight > .infoBoxContainer > .infoBoxContents > tbody > tr:last-child > td\';'. PHP_EOL; |
|
| 159 | - echo ' }'. PHP_EOL; |
|
| 160 | - echo ' '.$simulatorCode.'.product_simulator = {};'. PHP_EOL; |
|
| 161 | - echo ' '.$simulatorCode.'.product_simulator.id = \'product-simulator\';'. PHP_EOL; |
|
| 162 | - echo ' '.$simulatorCode.'.product_simulator.publicKey = \'' . $this->pk . '\';'. PHP_EOL; |
|
| 163 | - echo ' '.$simulatorCode.'.product_simulator.selector = positionSelector;'. PHP_EOL; |
|
| 164 | - echo ' '.$simulatorCode.'.product_simulator.numInstalments = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] . '\';'. PHP_EOL; |
|
| 165 | - echo ' '.$simulatorCode.'.product_simulator.type = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'] . ';'. PHP_EOL; |
|
| 166 | - echo ' '.$simulatorCode.'.product_simulator.skin = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'] . ';'. PHP_EOL; |
|
| 167 | - echo ' '.$simulatorCode.'.product_simulator.position = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'] . ';'. PHP_EOL; |
|
| 136 | + echo "<script src='".$this->sdkFile."'></script>".PHP_EOL; |
|
| 137 | + echo '<script>'.PHP_EOL; |
|
| 138 | + echo ' function loadSimulator()'.PHP_EOL; |
|
| 139 | + echo ' {'.PHP_EOL; |
|
| 140 | + echo ' if (typeof '.$simulatorCode.' != \'undefined\') {'.PHP_EOL; |
|
| 141 | + echo ' var positionSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'].'\';'.PHP_EOL; |
|
| 142 | + echo ' var priceSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'].'\';'.PHP_EOL; |
|
| 143 | + echo ' var checkoutPriceSelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'].'\';'.PHP_EOL; |
|
| 144 | + echo ' var quantitySelector = \''.$this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'].'\';'.PHP_EOL; |
|
| 145 | + echo ' var checkoutPage = \''.$checkoutPage.'\';'.PHP_EOL; |
|
| 146 | + echo ' var promotedAmount = \''.$promotedAmount.'\';'.PHP_EOL; |
|
| 147 | + echo ' var langCode = \''.$this->langCode.'\';'.PHP_EOL; |
|
| 148 | + |
|
| 149 | + echo ' if (positionSelector === \'default\') {'.PHP_EOL; |
|
| 150 | + echo ' positionSelector = \'.buttonSet\''.PHP_EOL; |
|
| 151 | + echo ' }'.PHP_EOL; |
|
| 152 | + |
|
| 153 | + echo ' if (priceSelector === \'default\') {'.PHP_EOL; |
|
| 154 | + echo ' priceSelector = \'#bodyContent>form>div>h1\''.PHP_EOL; |
|
| 155 | + echo ' }'.PHP_EOL; |
|
| 156 | + |
|
| 157 | + echo ' if (checkoutPriceSelector == \'default\' && checkoutPage == \'1\') {'.PHP_EOL; |
|
| 158 | + echo ' priceSelector = \'#columnRight > .infoBoxContainer > .infoBoxContents > tbody > tr:last-child > td\';'.PHP_EOL; |
|
| 159 | + echo ' }'.PHP_EOL; |
|
| 160 | + echo ' '.$simulatorCode.'.product_simulator = {};'.PHP_EOL; |
|
| 161 | + echo ' '.$simulatorCode.'.product_simulator.id = \'product-simulator\';'.PHP_EOL; |
|
| 162 | + echo ' '.$simulatorCode.'.product_simulator.publicKey = \''.$this->pk.'\';'.PHP_EOL; |
|
| 163 | + echo ' '.$simulatorCode.'.product_simulator.selector = positionSelector;'.PHP_EOL; |
|
| 164 | + echo ' '.$simulatorCode.'.product_simulator.numInstalments = \''.$this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'].'\';'.PHP_EOL; |
|
| 165 | + echo ' '.$simulatorCode.'.product_simulator.type = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'].';'.PHP_EOL; |
|
| 166 | + echo ' '.$simulatorCode.'.product_simulator.skin = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'].';'.PHP_EOL; |
|
| 167 | + echo ' '.$simulatorCode.'.product_simulator.position = '.$this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'].';'.PHP_EOL; |
|
| 168 | 168 | |
| 169 | 169 | //Amount in product page |
| 170 | - echo ' var promotedProduct = \'' . $this->isPromoted($productId) .'\';'. PHP_EOL; |
|
| 170 | + echo ' var promotedProduct = \''.$this->isPromoted($productId).'\';'.PHP_EOL; |
|
| 171 | 171 | echo ' if(checkoutPage != \'1\' ) {'; |
| 172 | - echo ' '.$simulatorCode.'.product_simulator.itemAmountSelector = priceSelector;'. PHP_EOL; |
|
| 173 | - echo ' if(promotedProduct == \'1\') { ' . PHP_EOL; |
|
| 174 | - echo ' '.$simulatorCode.'.product_simulator.itemPromotedAmountSelector = priceSelector;'. PHP_EOL; |
|
| 175 | - echo ' }' . PHP_EOL; |
|
| 172 | + echo ' '.$simulatorCode.'.product_simulator.itemAmountSelector = priceSelector;'.PHP_EOL; |
|
| 173 | + echo ' if(promotedProduct == \'1\') { '.PHP_EOL; |
|
| 174 | + echo ' '.$simulatorCode.'.product_simulator.itemPromotedAmountSelector = priceSelector;'.PHP_EOL; |
|
| 175 | + echo ' }'.PHP_EOL; |
|
| 176 | 176 | echo ' }'; |
| 177 | 177 | |
| 178 | 178 | //Amount in checkout page |
| 179 | - echo ' if(checkoutPage == \'1\' ) { ' . PHP_EOL; |
|
| 180 | - echo ' '.$simulatorCode.'.product_simulator.totalAmountSelector = priceSelector;'. PHP_EOL; |
|
| 181 | - echo ' if(promotedAmount != \'0\' && checkoutPage == \'1\' ) { ' . PHP_EOL; |
|
| 182 | - echo ' ' .$simulatorCode.'.product_simulator.totalPromotedAmount = promotedAmount;'. PHP_EOL; |
|
| 183 | - echo ' }' . PHP_EOL; |
|
| 184 | - echo ' }' . PHP_EOL; |
|
| 185 | - echo ' '.$simulatorCode.'.simulator.init('.$simulatorCode.'.product_simulator);'. PHP_EOL; |
|
| 186 | - echo ' clearInterval(window.OSSimulatorId);'. PHP_EOL; |
|
| 187 | - echo ' return true;'. PHP_EOL; |
|
| 188 | - echo ' }'. PHP_EOL; |
|
| 189 | - echo ' return false;'. PHP_EOL; |
|
| 190 | - echo ' }'. PHP_EOL; |
|
| 179 | + echo ' if(checkoutPage == \'1\' ) { '.PHP_EOL; |
|
| 180 | + echo ' '.$simulatorCode.'.product_simulator.totalAmountSelector = priceSelector;'.PHP_EOL; |
|
| 181 | + echo ' if(promotedAmount != \'0\' && checkoutPage == \'1\' ) { '.PHP_EOL; |
|
| 182 | + echo ' '.$simulatorCode.'.product_simulator.totalPromotedAmount = promotedAmount;'.PHP_EOL; |
|
| 183 | + echo ' }'.PHP_EOL; |
|
| 184 | + echo ' }'.PHP_EOL; |
|
| 185 | + echo ' '.$simulatorCode.'.simulator.init('.$simulatorCode.'.product_simulator);'.PHP_EOL; |
|
| 186 | + echo ' clearInterval(window.OSSimulatorId);'.PHP_EOL; |
|
| 187 | + echo ' return true;'.PHP_EOL; |
|
| 188 | + echo ' }'.PHP_EOL; |
|
| 189 | + echo ' return false;'.PHP_EOL; |
|
| 190 | + echo ' }'.PHP_EOL; |
|
| 191 | 191 | |
| 192 | 192 | //Invoke to main method |
| 193 | - echo ' window.OSSimulatorId = setInterval(function () {'. PHP_EOL; |
|
| 194 | - echo ' loadSimulator();'. PHP_EOL; |
|
| 195 | - echo ' }, 2000);'. PHP_EOL; |
|
| 196 | - echo '</script>'. PHP_EOL; |
|
| 193 | + echo ' window.OSSimulatorId = setInterval(function () {'.PHP_EOL; |
|
| 194 | + echo ' loadSimulator();'.PHP_EOL; |
|
| 195 | + echo ' }, 2000);'.PHP_EOL; |
|
| 196 | + echo '</script>'.PHP_EOL; |
|
| 197 | 197 | |
| 198 | 198 | //Checkout simulator |
| 199 | 199 | if ($checkoutPage) { |
| 200 | - echo '<script>' . PHP_EOL; |
|
| 201 | - |
|
| 202 | - echo 'function checkSelected(value)'. PHP_EOL; |
|
| 203 | - echo '{ '. PHP_EOL; |
|
| 204 | - echo 'var simulator = document.getElementsByClassName("buttonSet");' . PHP_EOL; |
|
| 205 | - echo ' if(simulator == "undefined") { return false; } '. PHP_EOL; |
|
| 206 | - echo 'var pagantisCheckbox = document.querySelector("input[value=\'pagantis\']"); ' . PHP_EOL; |
|
| 207 | - echo 'var grandparentNode = pagantisCheckbox.parentNode.parentNode;' . PHP_EOL; |
|
| 208 | - echo 'if(grandparentNode == value) { var status="" } ' . PHP_EOL; |
|
| 209 | - echo 'else { var status="none";} '. PHP_EOL; |
|
| 210 | - echo 'simulator[0].style.display=status; ' . PHP_EOL; |
|
| 211 | - echo '}'. PHP_EOL; |
|
| 212 | - |
|
| 213 | - echo 'function showSimulator()'. PHP_EOL; |
|
| 214 | - echo '{'. PHP_EOL; |
|
| 215 | - echo 'var elements = document.querySelectorAll("tr[class^=\'moduleRow\']");' . PHP_EOL; |
|
| 216 | - echo 'if(elements == null) { return false };' . PHP_EOL; |
|
| 200 | + echo '<script>'.PHP_EOL; |
|
| 201 | + |
|
| 202 | + echo 'function checkSelected(value)'.PHP_EOL; |
|
| 203 | + echo '{ '.PHP_EOL; |
|
| 204 | + echo 'var simulator = document.getElementsByClassName("buttonSet");'.PHP_EOL; |
|
| 205 | + echo ' if(simulator == "undefined") { return false; } '.PHP_EOL; |
|
| 206 | + echo 'var pagantisCheckbox = document.querySelector("input[value=\'pagantis\']"); '.PHP_EOL; |
|
| 207 | + echo 'var grandparentNode = pagantisCheckbox.parentNode.parentNode;'.PHP_EOL; |
|
| 208 | + echo 'if(grandparentNode == value) { var status="" } '.PHP_EOL; |
|
| 209 | + echo 'else { var status="none";} '.PHP_EOL; |
|
| 210 | + echo 'simulator[0].style.display=status; '.PHP_EOL; |
|
| 211 | + echo '}'.PHP_EOL; |
|
| 212 | + |
|
| 213 | + echo 'function showSimulator()'.PHP_EOL; |
|
| 214 | + echo '{'.PHP_EOL; |
|
| 215 | + echo 'var elements = document.querySelectorAll("tr[class^=\'moduleRow\']");'.PHP_EOL; |
|
| 216 | + echo 'if(elements == null) { return false };'.PHP_EOL; |
|
| 217 | 217 | echo 'for(var i = 0, max = elements.length; i < max; i++) { elements[i].onclick = function() { |
| 218 | 218 | checkSelected(this); |
| 219 | 219 | } }' . PHP_EOL; |
| 220 | 220 | echo 'clearInterval(window.OSdisplayId);'; |
| 221 | - echo 'return true;'. PHP_EOL; |
|
| 222 | - echo '};'. PHP_EOL; |
|
| 221 | + echo 'return true;'.PHP_EOL; |
|
| 222 | + echo '};'.PHP_EOL; |
|
| 223 | 223 | |
| 224 | - echo ' window.OSdisplayId = setInterval(function () {'. PHP_EOL; |
|
| 225 | - echo ' showSimulator();'. PHP_EOL; |
|
| 226 | - echo ' }, 2000);'. PHP_EOL; |
|
| 227 | - echo '</script>'. PHP_EOL; |
|
| 224 | + echo ' window.OSdisplayId = setInterval(function () {'.PHP_EOL; |
|
| 225 | + echo ' showSimulator();'.PHP_EOL; |
|
| 226 | + echo ' }, 2000);'.PHP_EOL; |
|
| 227 | + echo '</script>'.PHP_EOL; |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * install |
| 248 | 248 | */ |
| 249 | 249 | function install() { |
| 250 | - 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())"); |
|
| 250 | + 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())"); |
|
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * remove |
| 256 | 256 | */ |
| 257 | 257 | function remove() { |
| 258 | - tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); |
|
| 258 | + tep_db_query("delete from ".TABLE_CONFIGURATION." where configuration_key in ('".implode("', '", $this->keys())."')"); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | if ($this->extraConfig['PAGANTIS_PROMOTION'] == '') { |
| 280 | 280 | $promotedProducts = array(); |
| 281 | - } else { |
|
| 281 | + }else { |
|
| 282 | 282 | $promotedProducts = array_values((array)unserialize($this->extraConfig['PAGANTIS_PROMOTION'])); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | if (strpos($_SERVER[REQUEST_URI], "checkout_payment.php") <= 0) { |
| 70 | 70 | $this->title = MODULE_PAYMENT_PAGANTIS_TEXT_ADMIN_TITLE; // Payment module title in Admin |
| 71 | - } else { |
|
| 72 | - $this->title = MODULE_PAYMENT_PAGANTIS_TEXT_CHECKOUT .'<br/><br/><div class="buttonSet" style="display:none"></div><br/>'; // Payment module title in Catalog |
|
| 71 | + }else { |
|
| 72 | + $this->title = MODULE_PAYMENT_PAGANTIS_TEXT_CHECKOUT.'<br/><br/><div class="buttonSet" style="display:none"></div><br/>'; // Payment module title in Catalog |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->enabled = ((MODULE_PAYMENT_PAGANTIS_STATUS == 'True') ? true : false); |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | "%s://%s%s%s", |
| 80 | 80 | isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', |
| 81 | 81 | $_SERVER['SERVER_NAME'], |
| 82 | - isset($_SERVER['SERVER_PORT']) ? ":" . $_SERVER['SERVER_PORT'] : '', |
|
| 82 | + isset($_SERVER['SERVER_PORT']) ? ":".$_SERVER['SERVER_PORT'] : '', |
|
| 83 | 83 | $_SERVER['REQUEST_URI'] |
| 84 | 84 | ) |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | - $this->form_action_url = $this->base_url . '/ext/modules/payment/pagantis/bypass.php'; |
|
| 87 | + $this->form_action_url = $this->base_url.'/ext/modules/payment/pagantis/bypass.php'; |
|
| 88 | 88 | |
| 89 | 89 | if (defined('MODULE_PAYMENT_PAGANTIS_LANG_CODE')) { |
| 90 | 90 | $this->langCode = strtoupper(MODULE_PAYMENT_PAGANTIS_LANG_CODE); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $userAddress = new Address(); |
| 198 | 198 | $userAddress |
| 199 | 199 | ->setZipCode($order->billing['postcode']) |
| 200 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 200 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 201 | 201 | ->setCountryCode('ES') |
| 202 | 202 | ->setCity($order->billing['city']) |
| 203 | 203 | ->setAddress($order->billing['street_address']) |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $orderShippingAddress = new Address(); |
| 212 | 212 | $orderShippingAddress |
| 213 | 213 | ->setZipCode($order->delivery['postcode']) |
| 214 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 214 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 215 | 215 | ->setCountryCode('ES') |
| 216 | 216 | ->setCity($order->delivery['city']) |
| 217 | 217 | ->setAddress($order->delivery['street_address']) |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $orderUser = new \Pagantis\OrdersApiClient\Model\Order\User(); |
| 222 | 222 | $orderUser |
| 223 | 223 | ->setAddress($userAddress) |
| 224 | - ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
|
| 224 | + ->setFullName($order->billing['firstname'].' '.$order->billing['lastname']) |
|
| 225 | 225 | ->setBillingAddress($orderBillingAddress) |
| 226 | 226 | ->setEmail($order->customer['email_address']) |
| 227 | 227 | ->setFixPhone($order->customer['telephone']) |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | ->setQuantity(intval($item['qty'])) |
| 263 | 263 | ->setDescription($item['name']); |
| 264 | 264 | if ($promotedProduct) { |
| 265 | - $promotedAmount+=$product->getAmount(); |
|
| 265 | + $promotedAmount += $product->getAmount(); |
|
| 266 | 266 | $promotedMessage = $product->getDescription()."-Price:".$item['final_price']."-Qty:".$product->getQuantity(); |
| 267 | 267 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 268 | 268 | } |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | $cancelUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false)); |
| 285 | - if ($this->extraConfig['PAGANTIS_URL_KO']!='') { |
|
| 285 | + if ($this->extraConfig['PAGANTIS_URL_KO'] != '') { |
|
| 286 | 286 | $koUrl = $this->extraConfig['PAGANTIS_URL_KO']; |
| 287 | - } else { |
|
| 287 | + }else { |
|
| 288 | 288 | $koUrl = $cancelUrl; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -322,16 +322,16 @@ discard block |
||
| 322 | 322 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 323 | 323 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 324 | 324 | $this->insertRow($this->os_order_reference, $pagantisOrder->getId(), serialize($global_vars)); |
| 325 | - } else { |
|
| 325 | + }else { |
|
| 326 | 326 | throw new OrderNotFoundException(); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | if ($url == "") { |
| 330 | 330 | throw new UnknownException(_("No ha sido posible obtener una respuesta de Pagantis")); |
| 331 | - } else { |
|
| 331 | + }else { |
|
| 332 | 332 | $output = "\n"; |
| 333 | - $output .= tep_draw_hidden_field("formUrl", $url) . "\n"; |
|
| 334 | - $output .= tep_draw_hidden_field("cancelUrl", $cancelUrl) . "\n"; |
|
| 333 | + $output .= tep_draw_hidden_field("formUrl", $url)."\n"; |
|
| 334 | + $output .= tep_draw_hidden_field("cancelUrl", $cancelUrl)."\n"; |
|
| 335 | 335 | return $output; |
| 336 | 336 | |
| 337 | 337 | } //TODO IFRAME |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | return 'failed'; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 401 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 402 | 402 | ( |
| 403 | 403 | configuration_title, |
| 404 | 404 | configuration_key, |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | ', |
| 422 | 422 | now() |
| 423 | 423 | )"); |
| 424 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 424 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 425 | 425 | ( |
| 426 | 426 | configuration_title, |
| 427 | 427 | configuration_key, |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | '0', |
| 442 | 442 | now() |
| 443 | 443 | )"); |
| 444 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 444 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 445 | 445 | ( |
| 446 | 446 | configuration_title, |
| 447 | 447 | configuration_key, |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | '0', |
| 462 | 462 | now() |
| 463 | 463 | )"); |
| 464 | - tep_db_query("insert into " . TABLE_CONFIGURATION . " |
|
| 464 | + tep_db_query("insert into ".TABLE_CONFIGURATION." |
|
| 465 | 465 | ( |
| 466 | 466 | configuration_title, |
| 467 | 467 | configuration_key, |
@@ -493,14 +493,14 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | private function installPagantisTables() |
| 495 | 495 | { |
| 496 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_LOG . " ( |
|
| 496 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_LOG." ( |
|
| 497 | 497 | id int NOT NULL AUTO_INCREMENT, |
| 498 | 498 | log text NOT NULL, |
| 499 | 499 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
| 500 | 500 | UNIQUE KEY id (id))"; |
| 501 | 501 | tep_db_query($sql); |
| 502 | 502 | |
| 503 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONFIG . " ( |
|
| 503 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONFIG." ( |
|
| 504 | 504 | id int NOT NULL AUTO_INCREMENT, |
| 505 | 505 | config varchar(60) NOT NULL, |
| 506 | 506 | value varchar(200) NOT NULL, |
@@ -508,10 +508,10 @@ discard block |
||
| 508 | 508 | tep_db_query($sql); |
| 509 | 509 | |
| 510 | 510 | // check if table has records |
| 511 | - $check_query = tep_db_query("select value from " . TABLE_PAGANTIS_CONFIG); |
|
| 511 | + $check_query = tep_db_query("select value from ".TABLE_PAGANTIS_CONFIG); |
|
| 512 | 512 | if (tep_db_num_rows($check_query) === 0) { |
| 513 | 513 | foreach ((array)$this->defaultConfigs as $configKey => $configValue) { |
| 514 | - $query = "INSERT INTO " . TABLE_PAGANTIS_CONFIG . " |
|
| 514 | + $query = "INSERT INTO ".TABLE_PAGANTIS_CONFIG." |
|
| 515 | 515 | ( |
| 516 | 516 | config, |
| 517 | 517 | value |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_ORDERS . " ( |
|
| 528 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_ORDERS." ( |
|
| 529 | 529 | id int NOT NULL AUTO_INCREMENT, |
| 530 | 530 | os_order_id varchar(50), |
| 531 | 531 | os_order_reference varchar(50) NOT NULL, |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | UNIQUE KEY id(id))"; |
| 535 | 535 | tep_db_query($sql); |
| 536 | 536 | |
| 537 | - $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONCURRENCY . " ( |
|
| 537 | + $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONCURRENCY." ( |
|
| 538 | 538 | id varchar(50) NOT NULL, |
| 539 | 539 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 540 | 540 | UNIQUE KEY id(id))"; |
@@ -546,29 +546,29 @@ discard block |
||
| 546 | 546 | */ |
| 547 | 547 | public function remove() |
| 548 | 548 | { |
| 549 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_LOG . "'"); |
|
| 549 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_LOG."'"); |
|
| 550 | 550 | if (tep_db_num_rows($checkTable) > 0) { |
| 551 | - tep_db_query("drop table " . TABLE_PAGANTIS_LOG); |
|
| 551 | + tep_db_query("drop table ".TABLE_PAGANTIS_LOG); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONFIG . "'"); |
|
| 554 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'"); |
|
| 555 | 555 | if (tep_db_num_rows($checkTable) > 0) { |
| 556 | - tep_db_query("drop table " . TABLE_PAGANTIS_CONFIG); |
|
| 556 | + tep_db_query("drop table ".TABLE_PAGANTIS_CONFIG); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_ORDERS . "'"); |
|
| 559 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_ORDERS."'"); |
|
| 560 | 560 | if (tep_db_num_rows($checkTable) > 0) { |
| 561 | - tep_db_query("drop table " . TABLE_PAGANTIS_ORDERS); |
|
| 561 | + tep_db_query("drop table ".TABLE_PAGANTIS_ORDERS); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONCURRENCY . "'"); |
|
| 564 | + $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONCURRENCY."'"); |
|
| 565 | 565 | if (tep_db_num_rows($checkTable) > 0) { |
| 566 | - tep_db_query("drop table " . TABLE_PAGANTIS_CONCURRENCY); |
|
| 566 | + tep_db_query("drop table ".TABLE_PAGANTIS_CONCURRENCY); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - tep_db_query("DELETE FROM ". TABLE_CONFIGURATION ." where configuration_key in ('MODULE_PAYMENT_PAGANTIS_STATUS','MODULE_PAYMENT_PAGANTIS_PK','MODULE_PAYMENT_PAGANTIS_SK')"); |
|
| 569 | + tep_db_query("DELETE FROM ".TABLE_CONFIGURATION." where configuration_key in ('MODULE_PAYMENT_PAGANTIS_STATUS','MODULE_PAYMENT_PAGANTIS_PK','MODULE_PAYMENT_PAGANTIS_SK')"); |
|
| 570 | 570 | |
| 571 | - $query = "delete from " . TABLE_CONFIGURATION . " where configuration_key like '%_PAGANTIS_%'"; |
|
| 571 | + $query = "delete from ".TABLE_CONFIGURATION." where configuration_key like '%_PAGANTIS_%'"; |
|
| 572 | 572 | tep_db_query($query); |
| 573 | 573 | |
| 574 | 574 | $this->uninstallSimulator(); |
@@ -623,13 +623,13 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | private function insertRow($orderId, $pagantisOrderId, $globalVars) |
| 625 | 625 | { |
| 626 | - $query = "select * from " . TABLE_PAGANTIS_ORDERS . " where os_order_reference='$orderId'"; |
|
| 626 | + $query = "select * from ".TABLE_PAGANTIS_ORDERS." where os_order_reference='$orderId'"; |
|
| 627 | 627 | $resultsSelect = tep_db_query($query); |
| 628 | 628 | $countResults = tep_db_num_rows($resultsSelect); |
| 629 | 629 | if ($countResults == 0) { |
| 630 | - $query = "INSERT INTO " . TABLE_PAGANTIS_ORDERS . " |
|
| 630 | + $query = "INSERT INTO ".TABLE_PAGANTIS_ORDERS." |
|
| 631 | 631 | (os_order_reference, pagantis_order_id, globals) values ('$orderId', '$pagantisOrderId','$globalVars')"; |
| 632 | - } else { |
|
| 632 | + }else { |
|
| 633 | 633 | $query = "UPDATE ".TABLE_PAGANTIS_ORDERS." set pagantis_order_id='$pagantisOrderId' |
| 634 | 634 | where os_order_reference='$orderId'"; |
| 635 | 635 | } |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | if ($this->extraConfig['PAGANTIS_PROMOTION'] == '') { |
| 669 | 669 | $promotedProducts = array(); |
| 670 | - } else { |
|
| 670 | + }else { |
|
| 671 | 671 | $promotedProducts = array_values((array)unserialize($this->extraConfig['PAGANTIS_PROMOTION'])); |
| 672 | 672 | } |
| 673 | 673 | |
@@ -680,13 +680,13 @@ discard block |
||
| 680 | 680 | private function getDescription() |
| 681 | 681 | { |
| 682 | 682 | $descriptionCode = "<img src=\"images/icon_info.gif\" border=\"0\" alt=\"Info\" title=\"Info\"> <strong>Module version:</strong> $this->version<br/><br/>"; |
| 683 | - $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/>"; |
|
| 684 | - $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/>"; |
|
| 683 | + $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/>"; |
|
| 684 | + $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/>"; |
|
| 685 | 685 | |
| 686 | 686 | if (MODULE_PAYMENT_PAGANTIS_STATUS == 'True') { |
| 687 | 687 | $pagantisPromotionUrl = $this->base_url.'/admin/promotion.php'; |
| 688 | 688 | $linkDescription = "Si deseas ofrecer financiación sin intereses para alguno de tus productos "; |
| 689 | - $descriptionCode.= "<img src='images/icon_info.gif' border='0'/> $linkDescription<a href='$pagantisPromotionUrl' style='text-decoration: underline; font-weight: bold;'>haz click aquí</a>"; |
|
| 689 | + $descriptionCode .= "<img src='images/icon_info.gif' border='0'/> $linkDescription<a href='$pagantisPromotionUrl' style='text-decoration: underline; font-weight: bold;'>haz click aquí</a>"; |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | return $descriptionCode; |
@@ -697,18 +697,18 @@ discard block |
||
| 697 | 697 | */ |
| 698 | 698 | private function installSimulator() |
| 699 | 699 | { |
| 700 | - $checkSimulator = tep_db_query("select configuration_key, configuration_value from " .TABLE_CONFIGURATION ." |
|
| 700 | + $checkSimulator = tep_db_query("select configuration_key, configuration_value from ".TABLE_CONFIGURATION." |
|
| 701 | 701 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED' |
| 702 | 702 | and configuration_value like '%ht_pagantis.php%';"); |
| 703 | 703 | if (tep_db_num_rows($checkSimulator) > 0) { |
| 704 | 704 | return true; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $query = "UPDATE " . TABLE_CONFIGURATION . " set configuration_value = concat(configuration_value, ';ht_pagantis.php') |
|
| 707 | + $query = "UPDATE ".TABLE_CONFIGURATION." set configuration_value = concat(configuration_value, ';ht_pagantis.php') |
|
| 708 | 708 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED'"; |
| 709 | 709 | tep_db_query($query); |
| 710 | 710 | |
| 711 | - 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())"); |
|
| 711 | + 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())"); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -716,18 +716,18 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | private function uninstallSimulator() |
| 718 | 718 | { |
| 719 | - $checkSimulator = tep_db_query("select configuration_key, configuration_value from " .TABLE_CONFIGURATION ." |
|
| 719 | + $checkSimulator = tep_db_query("select configuration_key, configuration_value from ".TABLE_CONFIGURATION." |
|
| 720 | 720 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED' |
| 721 | 721 | and configuration_value like '%ht_pagantis.php%';"); |
| 722 | 722 | if (tep_db_num_rows($checkSimulator) == 0) { |
| 723 | 723 | return true; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - $query = "UPDATE " . TABLE_CONFIGURATION . " set configuration_value = REPLACE(configuration_value, ';ht_pagantis.php', '') |
|
| 726 | + $query = "UPDATE ".TABLE_CONFIGURATION." set configuration_value = REPLACE(configuration_value, ';ht_pagantis.php', '') |
|
| 727 | 727 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED'"; |
| 728 | 728 | tep_db_query($query); |
| 729 | 729 | |
| 730 | - $query = "delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_HEADER_TAGS_PAGANTIS_STATUS'"; |
|
| 730 | + $query = "delete from ".TABLE_CONFIGURATION." where configuration_key = 'MODULE_HEADER_TAGS_PAGANTIS_STATUS'"; |
|
| 731 | 731 | tep_db_query($query); |
| 732 | 732 | } |
| 733 | 733 | |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | private function insertLog($exception) |
| 738 | 738 | { |
| 739 | 739 | if ($exception instanceof \Exception) { |
| 740 | - $logEntry= new LogEntry(); |
|
| 740 | + $logEntry = new LogEntry(); |
|
| 741 | 741 | $logEntryJson = $logEntry->error($exception)->toJson(); |
| 742 | 742 | |
| 743 | 743 | $query = "insert into ".TABLE_PAGANTIS_LOG."(log) values ($logEntryJson)"; |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | return $order->customer['national_id']; |
| 756 | 756 | } elseif (isset($order->billing['piva'])) { |
| 757 | 757 | return $order->billing['piva']; |
| 758 | - } else { |
|
| 758 | + }else { |
|
| 759 | 759 | return null; |
| 760 | 760 | } |
| 761 | 761 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | return $order->customer['tax_id']; |
| 771 | 771 | } elseif (isset($order->billing['cf'])) { |
| 772 | 772 | return $order->billing['cf']; |
| 773 | - } else { |
|
| 773 | + }else { |
|
| 774 | 774 | return null; |
| 775 | 775 | } |
| 776 | 776 | } |