What version of Merx do you use? Make sure you have Merx 1.4.x. The routing changed with Kirby 3.4.
I’ve just updated a shop to Kirby 3.5.0-rc.6 (merx.wagnerwagner.de). Several other shops are running with 3.4.x without issues.
What version of Merx do you use? Make sure you have Merx 1.4.x. The routing changed with Kirby 3.4.
I’ve just updated a shop to Kirby 3.5.0-rc.6 (merx.wagnerwagner.de). Several other shops are running with 3.4.x without issues.
I’m running Merx 1.4.1. What bothers me, is that I have no idea where to start to debug. I tried logging couple of things but haven’t found any leads. And no errors in the server log files. Thanks for the hint, I will also look into the routing changes of Kirby 3.4.
It was indeed a typo in that part - thanks!
The error i’m getting changed after correcting the typo for my key.
Any idea why that’s showing up now?
hi there,
just checked out the Dietz shop, well done! <3 I noticed that each country seems to have a corresponding shipping page attached to it, and I wanted to ask, if I may, how you manage this in Kirby. Are there pages for every possible country? Do you use hooks to add a shipping item? What happens when a user selects i.e “bulgaria”, but enters “united states” in the county field?
All the best :~)
I don’t know about the integration of the Dietz shop. But it might be a combination of the Shipping Costs and Product Variants cookbook.
Do you use a special PHP version? Have you set a namespace such as namespace Wagnerwagner\Merx;
somewhere in your code?
Editing site/plugins/merx/src/cart.php
should fix this temporarily. But this will obviously break with the next Merx update.
On line 117 replace this
public function getStripePaymentIntent(): object
with this
public function getStripePaymentIntent()
@tobiasfabian whenever I have more than one item in the cart, and click on “buy” to complete the checkout, my server crashes… with one item it works just fine. any idea what might be the issue?
'ww.merx.completePayment:after' => function ($orderPage) {
$hash = bin2hex(random_bytes(16));
$urlWithHash = url($orderPage->url(), ['params' => ['q' => $hash]]);
$orderPage->update([
'hash' => $hash,
]);
foreach($orderPage->cart() as $cartItem) {
$cartItemPage = page($cartItem['id']);
// make sure the item is a product, not a shipping option
if ($cartItemPage->parent()->slug() == 'editions') {
$newStock = $cartItemPage->stock()->toInt() - (int)$cartItem['quantity'];
$cartItemPage->update([
'stock' => (int)$newStock,
]);
}
};
sendConfirmationMail($orderPage, $urlWithHash);
go($urlWithHash);
}
it’s definitely the stock management part of the hook, commenting that out and it works. I absolutely don’t understand what’s wrong with that part though…
Hello,
I am organizing the orders view with the pagetable plugin, and I am searching for a way to indicate that an order has been fulfilled. Is it possible for orders to be saved with a status of unlisted initially, and allow the admin to change it on completion (or perhaps make this change automatic with a hook)?
I’d also be interested in an answer to this :~) I believe that the page status relates to the internal status of the order itself, meaning it will only automatically be marked as listed/successful if everything went well with the payment etc, so it would probably mess with the internal logic of Merx (correct me if i’m wrong, @tobiasfabian). For my shop, I’ve simply added a “shipped” toggle field. As you probably know, with the pagetable plugin it’s quite easy to add any icon or text depending on certain field contents.
As @bruno said the listed status of order pages is crucial to Merx.
But you can create your own complete status. Kinda like this.
class OrderPage {
isComplete(): bool
{
return $this->shipped()->isTrue() && $this->payed()->isTrue();
}
}
This is more related to the pageTable plugin, but how could I format the output of this function?
class OrderPage extends OrderPageAbstract {
public function orderStatus() {
$status = 'In progress';
if ($this->shipped()->isTrue() && $this->paymentcomplete()->isTrue()) {
$status = 'Complete';
}
return $status;
}
};
columns:
order_status:
label: Status
type: text
text: "{{ page.orderStatus.formatStatus }}" // formatStatus doesn't work
sortable: true
The formatStatus method in the blueprint doesn’t work here. Maybe it has to do with orderStatus()
output being a string instead of an object, as mentioned here. If that’s the case, how can I output an object (sorry, poor PHP skills…)?
what is the formatStatus
method?
A function from a custom field method plugin.
Do you mind sharing the plugin code? If you do text: "{{ page.orderStatus }}"
, do you get the desired unformatted result in the pagetable column?
Yes, with text: "{{ page.orderStatus }}"
I am getting the unformatted result. In the plugin code I am just outputting the field to check if it works, but it returns empty:
Kirby::plugin('alex/format-status', [
'fieldMethods' => [
'formatStatus' => function($field) {
return $field;
}
]
]);
hmmm, I’m puzzled as well. I believe this is due to how pagetable plugin handles stuff… sorry I can’t be of any help, maybe somebody else has a suggestion
@efavaro and @tobiasfabian Thank you. Needed the custom gateway also for discounts larger or equal to the sum. Works great. Minor thing, only had to change “!==” into “!=” to make it work.
It was a pagetable thing after all. It can’t show data that is coming from models, only field values contained in the content file.
Glad you asked, because you reminded me to post my solution.
In my case the problem was caused by a custom payment gateway. I have added a prepayment (bank transfer) option via the config file. But I haven’t added the “completePayment” function. So previously my code looked like this:
'ww.merx.gateways' => [
'prepayment' => [],
],
With the added function it looks like this now:
'ww.merx.gateways' => [
'prepayment' => [
'completePayment' => function(OrderPage $virtualOrderPage, array $data): OrderPage
{
return $virtualOrderPage;
}
],
],
Don’t pin me down on technical specifics, but I think what happened was that the “completePayment” function previously threw an exception and returned the order page (is that even possible?). Because the success page echoed ‘The payment could not be completed.’ but also redirected. With Kirby 3.3 the redirect worked, but with Kirby 3.4 the site went into some sort of soft-lock and didn’t respond after the order, until the session was deleted.