<?php

declare(strict_types=1);

/**
 * Copyright 2024-2025 Simply.IN Sp. z o.o.
 *
 * NOTICE OF LICENSE
 *
 * Licensed under the EUPL-1.2 or later.
 * You may not use this work except in compliance with the Licence.
 *
 * Copy of the Licence is available at:
 * https://joinup.ec.europa.eu/software/page/eupl
 * It is bundled with this package in the file LICENSE.txt
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Licence is distributed on an as is basis,
 * without warranties or conditions of any kind, either express or implied.
 * Check the Licence for the specific language governing permissions
 * and limitations under the License.
 *
 * @author   Simply.IN Sp. z o.o.
 * @copyright 2024-2025 Simply.IN Sp. z o.o.
 * @license   https://joinup.ec.europa.eu/software/page/eupl
 */

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Registers the order-detail display hook added in this version.
 *
 * Adding a hook to the installer's list only affects FRESH installs — an already-installed shop
 * keeps the registrations it was installed with, so without this step the pay-again surface would
 * silently not exist on any existing shop. Same direct-registerHook pattern as upgrade-8.1.25.php.
 *
 * The hook itself is part of PrestaShop's own install data and is dispatched by both the customer's
 * order page and guest order tracking, so one registration covers both audiences and there is no
 * risk of registering a name the shop does not have.
 *
 * registerHook() is idempotent in PrestaShop, so re-running this is harmless.
 *
 * Its return value is deliberately NOT propagated: PrestaShop's module-upgrade runner DISABLES the
 * module when an upgrade function returns false, and the modern admin flow bumps the stored version
 * regardless — so propagating a failed registration would trade a missing pay-again surface for a
 * dead checkout. Without the hook the shop simply behaves as it did before this version, which is
 * the safe direction.
 *
 * @param \Simplyin $module
 *
 * @return bool
 */
function upgrade_module_8_1_27($module)
{
    $module->registerHook('displayOrderDetail');

    return true;
}
