Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom invoice numbers break multi-language website #75

Open
jan-herman opened this issue Mar 12, 2024 · 4 comments
Open

Custom invoice numbers break multi-language website #75

jan-herman opened this issue Mar 12, 2024 · 4 comments

Comments

@jan-herman
Copy link

Hi there,
I have a multi-language website (default language: czech, secondary: english) and I followed this cookbook recipe to add custom invoice numbers to orders: https://merx.wagnerwagner.de/cookbooks/custom-invoice-numbers.

In czech everything works as expected, but every time order is submitted in english, order.en.txt is created with following content:

Note: 

----

Invoicedate: 2024-03-12T23:11:34+00:00

----

Invoicenumber: 202400001

While in order.cs.txt the Invoicenumber is missing.

I tried specifying locale like this, but that didn't work either.

$orderPage->update([
    'invoiceNumber' => (string) $invoice_number,
], 'cs');

Am I missing something or is this a bug related to #62?

@tobiasfabian
Copy link
Member

tobiasfabian commented Mar 20, 2024

Hi @jan-herman,

thanks for your question.

You are right. In multi-language sites such things as custom invoice numbers should always be stored in the default language. So I’m wondering why your approach of setting the languageCode in the update method doesn’t work.

Can you please double-check if the code value stored in languages/cs.php is cs.

To make sure you always use the default language, you can do the following:

        'ww.merx.completePayment:after' => function (OrderPage $orderPage) {
            $customInvoiceNumber = 'Lorem Ipsum';
            $orderPage->update([
                'invoiceNumber' => $customInvoiceNumber,
            ], $orderPage->kirby()->defaultLanguage()?->code());
        },

@jan-herman
Copy link
Author

Hi,
sorry for the late reply. For some reason I missed the notification.

Anyway cs is definitely the default language code. All the other orders are saved as order.cs.txt.

@tobiasfabian
Copy link
Member

Hi @jan-herman,
is there anything I can do for you?

@jan-herman
Copy link
Author

Hi,
thank you, but it's on the back burner for now. There have only been a few orders from other countries, so it's not really a priority for the client.

We might revisit this issue when we do the update to Kirby 5. From what I understand the team has made some changes to the way the hooks work so it may resolve itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants