Comments (6)
Hi @jimkrutor,
thank you so much for your detailed bug report and sorry for the late replay.
I think there is already a fix for this problem in the develop branch (commit 99b92e9).
I will have take a closer look at this. If this is a solution for your problem I will merge it into the main branch and create a new release.
from merx.
I have the exact same problem and would love a fix in the next release.
from merx.
I ran into the same problem today. Any news?
from merx.
Hello everyone!
thanks for your patience and sorry for the late fix of this issue.
This issue should be fixed with 1.7.0-beta.1
. Please report back if you still have problems with validation on multilingual pages.
from merx.
Confirmed - this solved my original issue, thank you!
from merx.
Hi all!
I tried solution from commit 99b92e9 and here's my feedback:
Said fix is taking place in completePayment()
method which is happening later in the process. In my case, saving order page (creating content file) works without problem.
Original issue starts earlier in initializePayment()
method. In this step, $virtualOrderPage
is created and validated. Validation fails because virtual page have its translation created empty by default. I tried to use same approach with $kirby->setCurrentLanguage()
before creating $virtualOrderPage
, but translation is still created empty.
I still see forcing of the default translation as a viable option. I think I found better way to do it, that can work even without multi-lang option and hopefully for multi-lang sites with more than one language. I didn't do any deep testing of different language configurations though.
Merx.php starting from line 215 (v1.6.1)
// create virtual order page
$virtualOrderPage = new OrderPage([
'slug' => Str::random(16),
'template' => 'order',
'model' => 'order',
'content' => $data
]);
//modification start
$kirby = kirby();
if ($kirby->multilang()) {
$languageCode = $kirby->defaultLanguage()->code();
$virtualOrderPage->translation($languageCode)->update($data);
}
//modification end
// check for validation errors
$errors = $virtualOrderPage->errors();
if (sizeof($errors) > 0) {
throw new Exception([
'key' => 'merx.fieldsvalidation',
'httpCode' => 400,
'details' => $errors,
]);
}
I also found another workaround in OrderPage model that fills empty translation on request. It works, but i think fix on merx level will be more effecient (not having to fetch and convert content object)
site/models/order.php
public function translation(?string $languageCode = null) {
if($translation = parent::translation($languageCode)) { //language exists
if($translation->content()) {
//this should happen most of the time
return $translation;
} else {
//this should happen only once in initializePayment()
parent::translation($languageCode)->update($this->content()->toArray());
return parent::translation($languageCode);
}
} else { //language do not exist
return null;
}
}
from merx.
Related Issues (20)
- more examples HOT 4
- $cart->getSum() includes tax? HOT 1
- Documentation website down HOT 2
- Syntax error with Starter Kit HOT 1
- No such payment_intent HOT 1
- Compatibility issue with Kirby 3.7.1 HOT 4
- Is it possible to disable online payments? HOT 1
- Upgrade to Paypal API v2 HOT 5
- Wagnerwagner\Merx\ProductList::__set(): Return type must be void when declared HOT 2
- Discount per product? HOT 1
- How do you add different types of sizes for a product? HOT 2
- Deprecated Stripe API
- Save orders in a specific language HOT 1
- Order pages with identical page num created HOT 3
- Declaration of Wagnerwagner\Merx\ProductList::__set(string $key, $value) must be compatible with Kirby HOT 1
- Cart and Checkout problem HOT 1
- Cart()->remove() not removing product - Issue with UUID's HOT 2
- Dynamic shipping prices (request) HOT 1
- Allow donation or 'pay what you want' HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from merx.