Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,52 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 3.0.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_3_0_0(Ps_checkout $module)
{
// Force PrestaShop to upgrade for all shop to avoid issues
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
$shopsList = \Shop::getShops(false, null, true);
$module->registerHook('actionObjectShopDeleteAfter', $shopsList);
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
return true;
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 3.1.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_3_1_0($module)
{
// Force PrestaShop to upgrade for all shop to avoid issues
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
$shopsList = \Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
Configuration::updateValue('PS_CHECKOUT_LIABILITY_SHIFT_REQ', '1', false, null, (int) $shopId);
}
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
return true;
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.3.3.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_3_3_0(Ps_checkout $module)
{
// Force PrestaShop to upgrade for all shop to avoid issues
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
$module->registerHook('displayPaymentReturn');
$module->registerHook('displayOrderDetail');
try {
$db = Db::getInstance();
$db->delete(
'pscheckout_cart',
'paypal_order IS NULL'
);
$db->update(
'pscheckout_cart',
[
'paypal_token' => null,
'paypal_token_expire' => null,
],
'paypal_token IS NOT NULL',
0,
true
);
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 3, $exception->getCode(), 'Module', $module->id);
return false;
}
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
return true;
}

View File

@@ -0,0 +1,273 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.3.4.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_3_4_0(Ps_checkout $module)
{
// Force PrestaShop to upgrade for all shop to avoid issues
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
try {
$shopsList = Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
Configuration::updateValue('PS_CHECKOUT_LIABILITY_SHIFT_REQ', '0', false, null, (int) $shopId);
}
Configuration::updateGlobalValue('PS_CHECKOUT_LIABILITY_SHIFT_REQ', '0');
$db = Db::getInstance();
// Check module OrderState
$moduleOrderStates = [
'PS_CHECKOUT_STATE_PENDING' => (int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_PENDING'),
'PS_CHECKOUT_STATE_COMPLETED' => (int) Configuration::getGlobalValue('PS_OS_PAYMENT'),
'PS_CHECKOUT_STATE_CANCELED' => (int) Configuration::getGlobalValue('PS_OS_CANCELED'),
'PS_CHECKOUT_STATE_ERROR' => (int) Configuration::getGlobalValue('PS_OS_ERROR'),
'PS_CHECKOUT_STATE_REFUNDED' => (int) Configuration::getGlobalValue('PS_OS_REFUND'),
'PS_CHECKOUT_STATE_PARTIALLY_REFUNDED' => (int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_PARTIAL_REFUND'),
'PS_CHECKOUT_STATE_PARTIALLY_PAID' => (int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_PARTIALLY_PAID'),
'PS_CHECKOUT_STATE_AUTHORIZED' => (int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_AUTHORIZED'),
];
$moduleOrderStatesId = array_values($moduleOrderStates);
$moduleOrderStatesIdToDelete = [
(int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_WAITING_PAYPAL_PAYMENT'),
(int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_WAITING_CREDIT_CARD_PAYMENT'),
(int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_WAITING_LOCAL_PAYMENT'),
(int) Configuration::getGlobalValue('PS_CHECKOUT_STATE_WAITING_CAPTURE'),
];
$orderStateCollection = new PrestaShopCollection(OrderState::class);
$orderStateCollection->where('module_name', '=', $module->name);
$orderStateCollection->where('deleted', '=', '0');
/** @var OrderState[] $orderStates */
$orderStates = $orderStateCollection->getResults();
$currentModuleOrderStatesId = [];
if (!empty($orderStates)) {
foreach ($orderStates as $orderState) {
$orderStateId = (int) $orderState->id;
if (
!in_array($orderStateId, $moduleOrderStatesId, true)
|| in_array($orderState->id, $moduleOrderStatesIdToDelete, true)
) {
$orderState->deleted = true;
$orderState->save();
} else {
$currentModuleOrderStatesId[] = $orderStateId;
}
}
}
foreach ($moduleOrderStates as $configuration_key => $id_order_state) {
if (
!$id_order_state
|| !in_array((int) $id_order_state, $currentModuleOrderStatesId, true)
) {
switch ($configuration_key) {
case 'PS_CHECKOUT_STATE_AUTHORIZED':
ps_checkout_create_order_state_8_3_4_0(
'PS_CHECKOUT_STATE_AUTHORIZED',
'#3498D8',
[
'en' => 'Authorized. To be captured by merchant',
'fr' => 'Autorisation. A capturer par le marchand',
'es' => 'Autorizado. El vendedor lo capturará',
'it' => 'Autorizzato. Sarà acquisito dal commerciante',
'nl' => 'Goedgekeurd. Door retailer te registreren.',
'de' => 'Autorisiert. Wird von Händler erfasst.',
'pl' => 'Pomyślna autoryzacja. Transfer do przeprowadzenia przez sklep',
'pt' => 'Autorizado. A ser capturado pelo comerciante',
]
);
break;
case 'PS_CHECKOUT_STATE_PARTIALLY_REFUNDED':
ps_checkout_create_order_state_8_3_4_0(
'PS_CHECKOUT_STATE_PARTIALLY_REFUNDED',
'#01B887',
[
'en' => 'Partial refund',
'fr' => 'Remboursement partiel',
'es' => 'Reembolso parcial',
'it' => 'Rimborso parziale',
'nl' => 'Gedeeltelijke terugbetaling',
'de' => 'Teilweise Rückerstattung',
'pl' => 'Częściowy zwrot',
'pt' => 'Reembolso parcial',
]
);
break;
case 'PS_CHECKOUT_STATE_PENDING':
ps_checkout_create_order_state_8_3_4_0('PS_CHECKOUT_STATE_PENDING', '#34209E', [
'en' => 'Waiting for payment',
'fr' => 'En attente de paiement',
'es' => 'Esperando el pago',
'it' => 'In attesa di pagamento',
'nl' => 'Wachten op betaling',
'de' => 'Warten auf Zahlung',
'pl' => 'Oczekiwanie na płatność',
'pt' => 'Aguardando pagamento',
]);
break;
case 'PS_CHECKOUT_STATE_PARTIALLY_PAID':
ps_checkout_create_order_state_8_3_4_0(
'PS_CHECKOUT_STATE_PARTIALLY_PAID',
'#3498D8',
[
'en' => 'Partial payment',
'fr' => 'Paiement partiel',
'es' => 'Pago parcial',
'it' => 'Pagamento parziale',
'nl' => 'Gedeeltelijke betaling',
'de' => 'Teilweise Zahlung',
'pl' => 'Częściowa płatność',
'pt' => 'Pagamento parcial',
]
);
break;
default:
Configuration::updateGlobalValue($configuration_key, $id_order_state);
}
} else {
Configuration::updateGlobalValue($configuration_key, $id_order_state);
}
}
// Installing FundingSource if table pscheckout_funding_source is empty or incomplete - including BLIK
$fundingSources = ['paypal', 'paylater', 'card', 'bancontact', 'eps', 'ideal', 'mybank', 'p24', 'blik'];
$availableFundingSourcesByShops = [];
$maxPositionByShops = [];
$availableFundingSources = $db->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'pscheckout_funding_source');
if (!empty($availableFundingSources)) {
foreach ($availableFundingSources as $availableFundingSource) {
$currentPosition = (int) $availableFundingSource['position'];
$shopId = (int) $availableFundingSource['id_shop'];
if (
!isset($maxPositionByShops[$shopId])
|| $maxPositionByShops[$shopId] < $currentPosition
) {
$maxPositionByShops[$shopId] = $currentPosition;
}
$availableFundingSourcesByShops[$shopId][] = $availableFundingSource['name'];
}
}
foreach ($shopsList as $shopId) {
$currentPosition = isset($maxPositionByShops[(int) $shopId]) ? $maxPositionByShops[(int) $shopId] + 1 : 1;
foreach ($fundingSources as $fundingSource) {
if (
!isset($availableFundingSourcesByShops[(int) $shopId])
|| !in_array($fundingSource, $availableFundingSourcesByShops[(int) $shopId], true)
) {
$db->insert(
'pscheckout_funding_source',
[
'name' => pSQL($fundingSource),
'active' => 1,
'position' => (int) $currentPosition,
'id_shop' => (int) $shopId,
]
);
++$currentPosition;
}
}
}
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 3, $exception->getCode(), 'Module', $module->id);
return false;
}
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
return true;
}
function ps_checkout_create_order_state_8_3_4_0($configuration_key, $color, $nameByLangIsoCode)
{
$orderStateNameByLangId = [];
foreach (Language::getLanguages(false) as $language) {
$languageIsoCode = Tools::strtolower($language['iso_code']);
if (isset($nameByLangIsoCode[$languageIsoCode])) {
$orderStateNameByLangId[(int) $language['id_lang']] = $nameByLangIsoCode[$languageIsoCode];
} elseif (isset($nameByLangIsoCode['en'])) {
$orderStateNameByLangId[(int) $language['id_lang']] = $nameByLangIsoCode['en'];
}
}
$orderState = new OrderState();
$orderState->name = $orderStateNameByLangId;
$orderState->module_name = 'ps_checkout';
$orderState->unremovable = true;
$orderState->color = $color;
$orderState->delivery = false;
$orderState->shipped = false;
$orderState->pdf_delivery = false;
$orderState->pdf_invoice = false;
$orderState->hidden = false;
$orderState->invoice = false;
$orderState->send_email = false;
$orderState->paid = false;
$orderState->logable = false;
$orderState->deleted = false;
$orderState->template = [];
$orderState->save();
Configuration::updateGlobalValue($configuration_key, $orderState->id);
$orderStateImage = $configuration_key === 'PS_CHECKOUT_STATE_PARTIALLY_REFUNDED' ? 'refund.gif' : 'waiting.gif';
$moduleOrderStateImgPath = _PS_MODULE_DIR_ . 'ps_checkout/views/img/OrderStatesIcons/' . $orderStateImage;
$coreOrderStateImgPath = _PS_IMG_DIR_ . 'os/' . $orderState->id . '.gif';
if (
Tools::file_exists_cache($moduleOrderStateImgPath)
&& !Tools::file_exists_cache($coreOrderStateImgPath)
&& is_writable(_PS_IMG_DIR_ . 'os/')
) {
Tools::copy($moduleOrderStateImgPath, $coreOrderStateImgPath);
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.3.5.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_3_5_0(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$databaseFields = [];
$fields = $db->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'pscheckout_cart`');
if (!empty($fields)) {
foreach ($fields as $field) {
if (isset($field['Field'])) {
$databaseFields[] = $field['Field'];
}
}
}
if (!empty($databaseFields) && !in_array('environment', $databaseFields, true)) {
$db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_cart` ADD COLUMN `environment` varchar(20) DEFAULT NULL;');
}
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.3.6.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_3_6_0(Ps_checkout $module)
{
// Force PrestaShop to upgrade for all shop to avoid issues
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
try {
$shopsList = Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
// Require the liability shift for all shops
Configuration::updateValue('PS_CHECKOUT_LIABILITY_SHIFT_REQ', '1', false, null, (int) $shopId);
// Update global value only if it is not already set to SCA_ALWAYS
if (Configuration::get('PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES', null, null, $shopId) !== 'SCA_ALWAYS') {
Configuration::updateValue('PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES', 'SCA_WHEN_REQUIRED', false, null, (int) $shopId);
}
}
// Require the liability shift for all shops
Configuration::updateGlobalValue('PS_CHECKOUT_LIABILITY_SHIFT_REQ', '1');
// Update global value only if it is not already set to SCA_ALWAYS
if (Configuration::getGlobalValue('PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES') !== 'SCA_ALWAYS') {
Configuration::updateGlobalValue('PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES', 'SCA_WHEN_REQUIRED');
}
// Add new configuration for displaying the logo on the product page and the cart
Configuration::updateGlobalValue('PS_CHECKOUT_DISPLAY_LOGO_PRODUCT', '1');
Configuration::updateGlobalValue('PS_CHECKOUT_DISPLAY_LOGO_CART', '1');
// Remove Sofort
Db::getInstance()->delete(
'pscheckout_funding_source',
'name LIKE "sofort"'
);
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 3, $exception->getCode(), 'Module', $module->id);
return false;
}
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
return true;
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.3.6.3
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_3_6_3(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$db->update('pscheckout_cart', ['paypal_token' => null, 'paypal_token_expire' => null], 'paypal_token IS NOT NULL', 0, true);
$db->update('pscheckout_cart', ['paypal_status' => 'CANCELED'], 'paypal_status = "CREATED" AND date_add < DATE_SUB(NOW(), INTERVAL 1 HOUR)');
$db->delete('pscheckout_cart', 'paypal_order IS NULL OR paypal_order = ""');
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
}
return true;
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.4.0.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_4_0_0(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_order` (
`id` varchar(50) NOT NULL,
`id_cart` int unsigned NOT NULL,
`status` varchar(30) NOT NULL,
`intent` varchar(50) DEFAULT "CAPTURE",
`funding_source` varchar(50) NOT NULL,
`payment_source` text,
`environment` varchar(50) NOT NULL,
`is_card_fields` tinyint(1) NOT NULL,
`is_express_checkout` tinyint(1) NOT NULL,
`customer_intent` varchar(50),
`payment_token_id` varchar(50),
PRIMARY KEY (`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_capture` (
`id` varchar(50) NOT NULL,
`id_order` varchar(50) NOT NULL,
`status` varchar(30) NOT NULL,
`final_capture` tinyint(1) NOT NULL,
`created_at` varchar(50) NOT NULL,
`updated_at` varchar(50) NOT NULL,
`seller_protection` text,
`seller_receivable_breakdown` text,
PRIMARY KEY (`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_refund` (
`id` varchar(50) NOT NULL,
`id_order` varchar(50) NOT NULL,
`status` varchar(30) NOT NULL,
`invoice_id` varchar(50) NOT NULL,
`custom_id` varchar(50) NOT NULL,
`acquirer_reference_number` varchar(50) NOT NULL,
`seller_payable_breakdown` text,
`id_order_slip` INT UNSIGNED,
PRIMARY KEY (`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_authorization` (
`id` varchar(50) NOT NULL,
`id_order` varchar(50) NOT NULL,
`status` varchar(30) NOT NULL,
`expiration_time` varchar(50) NOT NULL,
`seller_protection` text,
PRIMARY KEY (`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_purchase_unit` (
`id_order` varchar(50) NOT NULL,
`checksum` varchar(50) NOT NULL,
`reference_id` varchar(50) NOT NULL,
`items` text,
PRIMARY KEY (`reference_id`, `id_order`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_customer` (
`id_customer` int unsigned NOT NULL,
`paypal_customer_id` varchar(50) NOT NULL,
PRIMARY KEY (`id_customer`, `paypal_customer_id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_payment_token` (
`id` INT UNSIGNED AUTO_INCREMENT,
`token_id` varchar(50) NOT NULL,
`paypal_customer_id` varchar(50) NOT NULL,
`payment_source` varchar(50) NOT NULL,
`data` text NOT NULL,
`merchant_id` varchar(50) NOT NULL,
`status` varchar(50) NOT NULL,
`is_favorite` tinyint(1) unsigned DEFAULT 0 NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `token_id_merchant_id_paypal_customer_id` (`token_id`, `merchant_id`, `paypal_customer_id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_cart` CHANGE `paypal_status` `paypal_status` VARCHAR(30) NULL; ');
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.4.1.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_4_1_0(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$shopsList = \Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
$isGooglePayEligible = (bool) \Configuration::get(
'PS_CHECKOUT_GOOGLE_PAY',
null,
null,
$shopId
);
$hasFundingSourceGooglePay = (bool) $db->getValue(
'
SELECT 1
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
WHERE `name` = "google_pay"
AND `id_shop` = ' . (int) $shopId
);
if (!$hasFundingSourceGooglePay) {
$db->insert(
'pscheckout_funding_source',
[
'name' => 'google_pay',
'position' => 11,
'active' => (int) $isGooglePayEligible,
'id_shop' => (int) $shopId,
]
);
}
}
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.4.2.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_8_4_2_0(Ps_checkout $module)
{
try {
$module->registerHook('moduleRoutes');
$db = Db::getInstance();
$shopsList = \Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
$hasFundingSourceApplePay = (bool) $db->getValue(
'
SELECT 1
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
WHERE `name` = "apple_pay"
AND `id_shop` = ' . (int) $shopId
);
if (!$hasFundingSourceApplePay) {
$db->insert(
'pscheckout_funding_source',
[
'name' => 'apple_pay',
'position' => 12,
'active' => 0,
'id_shop' => (int) $shopId,
]
);
}
}
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 8.5.0.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_9_5_0_0(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_tracking` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_order` int(10) unsigned NOT NULL,
`tracking_number` varchar(64) NOT NULL,
`carrier_id` int(10) unsigned NOT NULL,
`carrier_name` varchar(64) NOT NULL,
`paypal_order_id` varchar(50) NOT NULL,
`paypal_capture_id` varchar(50) NOT NULL,
`tracker_id` varchar(64) DEFAULT NULL,
`items` text DEFAULT NULL,
`status` varchar(20) NOT NULL DEFAULT "PENDING",
`paypal_tracking_status` varchar(20) DEFAULT NULL,
`payload_checksum` varchar(64) NOT NULL,
`sent_to_paypal` tinyint(1) NOT NULL DEFAULT 0,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `id_order` (`id_order`),
KEY `tracking_number` (`tracking_number`),
KEY `paypal_order_id` (`paypal_order_id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$fields = $db->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'pscheckout_order`');
if (!empty($fields)) {
$field = array_filter($fields, function ($field) {
return $field['Field'] === 'tags';
});
if (empty($field)) {
$db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_order` ADD COLUMN `tags` varchar(255) DEFAULT NULL;');
}
}
$module->registerHook('actionGetOrderShipments');
$module->registerHook('actionObjectOrderCarrierUpdateAfter');
// Remove Giropay
Db::getInstance()->delete(
'pscheckout_funding_source',
'name LIKE "giropay"'
);
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Update main function for module version 9.5.1.0
*
* @param Ps_checkout $module
*
* @return bool
*/
function upgrade_module_9_5_1_0(Ps_checkout $module)
{
try {
$db = Db::getInstance();
$savedShopContext = Shop::getContext();
$savedShopId = Shop::getContextShopID();
$savedGroupShopId = Shop::getContextShopGroupID();
Shop::setContext(Shop::CONTEXT_ALL);
$shopsList = \Shop::getShops(false, null, true);
foreach ($shopsList as $shopId) {
$configuration = json_encode([
'cart' => [
'placement' => 'cart',
'status' => (bool) \Configuration::get(
'PS_CHECKOUT_PAY_LATER_ORDER_PAGE_BANNER',
null,
null,
$shopId
) ? 'enabled' : 'disabled',
'layout' => 'text',
'logo-type' => 'inline',
'text-color' => 'black',
'text-size' => '12',
],
'category' => [
'placement' => 'category',
'status' => (bool) \Configuration::get(
'PS_CHECKOUT_PAY_LATER_CATEGORY_PAGE_BANNER',
null,
null,
$shopId
) ? 'enabled' : 'disabled',
'color' => 'white',
'layout' => 'flex',
'ratio' => '8x1',
],
'checkout' => [
'placement' => 'checkout',
'status' => (bool) \Configuration::get(
'PS_CHECKOUT_PAY_LATER_ORDER_PAGE_BANNER',
null,
null,
$shopId
) ? 'enabled' : 'disabled',
'layout' => 'text',
'logo-type' => 'inline',
'text-color' => 'black',
'text-size' => '12',
],
'homepage' => [
'placement' => 'homepage',
'status' => (bool) \Configuration::get(
'PS_CHECKOUT_PAY_LATER_HOME_PAGE_BANNER',
null,
null,
$shopId
) ? 'enabled' : 'disabled',
'color' => 'white',
'layout' => 'flex',
'ratio' => '8x1',
],
'product' => [
'placement' => 'product',
'status' => (bool) \Configuration::get(
'PS_CHECKOUT_PAY_LATER_PRODUCT_PAGE',
null,
null,
$shopId
) ? 'enabled' : 'disabled',
'layout' => 'text',
'logo-type' => 'inline',
'text-color' => 'black',
'text-size' => '12',
],
]);
Configuration::updateValue('PS_CHECKOUT_PAY_LATER_CONFIG', $configuration, false, null, (int) $shopId);
foreach (['venmo', 'pay_upon_invoice'] as $paymentOption) {
$maxPosition = (int) $db->getValue(
'
SELECT MAX(position)
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
WHERE `id_shop` = ' . (int) $shopId
);
$paymentExists = $db->getValue(
'
SELECT COUNT(*)
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
WHERE `name` = "' . pSQL($paymentOption) . '" AND `id_shop` = ' . (int) $shopId
);
if (!$paymentExists) {
$db->insert('pscheckout_funding_source', [
'name' => pSQL($paymentOption),
'active' => 0,
'position' => $maxPosition + 1,
'id_shop' => (int) $shopId,
]);
}
}
}
// Restore initial PrestaShop shop context
if (Shop::CONTEXT_SHOP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedShopId);
} elseif (Shop::CONTEXT_GROUP === $savedShopContext) {
Shop::setContext($savedShopContext, $savedGroupShopId);
} else {
Shop::setContext($savedShopContext);
}
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
return false;
}
return true;
}