Loading src/Entity/Invoice.php +8 −7 Original line number Diff line number Diff line Loading @@ -97,18 +97,19 @@ class Invoice extends CommerceContentEntityBase implements InvoiceInterface { public function toUrl($rel = 'canonical', array $options = []) { // For better UX, the collection URL of invoices that are created for a // single order should be the list of invoices for that specific order. $invoice_collection_url = NULL; if ($rel === 'collection' && count($this->get('orders')) === 1) { $order = $this->get('orders')->first()->entity; if ($order) { if ($this->bundle() === 'default') { $invoice_collection_url = $order->toUrl('invoices', $options); return $order->toUrl('invoices', $options); } elseif ($this->bundle() === 'credit_memo') { $invoice_collection_url = $order->toUrl('credit-memos', $options); return $order->toUrl('credit-memos', $options); } } } return $invoice_collection_url ?? parent::toUrl($rel, $options); return parent::toUrl($rel, $options); } /** Loading Loading
src/Entity/Invoice.php +8 −7 Original line number Diff line number Diff line Loading @@ -97,18 +97,19 @@ class Invoice extends CommerceContentEntityBase implements InvoiceInterface { public function toUrl($rel = 'canonical', array $options = []) { // For better UX, the collection URL of invoices that are created for a // single order should be the list of invoices for that specific order. $invoice_collection_url = NULL; if ($rel === 'collection' && count($this->get('orders')) === 1) { $order = $this->get('orders')->first()->entity; if ($order) { if ($this->bundle() === 'default') { $invoice_collection_url = $order->toUrl('invoices', $options); return $order->toUrl('invoices', $options); } elseif ($this->bundle() === 'credit_memo') { $invoice_collection_url = $order->toUrl('credit-memos', $options); return $order->toUrl('credit-memos', $options); } } } return $invoice_collection_url ?? parent::toUrl($rel, $options); return parent::toUrl($rel, $options); } /** Loading