Skip to content
Snippets Groups Projects
Commit 05c8ae88 authored by Jonathan Sacksick's avatar Jonathan Sacksick
Browse files

Issue #3401715 by gcb, jsacksick, rszrama: Set the initial_order when creating...

Issue #3401715 by gcb, jsacksick, rszrama: Set the initial_order when creating the subscription from the order subscriber."
parent d9ba0717
No related branches found
No related tags found
No related merge requests found
Pipeline #220534 passed with warnings
......@@ -94,6 +94,9 @@ class OrderSubscriber implements EventSubscriberInterface {
$subscription = $subscription_storage->createFromOrderItem($order_item, [
'type' => $subscription_type_item->target_plugin_id,
'billing_schedule' => $billing_schedule,
// The order is more up-to-date here than it is when collected from
// $order_item->getOrder(), so it's best to pass or updated order along.
'initial_order' => $order,
]);
// Set the payment method if known, it's not required to start a free
......
......@@ -26,11 +26,12 @@ class SubscriptionStorage extends CommerceContentEntityStorage implements Subscr
// affecting existing subscriptions.
'unit_price' => $order_item->getUnitPrice(),
];
if ($order = $order_item->getOrder()) {
$order = $values['initial_order'] ?? $order_item->getOrder();
if ($order) {
$values += [
'store_id' => $order->getStoreId(),
'uid' => $order->getCustomerId(),
'initial_order' => $order->id(),
'initial_order' => $order,
];
}
/** @var \Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment