#2130 Shopware 5.6.7: Warenkorb in Sprachshops funktioniert nicht mehr

Fehlerbeschreibung

Nach dem Update auf Shopware 5.6.7 funktioniert der Warenkorb eines oder mehrer Sprach-Shops nicht mehr. 


Du erhälst im Frontend die Fehlermeldung "Uncaught TypeError: Return value of Shopware_Controllers_Frontend_Checkout::isShippingAllowed() must be of the type bool [...]".


Ursache

Der Fehler steht unmittelbar mit dem Shopware Update im Zusammenhang und wird nicht durch ThemeWare verursacht. Ursache sind alte Übersetzungszustände.


Lösung

Zu dem Fehler gibt es bereits mehrere Einträge im Shopware Forum, z.B. hier: https://forum.shopware.com/discussion/69249/aufruf-des-warenkorbs-im-en-sprachhop-gibt-seit-update-auf-5-6-7-fehler


1. Lösungsmöglichkeit

Öffne und speichere alle Länder-Übersetzungen unter "Grundeinstellungen > Shopeinstellungen > Länder > Deutschland etc. > Übersetzung von Name".


2. Lösungsmöglichkeit

Passe die Methode isShippingAllowed() in dem Frontend Controller an. Füge dazu nach diesen Zeilen folgenden Code ein:

if (!array_key_exists('allow_shipping', $countryTranslations[$countryId])) {
  return $allowedByDefault;
}


Die vollständige Methode sieht dann so aus:

private function isShippingAllowed(int $countryId): bool
{
  $queryBuilder = $this->get('dbal_connection')->createQueryBuilder();

  $allowedByDefault = (bool) $queryBuilder->select('allow_shipping')
    ->from('s_core_countries', 'countries')
    ->where('countries.id = :countryId')
    ->setParameter(':countryId', $countryId)
    ->execute()
    ->fetchColumn();

  $countryTranslations = $this->get('modules')->sAdmin()->sGetCountryTranslation();

  if (!$countryTranslations) {
    return $allowedByDefault;
  }

  if (!array_key_exists($countryId, $countryTranslations)) {
    return $allowedByDefault;
  }

  if (!array_key_exists('allow_shipping', $countryTranslations[$countryId])) {
    return $allowedByDefault;
  }

  return $countryTranslations[$countryId]['allow_shipping'];
}



Bitte teile uns deine Meinung mit!

Danke, das hat mir geholfen
Hat mir nicht geholfen

87ce780aef64777df4a51e69afbeef26