Skip to content

useSalutation() ​

WARNING

Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).

ts
import { useSalutation } from 'shopware:composables';

function useSalutation(): {
    salutation: (entity: SalutationFilterEntityType, fallbackSnippet?: string) => string;
};

Formats the salutation of a customer-like entity - anything carrying a salutation association along with title, firstName and lastName.

ts
const { salutation } = useSalutation();
const { tWithFallback } = useTranslateWithFallback();

const greeting = computed(() => salutation(customer.value, tWithFallback('sw-customer.detail.noSalutation')));

It resolves the salutation filter on each call, so it behaves exactly as the filter does in a template. The fallback is returned as it is, so pass translated text, not a snippet key.

Replaces the salutation mixin.

Was this page helpful?
UnsatisfiedSatisfied
Be the first to vote!
0.0 / 5  (0 votes)