Add InPost Pay integration to admin templates

- Created a new template for the cart rule form with custom label, switch, and choice widgets.
- Implemented the InPost Pay block in the order details template for displaying delivery method, APM, and VAT invoice request.
- Added legacy support for the order details template to maintain compatibility with older PrestaShop versions.
This commit is contained in:
2025-09-14 14:38:09 +02:00
parent d895f86a03
commit 4066f6fa31
1086 changed files with 76598 additions and 6 deletions

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace izi\prestashop\Uuid;
abstract class Uuid implements \JsonSerializable
{
public const CANONICAL_FORMAT_LENGTH = 36;
private $uuid;
public function __construct(?string $uuid = null)
{
if (null === $uuid) {
$this->uuid = static::generate();
} else {
$version = preg_match('/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/Di', $uuid) ? (int) $uuid[14] : false;
if (false === $version || $version !== static::getVersion()) {
throw new \DomainException(sprintf('Invalid UUIDv%d: "%s".', static::getVersion(), $uuid));
}
$this->uuid = strtolower($uuid);
}
}
public static function v4(): UuidV4
{
return new UuidV4();
}
public function __toString(): string
{
return $this->uuid;
}
public function jsonSerialize(): string
{
return $this->uuid;
}
abstract protected static function generate(): string;
abstract protected static function getVersion(): int;
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace izi\prestashop\Uuid;
final class UuidV4 extends Uuid
{
protected static function generate(): string
{
$uuid = random_bytes(16);
$uuid[6] = $uuid[6] & "\x0F" | "\x40";
$uuid[8] = $uuid[8] & "\x3F" | "\x80";
$uuid = bin2hex($uuid);
return implode('-', [
substr($uuid, 0, 8),
substr($uuid, 8, 4),
substr($uuid, 12, 4),
substr($uuid, 16, 4),
substr($uuid, 20, 12),
]);
}
protected static function getVersion(): int
{
return 4;
}
}