|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright since 2007 PrestaShop SA and Contributors |
| 4 | + * PrestaShop is an International Registered Trademark & Property of PrestaShop SA |
| 5 | + * |
| 6 | + * NOTICE OF LICENSE |
| 7 | + * |
| 8 | + * This source file is subject to the Academic Free License version 3.0 |
| 9 | + * that is bundled with this package in the file LICENSE.md. |
| 10 | + * It is also available through the world-wide-web at this URL: |
| 11 | + * https://opensource.org/licenses/AFL-3.0 |
| 12 | + * If you did not receive a copy of the license and are unable to |
| 13 | + * obtain it through the world-wide-web, please send an email |
| 14 | + * to [email protected] so we can send you a copy immediately. |
| 15 | + * |
| 16 | + * @author PrestaShop SA and Contributors <[email protected]> |
| 17 | + * @copyright Since 2007 PrestaShop SA and Contributors |
| 18 | + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 |
| 19 | + */ |
| 20 | +if (!defined('_PS_VERSION_')) { |
| 21 | + exit; |
| 22 | +} |
| 23 | + |
| 24 | +/** |
| 25 | + * Update main function for module version 8.4.1.0 |
| 26 | + * |
| 27 | + * @param Ps_checkout $module |
| 28 | + * |
| 29 | + * @return bool |
| 30 | + */ |
| 31 | +function upgrade_module_8_4_1_0($module) |
| 32 | +{ |
| 33 | + try { |
| 34 | + $db = Db::getInstance(); |
| 35 | + $shopsList = \Shop::getShops(false, null, true); |
| 36 | + |
| 37 | + foreach ($shopsList as $shopId) { |
| 38 | + $isGooglePayEligible = (bool) \Configuration::get( |
| 39 | + 'PS_CHECKOUT_GOOGLE_PAY', |
| 40 | + null, |
| 41 | + null, |
| 42 | + $shopId |
| 43 | + ); |
| 44 | + $hasFundingSourceGooglePay = (bool) $db->getValue(' |
| 45 | + SELECT 1 |
| 46 | + FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source` |
| 47 | + WHERE `name` = "google_pay" |
| 48 | + AND `id_shop` = ' . (int) $shopId |
| 49 | + ); |
| 50 | + |
| 51 | + if (!$hasFundingSourceGooglePay) { |
| 52 | + $db->insert( |
| 53 | + 'pscheckout_funding_source', |
| 54 | + [ |
| 55 | + 'name' => 'google_pay', |
| 56 | + 'position' => 11, |
| 57 | + 'active' => (int) $isGooglePayEligible, |
| 58 | + 'id_shop' => (int) $shopId, |
| 59 | + ] |
| 60 | + ); |
| 61 | + } |
| 62 | + } |
| 63 | + } catch (Exception $exception) { |
| 64 | + PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id); |
| 65 | + |
| 66 | + return false; |
| 67 | + } |
| 68 | + |
| 69 | + return true; |
| 70 | +} |
0 commit comments