Closed vrielsa closed 4 years ago
Perhaps instead of instantiating Smarty yourselves, you could also consider using the template manager included in Shopware.
The getPaymentOptions methods could look a little like this:
protected function getPaymentOptions()
{
/** @var \Enlight_Template_Manager $templateManager */
$templateManager = $this->container->get('template');
$mollie = $this->getMollieClient();
// TODO: get methods in the correct locale (de_DE en_US es_ES fr_FR nl_BE fr_BE nl_NL)
$methods = $mollie->methods->allActive([
'resource' => 'orders',
'includeWallets' => 'applepay'
]);
$options = [];
$position = 0;
// path to template dir for extra payment-mean options
$paymentTemplateDir = __DIR__ . '/Resources/views/frontend/plugins/payment';
foreach ($methods as $key => $method) {
$name = 'mollie_' . $method->id;
$templateManager->assign('method', $method);
$templateManager->assign('router', Shopware()->Router());
// template path
$adTemplate = $paymentTemplateDir . '/methods/' . strtolower($method->id) . '.tpl';
// set default template if no specific template exists
if (!file_exists($adTemplate)) {
$adTemplate = $paymentTemplateDir . '/methods/main.tpl';
}
$additionalDescription = $templateManager->fetch('file:' . $adTemplate);
$option = [
'name' => $name,
'description' => $method->description,
'action' => 'frontend/Mollie',
'active' => 1,
'position' => $position,
'additionalDescription' => $additionalDescription
];
// check template exist
if (file_exists($paymentTemplateDir . '/' . $name . '.tpl')) {
$option['template'] = $name . '.tpl';
}
$options[] = $option;
}
return $options;
}
Hi, this looks like a great solution. I'll look into your pull request later today.
Hello
We've tried updating the installation of the Mollie plugin on our Shopware installation but got stuck after trying to activate the plugin. Clearing caches, autoload dumping, etc.. didn't work. We've also tried to install the plugin on a clean installation of our Shopware version, but we were unable to activate it on that as well, we were presented with the same error.
The only way we were able to activate the plugin is by requiring the smarty class file in MollieShopware.php.
Additional info:
Stack trace