Closed mbegerau closed 4 years ago
Hello, thanks for putting in the effort of providing such a full display of the issue you're experiencing. And what possible solution you see. I wasn't aware that the translation record in the database doesn't take over the custom fields. This to me feels a bit like an issue that Shopware might need to address.
I will take a moment to think about the suggestions you have given and I might have a talk with some of the developers of Shopware about this. I'll get back to you if I have more information.
Hello,
I now check for the translated field, look here: https://github.com/mollie/Shopware6/blob/master/src/Resources/views/storefront/component/payment/payment-fields.html.twig#L17
Hopefully this works out for you.
My kind regards, Reinder van Bochove.
Hey, thanks for your work! I can confirm that this is working now.
Environment changes compared to original post (completely new and clean shop): Shopware: 6.2.0 Mollie: 1.0.13
Environment
OS: Ubuntu 18.04 Apache: 2.4.29 PHP: 7.3.17 MySQL: 5.7.30 Shopware: 6.1.5 (fresh installation from production repository) Mollie: 1.0.10 Other Plugins: Shopware 6 Demo data (1.0.5)
Problem
In a multilanguage shop the creditcard components are only displayed in the main language shop.
Image: Working components in English shop Image: Broken components in German shop
Detected causes
custom/plugins/MolliePayments/src/Resources/views/storefront/component/payment/payment-fields.html.twig, lines 15-19
In a shop that is not using the main language, the payment.customFields array is empty. It should get the payment.translated.customFields array instead.
custom_fields
._Image: Empty
custom_fields
field in database_Another problem is that the custom fields are not displayed by default in the payment method editor.
Image: No custom fields in payment method editor
So the only way right now to fix this is filling in the field in the database manually.
Solution suggestion
a) Change the twig and somehow automatically add the custom_fields data to new payment method translations (not recommended)
b) Use a non-translatable field for payment method check.
if payment.handlerIdentifier == 'Kiener\\MolliePayments\\Handler\\Method\\CreditCardPayment'
Current workaround
{% block component_payment_method_description %} {% do payment.setCustomFields(payment.translated.customFields) %}
{% endblock %}
{ "molliePayments": { "components": { "creditCard": { "headLine": "Bitte die Kreditkarteninformationen eingeben", "cardHolderLabel": "Karteninhaber/in", "cardNumberLabel": "Kreditkartennummer", "cardExpiryDateLabel": "Ablaufdatum", "cardVerificationCodeLabel": "CVC", "creditCardTagLine": "Abgesichert durch and angebot von" } } } }