# Problem bei Auswahl der Versandkosten entsprechend der Artikel im Warenkorb.

**URL:** https://forum.shopware.com/t/problem-bei-auswahl-der-versandkosten-entsprechend-der-artikel-im-warenkorb/62010
**Category:** Programmierung
**Created:** [26. September 2019 um 11:02 UTC](https://forum.shopware.com/t/problem-bei-auswahl-der-versandkosten-entsprechend-der-artikel-im-warenkorb/62010 "2019-09-26T11:02:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![manatwork81](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@manatwork81](https://forum.shopware.com/u/manatwork81)
#### Post date: [26. September 2019 um 11:02 UTC](https://forum.shopware.com/t/problem-bei-auswahl-der-versandkosten-entsprechend-der-artikel-im-warenkorb/62010/1 "2019-09-26T11:02:52Z")

</div>

Es gibt zwei Standartversandarten, „ **Standard** “ und „ **24H-Lieferung** “. Derzeit beide im Warenkorb wählbar.  
Ziel: Liegt der Artikel XXX im Warenkorb, soll „24H-Lieferung“ verwendet werden, andernfalls „Standard“.  
**Einstellungen \> Versandkosten \> Erweiterte Einstellungen**

Also zum Handbuch: ([https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/versandkosten#erweiterte-einstellungen](https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/versandkosten#erweiterte-einstellungen)).  
Hier wird man auf Beispiele ([https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/individuelle-versandkosten#eigene-bedingungen](https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/individuelle-versandkosten#eigene-bedingungen)) verwiesen.  
Dort heißt es jedoch: „Für die eigene Bedingung muss oft unter **Einstellungen \> Grundeinstellungen \> Storefront \> Versandkosten-Modul** die „Erweiterte SQL-Abfrage“ erweitert werden.“

Folgendes Beispiel sieht passend aus:  
MAX(a.topseller) AS has\_topseller, MAX(at.attr3) AS has\_comment, MAX(b.esdarticle) AS has\_esd, MIN(IF(d.ordernumber LIKE ‚%XXX%‘ OR b.modus \<\> 0,1,0)) AS artikel  
Verstehe aber nicht was es bewirken sollte, weil da ja keine Versandart angesprochen wird. Es passiert (wie erwartet) nichts.

Logischer schiene mir „MIN(IF(d.ordernumber LIKE ‚%XXX%‘ OR b.modus \<\> 0,1,0)) AS artikel” in **Einstellungen \> Versandkosten \> Erweiterte Einstellungen** unterzubringen.  
Doch da hängt sich der Warenkorb auf im System Log kommt ein Fehler (siehe unten).

Worin könnte mein Denkfehler bestehen?

THX vorab!

&nbsp;

Fehler aus dem System Log:

PDOException: SQLSTATE(42000): Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‚AS artikel))) GROUP BY d.id ORDER BY d.position, d.name ASC‘ at line 13 in /vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:907 Stack trace:

#0 /vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(907): PDOStatement-\>execute()

#1 /vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(206): Doctrine\DBAL\Connection-\>executeQuery(‚SELECT d.id as …‘, Array, Array)

#2 /engine/Shopware/Core/sAdmin.php(2789): Doctrine\DBAL\Query\QueryBuilder-\>execute()

#3 /engine/Shopware/Controllers/Frontend/Checkout.php(1590): sAdmin-\>sGetPremiumDispatches(‚2‘, NULL, NULL)

#4 /engine/Shopware/Controllers/Frontend/Checkout.php(1724): Shopware\_Controllers\_Frontend\_Checkout-\>getSelectedDispatch()

#5 /engine/Library/Enlight/Controller/Action.php(192): Shopware\_Controllers\_Frontend\_Checkout-\>ajaxCartAction()

#6 /engine/Library/Enlight/Controller/Dispatcher/Default.php(478): Enlight\_Controller\_Action-\>dispatch(‚ajaxCartAction‘)

#7 /engine/Library/Enlight/Controller/Front.php(228): Enlight\_Controller\_Dispatcher\_Default-\>dispatch(Object(Enlight\_Controller\_Request\_RequestHttp), Object(Enlight\_Controller\_Response\_ResponseHttp))

#8 /engine/Shopware/Kernel.php(185): Enlight\_Controller\_Front-\>dispatch()

#9 /vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php(102): Shopware\Kernel-\>handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)

#10 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(448): Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(Object(Shopware\Kernel), Object(Symfony\Component\HttpFoundation\Request), 1, true)

#11 /engine/Shopware/Components/HttpCache/AppCache.php(256): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)

#12 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(420): Shopware\Components\HttpCache\AppCache-\>forward(Object(Symfony\Component\HttpFoundation\Request), true)

#13 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(317): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>fetch(Object(Symfony\Component\HttpFoundation\Request), true)

#14 /engine/Shopware/Components/HttpCache/AppCache.php(183): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>lookup(Object(Symfony\Component\HttpFoundation\Request), true)

#15 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(192): Shopware\Components\HttpCache\AppCache-\>lookup(Object(Symfony\Component\HttpFoundation\Request), true)

#16 /engine/Shopware/Components/HttpCache/AppCache.php(110): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) …

An exception occurred while executing

‚SELECT d.id as `key`, d.id, d.name, d.description, d.calculation, d.status\_link, b.\* FROM s\_premium\_dispatch d INNER JOIN (SELECT ‚1‘ as `instock`,‚1‘ as `stockmin`,‚0‘ as `laststock`,‘’ as `weight`,‚2‘ as `count_article`,‚0‘ as `shippingfree`,‚2099.8‘ as `amount`,‚1764.54‘ as `amount_net`,‚2099.80‘ as `amount_display`,’’ as `length`,’’ as `height`,’’ as `width`,‚1‘ as `userID`,‚0‘ as `has_topseller`,’’ as `has_comment`,‚0‘ as `has_esd`,‚0‘ as `artikel`,‚19‘ as `max_tax`,‚0‘ as `basketStateId`,‚2‘ as `countryID`,‚5‘ as `paymentID`,‚1‘ as `customergroupID`,‚1‘ as `multishopID`,‚pe6krlfiaavrd86ivdcd6i6pn8‘ as `sessionID`) b ON 1=1 INNER JOIN s\_premium\_dispatch\_countries dc ON d.id = dc.dispatchID AND dc.countryID=b.countryID INNER JOIN s\_premium\_dispatch\_paymentmeans dp ON d.id = dp.dispatchID AND dp.paymentID=b.paymentID LEFT JOIN s\_premium\_holidays h ON h.date = CURDATE() LEFT JOIN s\_premium\_dispatch\_holidays dh ON d.id=dh.dispatchID AND h.id=dh.holidayID LEFT JOIN (SELECT dc.dispatchID FROM s\_order\_basket b INNER JOIN s\_articles\_categories\_ro ac ON ac.articleID = b.articleID INNER JOIN s\_premium\_dispatch\_categories dc ON dc.categoryID = ac.categoryID WHERE (b.modus = 0) AND (b.sessionID = ?) GROUP BY dc.dispatchID) dk ON dk.dispatchID=d.id LEFT JOIN s\_user u ON&nbsp; u.id=b.userID AND u.active=1 LEFT JOIN s\_user\_addresses ub ON ub.user\_id = u.id AND ub.id = ? LEFT JOIN s\_user\_addresses us ON us.user\_id = u.id AND us.id = ? WHERE (d.active = 1) AND ((&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (bind\_time\_from IS NULL AND bind\_time\_to IS NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (IFNULL(bind\_time\_from,0) \<= IFNULL(bind\_time\_to,86400) AND TIME\_TO\_SEC(DATE\_FORMAT(NOW(),"%H:%i:00")) BETWEEN IFNULL(bind\_time\_from,0) AND IFNULL(bind\_time\_to,86400))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (bind\_time\_from \> bind\_time\_to AND TIME\_TO\_SEC(DATE\_FORMAT(NOW(),"%H:%i:00")) NOT BETWEEN bind\_time\_to AND bind\_time\_from)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )) AND ((&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (bind\_weekday\_from IS NULL AND bind\_weekday\_to IS NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (IFNULL(bind\_weekday\_from,1) \<= IFNULL(bind\_weekday\_to,7) AND WEEKDAY(NOW())+1 BETWEEN IFNULL(bind\_weekday\_from,1) AND IFNULL(bind\_weekday\_to,7))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (bind\_weekday\_from \> bind\_weekday\_to AND WEEKDAY(NOW())+1 NOT BETWEEN bind\_weekday\_to AND bind\_weekday\_from)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )) AND ((bind\_weight\_from IS NULL OR bind\_weight\_from \<= b.weight)) AND ((bind\_weight\_to IS NULL OR bind\_weight\_to \>= b.weight)) AND ((bind\_price\_from IS NULL OR bind\_price\_from \<= b.amount)) AND ((bind\_price\_to IS NULL OR bind\_price\_to \>= b.amount)) AND ((bind\_instock=0 OR bind\_instock IS NULL OR (bind\_instock=1 AND b.instock) OR (bind\_instock=2 AND b.stockmin))) AND ((bind\_laststock=0 OR (bind\_laststock=1 AND b.laststock))) AND ((bind\_shippingfree!=1 OR NOT b.shippingfree)) AND (dh.holidayID IS NULL) AND ((d.multishopID IS NULL OR d.multishopID=b.multishopID)) AND ((d.customergroupID IS NULL OR d.customergroupID=b.customergroupID)) AND (dk.dispatchID IS NULL) AND (d.type IN (0)) AND ((d.id != 15 OR (MIN(IF(d.ordernumber LIKE ‚%ZUS%‘ OR b.modus \<\> 0,0,1)) AS artikel))) GROUP BY d.id ORDER BY d.position, d.name ASC’ with params („pe6krlfiaavrd86ivdcd6i6pn8“, 1, 1):&nbsp;

SQLSTATE(42000): Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‚AS artikel))) GROUP BY d.id ORDER BY d.position, d.name ASC‘ at line 13
