Skip to content

Commit 7056ac1

Browse files
authored
[PT-931] comatibility for high performance order storage and cart checkout blocks (#115)
1 parent 9dcfef3 commit 7056ac1

22 files changed

+453
-210
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ wp i18n --allow-root make-pot . languages/mondu.pot
2323
wp i18n --allow-root update-po languages/mondu.pot languages/
2424
```
2525

26-
- Include the translated strings in the `languages/*.po` files.
26+
- Include the translated strings in the `languages/*.po` and `languages/*.json` files.
2727
- Run the following command to update `.mo` files:
2828

2929
```
3030
wp i18n --allow-root make-mo languages
31+
wp i18n --allow-root make-json languages
3132
```
3233

3334
## Before pushing your changes

assets/src/js/mondublocks.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
(function() {
2+
const { __ } = wp.i18n;
3+
const { createElement } = window.wp.element;
4+
const { decodeEntities } = window.wp.htmlEntities;
5+
const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
6+
const { registerPaymentMethodExtensionCallbacks } = window.wc.wcBlocksRegistry;
7+
const settings = window.wc.wcSettings.getSetting( 'mondu_blocks_data', {} );
8+
9+
settings.available_countries = settings.available_countries || [];
10+
settings.gateways = settings.gateways || {};
11+
12+
// This is not used anywhere, it's added for automatic translation generation with wp cli command
13+
const translations = [
14+
__('Mondu Invoice', 'mondu'),
15+
__('Mondu SEPA Direct Debit', 'mondu'),
16+
__('Mondu Installments', 'mondu'),
17+
__('Mondu Installments by Invoice', 'mondu'),
18+
__('Invoice - Pay later by bank transfer', 'mondu'),
19+
__('SEPA - Pay later by direct debit', 'mondu'),
20+
__('Split payments - Pay Later in Installments by Direct Debit', 'mondu'),
21+
__('Split payments - Pay Later in Installments by Bank Transfer', 'mondu')
22+
];
23+
24+
function Label(text) {
25+
return createElement('div', {}, Logo(), __(text, 'mondu'))
26+
}
27+
function Content(text) {
28+
return createElement('div', {}, __(text, 'mondu'), createElement('br', {}), DataProcessingNotice())
29+
}
30+
31+
function Logo() {
32+
return createElement('img', { src: 'https://checkout.mondu.ai/logo.svg', style: { display: 'inline', height: '1rem', marginRight: '0.5rem'} })
33+
}
34+
35+
function DataProcessingNotice() {
36+
return createElement('span', {
37+
dangerouslySetInnerHTML: {
38+
__html: __('Information on the processing of your personal data by <strong>Mondu GmbH</strong> can be found <a href="https://mondu.ai/gdpr-notification-for-buyers" target="_blank">here</a>.', 'mondu')
39+
}
40+
});
41+
}
42+
43+
function createGatewayBlock(gatewayName, gatewayInfo) {
44+
return {
45+
name: gatewayName,
46+
label: Label(gatewayInfo.title),
47+
content: Content(gatewayInfo.description),
48+
edit: Content(gatewayInfo.description),
49+
canMakePayment: () => true,
50+
ariaLabel: decodeEntities(gatewayInfo.title),
51+
supports: {
52+
features: gatewayInfo.supports,
53+
},
54+
}
55+
}
56+
57+
registerPaymentMethodExtensionCallbacks('mondu',
58+
Object.keys(settings.gateways).reduce((previousValue, currentValue) => {
59+
previousValue[currentValue] = function(arg) {
60+
return settings.available_countries.includes(arg.billingAddress.country)
61+
}
62+
63+
return previousValue;
64+
}, {})
65+
)
66+
67+
Object.entries(settings.gateways).forEach(([gatewayName, gatewayInfo]) => {
68+
registerPaymentMethod(createGatewayBlock(gatewayName, gatewayInfo))
69+
});
70+
})();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"translation-revision-date":"2022-11-01T18:21:49+00:00","generator":"WP-CLI\/2.10.0","source":"assets\/src\/js\/mondublocks.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de_AT","plural-forms":"nplurals=2; plural=(n != 1);"},"Mondu SEPA Direct Debit":["Mondu SEPA-Lastschrift"],"SEPA - Pay later by direct debit":["SEPA-Lastschrift - Sp\u00e4ter per Lastschrift bezahlen"],"Mondu Installments":["Mondu Ratenkauf"],"Split payments - Pay Later in Installments by Direct Debit":["Gesplittete Zahlungen - Ratenkauf per Lastschriftverfahren"],"Mondu Installments by Invoice":["Mondu Ratenkauf per Rechnung"],"Split payments - Pay Later in Installments by Bank Transfer":["Gesplittete Zahlungen - Ratenkauf per Bank\u00fcberweisung"],"Mondu Invoice":["Mondu Rechnungskauf"],"Invoice - Pay later by bank transfer":["Rechnungskauf - Sp\u00e4ter per Bank\u00fcberweisung bezahlen"],"Information on the processing of your personal data by <strong>Mondu GmbH<\/strong> can be found <a href=\"https:\/\/mondu.ai\/gdpr-notification-for-buyers\" target=\"_blank\">here<\/a>.":["Hinweise zur Verarbeitung Ihrer personenbezogenen Daten durch die <strong>Mondu GmbH<\/strong> finden Sie <a href=\"https:\/\/mondu.ai\/at\/gdpr-notification-for-buyers\" target=\"_blank\">hier<\/a>."]}}}

languages/mondu-de_AT.po

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ msgstr "Production"
7070

7171
#: src/Mondu/Admin/Option/Account.php:70
7272
#: src/Mondu/Mondu/Presenters/PaymentInfo.php:220
73-
#: src/Mondu/Plugin.php:331
74-
#: src/Mondu/Plugin.php:382
73+
#: src/Mondu/Plugin.php:344
74+
#: src/Mondu/Plugin.php:395
7575
msgid "Yes"
7676
msgstr "Ja"
7777

@@ -84,12 +84,12 @@ msgstr "Senden Sie nur Einzelposten für Bestellungen"
8484
msgid "No"
8585
msgstr "Nein"
8686

87-
#: src/Mondu/Admin/Order.php:42
87+
#: src/Mondu/Admin/Order.php:41
8888
msgid "Mondu Order Information"
8989
msgstr "Mondu Bestellinformationen"
9090

91-
#: src/Mondu/Admin/Order.php:64
92-
#: src/Mondu/Admin/Order.php:92
91+
#: src/Mondu/Admin/Order.php:68
92+
#: src/Mondu/Admin/Order.php:96
9393
#: src/Mondu/Admin/Settings.php:132
9494
msgid "Bad Request."
9595
msgstr "Schlechte Anfrage."
@@ -162,10 +162,12 @@ msgid "Not Found"
162162
msgstr "Nicht gefunden"
163163

164164
#: src/Mondu/Mondu/GatewayDirectDebit.php:12
165+
#: assets/src/js/mondublocks.js:15
165166
msgid "Mondu SEPA Direct Debit"
166167
msgstr "Mondu SEPA-Lastschrift"
167168

168169
#: src/Mondu/Mondu/GatewayDirectDebit.php:10
170+
#: assets/src/js/mondublocks.js:19
169171
msgid "SEPA - Pay later by direct debit"
170172
msgstr "SEPA-Lastschrift - Später per Lastschrift bezahlen"
171173

@@ -175,35 +177,41 @@ msgid "Enable %s payment method"
175177
msgstr "Aktivieren Sie %s Zahlungsart"
176178

177179
#: src/Mondu/Mondu/GatewayInstallment.php:12
180+
#: assets/src/js/mondublocks.js:16
178181
msgid "Mondu Installments"
179182
msgstr "Mondu Ratenkauf"
180183

181184
#: src/Mondu/Mondu/GatewayInstallment.php:10
185+
#: assets/src/js/mondublocks.js:20
182186
msgid "Split payments - Pay Later in Installments by Direct Debit"
183187
msgstr "Gesplittete Zahlungen - Ratenkauf per Lastschriftverfahren"
184188

185189
#: src/Mondu/Mondu/GatewayInstallmentByInvoice.php:12
190+
#: assets/src/js/mondublocks.js:17
186191
msgid "Mondu Installments by Invoice"
187192
msgstr "Mondu Ratenkauf per Rechnung"
188193

189194
#: src/Mondu/Mondu/GatewayInstallmentByInvoice.php:10
195+
#: assets/src/js/mondublocks.js:21
190196
msgid "Split payments - Pay Later in Installments by Bank Transfer"
191197
msgstr "Gesplittete Zahlungen - Ratenkauf per Banküberweisung"
192198

193199
#: src/Mondu/Mondu/GatewayInvoice.php:12
200+
#: assets/src/js/mondublocks.js:14
194201
msgid "Mondu Invoice"
195202
msgstr "Mondu Rechnungskauf"
196203

197204
#: src/Mondu/Mondu/GatewayInvoice.php:10
205+
#: assets/src/js/mondublocks.js:18
198206
msgid "Invoice - Pay later by bank transfer"
199207
msgstr "Rechnungskauf - Später per Banküberweisung bezahlen"
200208

201-
#: src/Mondu/Mondu/MonduGateway.php:125
209+
#: src/Mondu/Mondu/MonduGateway.php:127
202210
msgid "Error placing an order. Please try again."
203211
msgstr "Fehler beim Aufgeben einer Bestellung. Bitte versuchen Sie es erneut."
204212

205213
#: src/Mondu/Mondu/Presenters/PaymentInfo.php:80
206-
#: src/Mondu/Plugin.php:305
214+
#: src/Mondu/Plugin.php:318
207215
msgid "Order state"
208216
msgstr "Bestellstatus"
209217

@@ -298,83 +306,83 @@ msgstr "Gutschriften"
298306
msgid "Tax"
299307
msgstr "Steuer"
300308

301-
#: src/Mondu/Plugin.php:167
309+
#: src/Mondu/Plugin.php:180
302310
msgid "Since this order will be paid via Mondu you will not be able to change the addresses."
303311
msgstr "Da diese Bestellung über Mondu bezahlt wird, können Sie die Adressen nicht ändern."
304312

305-
#: src/Mondu/Plugin.php:200
313+
#: src/Mondu/Plugin.php:213
306314
msgid "View Mondu settings"
307315
msgstr "Mondu-Einstellungen anzeigen"
308316

309-
#: src/Mondu/Plugin.php:220
317+
#: src/Mondu/Plugin.php:233
310318
msgid "View Mondu documentation"
311319
msgstr "Mondu-Dokumentation anzeigen"
312320

313-
#: src/Mondu/Plugin.php:220
321+
#: src/Mondu/Plugin.php:233
314322
msgid "Docs"
315323
msgstr "Dokumente"
316324

317-
#: src/Mondu/Plugin.php:221
325+
#: src/Mondu/Plugin.php:234
318326
msgid "https://mondu.ai/introduction-to-paying-with-mondu"
319327
msgstr "https://mondu.ai/at/introduction-to-paying-with-mondu"
320328

321-
#: src/Mondu/Plugin.php:221
329+
#: src/Mondu/Plugin.php:234
322330
msgid "View introduction to paying with Mondu"
323331
msgstr "Einführung in das Bezahlen mit Mondu ansehen"
324332

325-
#: src/Mondu/Plugin.php:221
333+
#: src/Mondu/Plugin.php:234
326334
msgid "Mondu introduction"
327335
msgstr "Mondu Einführung"
328336

329-
#: src/Mondu/Plugin.php:222
337+
#: src/Mondu/Plugin.php:235
330338
msgid "https://mondu.ai/faq"
331339
msgstr "https://mondu.ai/at/faq"
332340

333-
#: src/Mondu/Plugin.php:222
341+
#: src/Mondu/Plugin.php:235
334342
msgid "View FAQ"
335343
msgstr "FAQ anzeigen"
336344

337-
#: src/Mondu/Plugin.php:222
345+
#: src/Mondu/Plugin.php:235
338346
msgid "FAQ"
339347
msgstr "FAQ"
340348

341349
#. translators: %s: Company
342-
#: src/Mondu/Plugin.php:241
350+
#: src/Mondu/Plugin.php:254
343351
msgid "%s is a required field for Mondu payments."
344352
msgstr "%s ist ein Pflichtfeld für Mondu-Zahlungen."
345353

346354
#. translators: %s: Company
347-
#: src/Mondu/Plugin.php:241
355+
#: src/Mondu/Plugin.php:254
348356
msgid "Company"
349357
msgstr "Firma"
350358

351359
#. translators: %s: Billing country
352-
#: src/Mondu/Plugin.php:246
360+
#: src/Mondu/Plugin.php:259
353361
msgid "%s not available for Mondu Payments."
354362
msgstr "%s für Mondu-Zahlungen nicht verfügbar."
355363

356364
#. translators: %s: Billing country
357-
#: src/Mondu/Plugin.php:246
365+
#: src/Mondu/Plugin.php:259
358366
msgid "Billing country"
359367
msgstr "Rechnungsland"
360368

361-
#: src/Mondu/Plugin.php:306
362-
#: src/Mondu/Plugin.php:356
363-
#: src/Mondu/Plugin.php:409
369+
#: src/Mondu/Plugin.php:319
370+
#: src/Mondu/Plugin.php:369
371+
#: src/Mondu/Plugin.php:422
364372
msgid "Canceled"
365373
msgstr "Storniert"
366374

367-
#: src/Mondu/Plugin.php:330
368-
#: src/Mondu/Plugin.php:381
375+
#: src/Mondu/Plugin.php:343
376+
#: src/Mondu/Plugin.php:394
369377
msgid "Mondu Invoice paid"
370378
msgstr "Mondu-Rechnung bezahlt"
371379

372-
#: src/Mondu/Plugin.php:355
373-
#: src/Mondu/Plugin.php:408
380+
#: src/Mondu/Plugin.php:368
381+
#: src/Mondu/Plugin.php:421
374382
msgid "Mondu Invoice state"
375383
msgstr "Mondu-Rechnungsstatus"
376384

377-
#: src/Mondu/Plugin.php:423
385+
#: src/Mondu/Plugin.php:436
378386
msgid "Mondu requires WooCommerce to be activated."
379387
msgstr "Mondu erfordert die Aktivierung von WooCommerce."
380388

@@ -406,6 +414,7 @@ msgid "Log date"
406414
msgstr "Log date"
407415

408416
#: views/checkout/payment-form.php:4
417+
#: assets/src/js/mondublocks.js:38
409418
msgid "Information on the processing of your personal data by <strong>Mondu GmbH</strong> can be found <a href=\"https://mondu.ai/gdpr-notification-for-buyers\" target=\"_blank\">here</a>."
410419
msgstr "Hinweise zur Verarbeitung Ihrer personenbezogenen Daten durch die <strong>Mondu GmbH</strong> finden Sie <a href=\"https://mondu.ai/at/gdpr-notification-for-buyers\" target=\"_blank\">hier</a>."
411420

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"translation-revision-date":"2022-11-01T18:21:49+00:00","generator":"WP-CLI\/2.10.0","source":"assets\/src\/js\/mondublocks.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de_DE","plural-forms":"nplurals=2; plural=(n != 1);"},"Mondu SEPA Direct Debit":["Mondu SEPA-Lastschrift"],"SEPA - Pay later by direct debit":["SEPA-Lastschrift - Sp\u00e4ter per Lastschrift bezahlen"],"Mondu Installments":["Mondu Ratenkauf"],"Split payments - Pay Later in Installments by Direct Debit":["Gesplittete Zahlungen - Ratenkauf per Lastschriftverfahren"],"Mondu Installments by Invoice":["Mondu Ratenkauf per Rechnung"],"Split payments - Pay Later in Installments by Bank Transfer":["Gesplittete Zahlungen - Ratenkauf per Bank\u00fcberweisung"],"Mondu Invoice":["Mondu Rechnungskauf"],"Invoice - Pay later by bank transfer":["Rechnungskauf - Sp\u00e4ter per Bank\u00fcberweisung bezahlen"],"Information on the processing of your personal data by <strong>Mondu GmbH<\/strong> can be found <a href=\"https:\/\/mondu.ai\/gdpr-notification-for-buyers\" target=\"_blank\">here<\/a>.":["Hinweise zur Verarbeitung Ihrer personenbezogenen Daten durch die <strong>Mondu GmbH<\/strong> finden Sie <a href=\"https:\/\/mondu.ai\/de\/gdpr-notification-for-buyers\" target=\"_blank\">hier<\/a>."]}}}

0 commit comments

Comments
 (0)