Skip to content
Snippets Groups Projects
Commit f4de3bc5 authored by Joachim Noreiko's avatar Joachim Noreiko Committed by Bojan Živanović
Browse files

Issue #2935892 by joachim, bojanz: Allow subscription adjustments to be shown...

Issue #2935892 by joachim, bojanz: Allow subscription adjustments to be shown as a part of the calculated price on the product catalog
parent 91ddef78
No related branches found
No related tags found
No related merge requests found
recurring:
label: 'Recurring'
singular_label: 'recurring adjustment'
plural_label: 'recurring adjustments'
subscription:
label: 'Subscription'
singular_label: 'subscription adjustment'
plural_label: 'subscription adjustments'
has_ui: false
weight: 10
......@@ -14,7 +14,7 @@ services:
class: Drupal\commerce_recurring\InitialOrderProcessor
arguments: ['@datetime.time']
tags:
- { name: commerce_order.order_processor, priority: 40 }
- { name: commerce_order.order_processor, priority: 40, adjustment_type: subscription }
commerce_recurring.recurring_order_processor:
class: Drupal\commerce_recurring\RecurringOrderProcessor
......
......@@ -67,7 +67,7 @@ class InitialOrderProcessor implements OrderProcessorInterface {
if (!$prorated_unit_price->equals($unit_price)) {
$difference = $unit_price->subtract($prorated_unit_price);
$order_item->addAdjustment(new Adjustment([
'type' => 'recurring',
'type' => 'subscription',
'label' => t('Proration'),
'amount' => $difference->multiply('-1'),
'source_id' => $billing_schedule->id(),
......@@ -77,7 +77,7 @@ class InitialOrderProcessor implements OrderProcessorInterface {
else {
// A postpaid purchased entity is free in the initial order.
$order_item->addAdjustment(new Adjustment([
'type' => 'recurring',
'type' => 'subscription',
'label' => t('Pay later'),
'amount' => $order_item->getAdjustedUnitPrice()->multiply('-1'),
'source_id' => $billing_schedule->id(),
......
......@@ -74,7 +74,7 @@ class InitialOrderProcessorTest extends RecurringKernelTestBase {
$this->assertNotEquals($order_item->getUnitPrice(), $order_item->getAdjustedUnitPrice());
$adjustments = $order_item->getAdjustments();
$adjustment = reset($adjustments);
$this->assertEquals('recurring', $adjustment->getType());
$this->assertEquals('subscription', $adjustment->getType());
$this->assertEquals(t('Proration'), $adjustment->getLabel());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment