k10r / klarna-ordermanagement

klarna-ordermanagement 是我们 Klarna 插件的一个包。

0.6.5 2024-03-13 13:45 UTC

README

Latest Version on Packagist Software License Total Downloads

这是一个 Shopware 5 插件的包。它增加了对 Klarna OrderManagement API 的支持,并在 Shopware 后端中包含了一个用户界面。如果您使用此包,您需要自行实现 Klarna Payments 和 Klarna Checkout。

安装

通过 Composer

$ composer require k10r/klarna-ordermanagement

注册依赖

在您的 Shopware 插件入口文件中,您需要指定以下容器参数

  • 插件名称
public function build(ContainerBuilder $containerBuilder)
{
    parent::build($containerBuilder);

    $containerBuilder->setParameter('bestit_klarna.plugin_name', 'ExamplePluginName');
}

并且您还需要注册我们的依赖

public function build(ContainerBuilder $containerBuilder)
{
    parent::build($containerBuilder);

    //

    $dependencyInjectionExtensions = [
        \BestitKlarnaOrderManagement\Components\DependencyInjection\DependencyInjectionExtension::class
    ];

    foreach ($dependencyInjectionExtensions as $dependencyInjectionExtension) {
        if (!class_exists($dependencyInjectionExtension)) {
            continue;
        }

        $dependencyInjectionExtension = new $dependencyInjectionExtension();

        if (!$dependencyInjectionExtension instanceof \BestitKlarnaOrderManagement\Components\DependencyInjection\DependencyInjectionExtensionInterface) {
            continue;
        }

        $dependencyInjectionExtension->injectDependencies($containerBuilder);
    }
}

然后您可以使用 OMInstaller 进行其他必要的设置

public function install(InstallContext $context)
{
    // ...

    $this->getOmInstaller()->install($this, $context);

    // ...
}

public function uninstall(UninstallContext $context)
{
    // ...

    $this->getOmInstaller()->uninstall($this, $context);

    // ...
}

public function update(UpdateContext $context)
{
    // ...

    $this->getOmInstaller()->update($this, $context);

    // ...
}

protected function getOmInstaller()
{
    if ($this->omInstaller !== null) {
        return $this->omInstaller;
    }

    $this->omInstaller = new OmInstaller($this->container->get('shopware.snippet_database_handler'));

    return $this->omInstaller;
}

用法

有关更多信息,请参阅 文档

变更日志

请参阅 变更日志 了解最近更改的内容。

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件