Skip to content

Commit 43322bb

Browse files
committed
🐛 forward checkoutFormData up to the order creation, thanks @tobimori
1 parent f956d11 commit 43322bb

File tree

6 files changed

+167
-157
lines changed

6 files changed

+167
-157
lines changed

classes/Kart/Models/OrdersPage.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,19 @@ public function createOrder(array $data, ?User $customer = null): ?Page
121121
return null;
122122
}
123123

124+
// remove a few fields that were set in [provider]->completed()
125+
// but should not be forwarded as content to the order itself.
126+
// keep the remaining kvs as they might be from checkoutFormData.
127+
unset($data['uuid']);
128+
unset($data['email']);
129+
unset($data['customer']);
130+
124131
/** @var Page $p */
125132
$p = kirby()->impersonate('kirby', fn () => self::createChild([
126133
'template' => kart()->option('orders.order.template', 'order'),
127134
'model' => kart()->option('orders.order.model', 'order'),
128135
// id, title, slug and uuid are automatically generated
129-
'content' => A::get($data, [
130-
'paidDate',
131-
'paymentMethod',
132-
'paymentComplete',
133-
'items',
134-
]) + [
136+
'content' => $data + [
135137
'customer' => [$customer?->uuid()->toString()], // kirby user field expects an array
136138
],
137139
]));

classes/Kart/Provider/Mollie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function completed(array $data = []): array
181181
}
182182
$data = array_merge($data, array_filter([
183183
// 'session_id' => $sessionId,
184-
'uuid' => A::get($json, 'metadata.order_id'),
184+
// 'uuid' => A::get($json, 'metadata.order_id'),
185185
'email' => A::get($customer, 'email'),
186186
'customer' => ! empty($customer) ? [
187187
'id' => A::get($customer, 'id'),

classes/Kart/Provider/Paypal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function completed(array $data = []): array
181181
}
182182
$data = array_merge($data, array_filter([
183183
// 'session_id' => $sessionId,
184-
'uuid' => A::get($json, 'purchase_units.0.custom_id'),
184+
// 'uuid' => A::get($json, 'purchase_units.0.custom_id'),
185185
'email' => A::get($json, 'payer.email_address'),
186186
'customer' => [
187187
'id' => A::get($json, 'payer.payer_id'),

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bnomei/kirby-kart",
33
"type": "kirby-plugin",
4-
"version": "5.6.4",
4+
"version": "5.6.5",
55
"description": "Streamlined E-Commerce Shopping Cart Solution",
66
"license": "proprietary",
77
"authors": [

0 commit comments

Comments
 (0)