mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Fix customer autocomplete filter not displaying guest customers (#18980)
Guest customers (without first/last name) appeared as blank entries in the order grid's customer autocomplete filter, making them impossible to select. Added `getNameOrEmail()` to `CustomerInterface` which returns `"Full Name (email)"` for named customers and just the email for guests, and switched the order grid filter to use it as its choice label.
This commit is contained in:
parent
50e3576804
commit
a75fd35347
3 changed files with 14 additions and 1 deletions
|
|
@ -114,7 +114,7 @@ sylius_grid:
|
||||||
form_options:
|
form_options:
|
||||||
extra_options:
|
extra_options:
|
||||||
class: '%sylius.model.customer.class%'
|
class: '%sylius.model.customer.class%'
|
||||||
choice_label: fullname
|
choice_label: nameOrEmail
|
||||||
date:
|
date:
|
||||||
type: date
|
type: date
|
||||||
label: sylius.ui.date
|
label: sylius.ui.date
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,17 @@ class Customer implements CustomerInterface, \Stringable
|
||||||
return trim(sprintf('%s %s', $this->firstName, $this->lastName));
|
return trim(sprintf('%s %s', $this->firstName, $this->lastName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNameOrEmail(): string
|
||||||
|
{
|
||||||
|
$fullName = $this->getFullName();
|
||||||
|
|
||||||
|
if ('' !== $fullName) {
|
||||||
|
return sprintf('%s (%s)', $fullName, $this->email);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
public function getFirstName(): ?string
|
public function getFirstName(): ?string
|
||||||
{
|
{
|
||||||
return $this->firstName;
|
return $this->firstName;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ interface CustomerInterface extends TimestampableInterface, ResourceInterface
|
||||||
|
|
||||||
public function getFullName(): string;
|
public function getFullName(): string;
|
||||||
|
|
||||||
|
public function getNameOrEmail(): string;
|
||||||
|
|
||||||
public function getFirstName(): ?string;
|
public function getFirstName(): ?string;
|
||||||
|
|
||||||
public function setFirstName(?string $firstName): void;
|
public function setFirstName(?string $firstName): void;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue