# Eigene Bedingung bei Versandart

**URL:** <https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639>\
**Category:** Programmierung\
**Created:** [13. Juni 2020 um 13:13 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639 "2020-06-13T13:13:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![axefg](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@axefg](https://forum.shopware.com/u/axefg)\
**Post date:** [13. Juni 2020 um 13:13 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/1 "2020-06-13T13:13:45Z")

</div>

Hallo zusammen

Ich möchte eine eigene Bedingung machen, scheitere aber daran.

- Bedingung Versandart: Diese Versandart soll nur aktiv sein, wenn einer der beiden folgenden Artikelnummern im Warenkorb ist:&nbsp;SS10230, SS10229.

Wie bringe ich das hin?

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [15. Juni 2020 um 10:23 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/2 "2020-06-15T10:23:20Z")

</div>

Nach Artikel kann man die Versandart nicht so einfach einschränken, aber nach Kategorien - Wie wäre es wenn du diese speziellen Artikel in einer Kategorie zusammenfasst und dann diese bei der Versandart hinterlegst?

---

<div class="post-metadata">

**Author:** ![axefg](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@axefg](https://forum.shopware.com/u/axefg)\
**Post date:** [18. Juni 2020 um 05:47 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/3 "2020-06-18T05:47:30Z")

</div>

Wäre eine Idee, danke.

Doch wie bringe ich es hin, dass dann diese letzte (pseudo) Kategorie nicht im Shop angezeigt wird?

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [19. Juni 2020 um 06:17 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/4 "2020-06-19T06:17:39Z")

</div>

Für die Anzeige in der Topnavi gibt es eine Checkbox… die Sidenavi wäre dann natürlich ein Problem…

Aber es gibt bei den Versandarten auch noch einen Reiter „Erweiterte Einstellungen“ für „Eigene Bedingungen/Berechnungen“, evtl. kann man es darüber lösen.  
Muss ich aber ehrlich zugeben die Felder noch nie benutzt zu haben, ggf. findest du aber Beispiele im Forum oder in der Funktionsbeschreibung wie man diese Bedingungen formuliert 🙂

---

<div class="post-metadata">

**Author:** ![axefg](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@axefg](https://forum.shopware.com/u/axefg)\
**Post date:** [21. Juni 2020 um 14:50 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/5 "2020-06-21T14:50:03Z")

</div>

PStadtfeld: Genau so wollte ich es lösen, doch ohne Erfolg. Siehe Fehlermeldungen auf dem Backend-Log am Schluss. Im Warenkorb bekomme ich lediglich einen Fehler.

**Mein Code für "Eigene Bedingungen"**

IF(d.ordernumber LIKE ‚%SS10230%‘ OR ‚%SS10229%‘,1,0)

Gemäss:&nbsp;[https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/individuelle-versandkosten#artikelnummern](https://docs.shopware.com/de/shopware-5-de/versand-und-zahlungsarten/individuelle-versandkosten#artikelnummern)

Hast du noch eine andere Idee?

**Erste Fehlermeldung**

PDOException: SQLSTATE(42S22): Column not found: 1054 Unknown column ‚d.ordernumber‘ in ‚where clause‘ 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(2797): Doctrine\DBAL\Query\QueryBuilder-\>execute()  
#3 /engine/Shopware/Controllers/Frontend/Checkout.php(1572): sAdmin-\>sGetPremiumDispatches(26, NULL, NULL)  
#4 /engine/Shopware/Controllers/Frontend/Checkout.php(151): Shopware\_Controllers\_Frontend\_Checkout-\>getSelectedDispatch()  
#5 /engine/Library/Enlight/Controller/Action.php(192): Shopware\_Controllers\_Frontend\_Checkout-\>cartAction()  
#6 /engine/Library/Enlight/Controller/Dispatcher/Default.php(478): Enlight\_Controller\_Action-\>dispatch(‚cartAction‘)  
#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(188): 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(453): Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(Object(Shopware\Kernel), Object(Symfony\Component\HttpFoundation\Request), 1, true)  
#11 /engine/Shopware/Components/HttpCache/AppCache.php(261): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)  
#12 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(426): 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(188): 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(113): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)  
#17 /home/hebinesi/www/domain.ch/shopware.php(122): Shopware\Components\HttpCache\AppCache-\>handle(Object(Symfony\Component\HttpFoundation\Request))  
#18

**Zweite Fehlermeldung**

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`,‚0.000‘ as `weight`,‚1‘ as `count_article`,‚0‘ as `shippingfree`,‚62‘ as `amount`,‚62‘ as `amount_net`,‚62.00‘ as `amount_display`,‘’ as `length`,’’ as `height`,’’ as `width`,’’ as `userID`,‚0‘ as `has_topseller`,’’ as `has_comment`,‚0‘ as `has_esd`,‚0‘ as `max_tax`,‚0‘ as `basketStateId`,‚26‘ as `countryID`,‚4‘ as `paymentID`,‚1‘ as `customergroupID`,‚1‘ as `multishopID`,‚ba5bafc79c5d280a2f028f3af42d59001642b2559f5148a8ef846b39459acf2d‘ 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; (bind\_time\_from IS NULL AND bind\_time\_to IS NULL) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OR &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; OR &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; )) AND (( &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; OR &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; OR &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; )) 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 != 14 OR (IF(d.ordernumber LIKE ‚%SS10230%‘ OR ‚%SS10229%‘,1,0)))) AND ((d.id != 15 OR (IFNULL(us.zipcode,ub.zipcode) = ‚9113‘))) GROUP BY d.id ORDER BY d.position, d.name ASC’ with params („ba5bafc79c5d280a2f028f3af42d59001642b2559f5148a8ef846b39459acf2d“, 0, 0): &nbsp;SQLSTATE(42S22): Column not found: 1054 Unknown column ‚d.ordernumber‘ in ‚where clause‘

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [23. Juni 2020 um 08:24 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/6 "2020-06-23T08:24:09Z")

</div>

Ja okay, es scheint als hätte sich die Funktion grundlegend geändert seit der letzten Überarbeitung der Dokumentationen und Hilfen seitens Shopware…  
Die Artikelnummer erscheint im entsprechenden Statement überhaupt nicht mehr und kann demanch auch nicht abgefragt werden (ist alles in Subqueries kaputtverschachtelt).

Probier es mal hiermit, das sollte eigentlich funktionieren…

```
(SELECT max(IF(sob.ordernumber LIKE '%SS10230%' OR sob.ordernumber LIKE '%SS10229%',0,1)) 
	 FROM s_order_basket sob 
	 WHERE sob.sessionID = b.sessionID) = 0

```

Zum Statement: Die Versandart ist nur dann Verfügbar, wenn im Warenkorb außer den zwei genannten Artikeln nichts drin liegt.  
Der IF-Bereich könnte noch um den Modus erweitert werden um nur nach regulären Artikeln zu filtern (also Aktionen und Rabatte nicht berücksichtigen - wäre sinnvoll).  
(Also z.B. die Abfrage der Artikelnummern in Klammern und ein AND sob.modus = 0 dahinter)

Wenn die Versandart bei dir schon erscheinen soll wenn nur einer der Artikel vorliegt (unabhängig von anderen Artikeln im Warenkorb) dann ändere einfach 0 und 1 im IF und in der Abfrage am Ende.

---

<div class="post-metadata">

**Author:** ![Marcel3802](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Marcel3802](https://forum.shopware.com/u/Marcel3802)\
**Post date:** [8. Dezember 2021 um 10:31 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/7 "2021-12-08T10:31:16Z")

</div>

> [@PStadtfeld](#):
>
> Wenn die Versandart bei dir schon erscheinen soll wenn nur einer der Artikel vorliegt (unabhängig von anderen Artikeln im Warenkorb) dann ändere einfach 0 und 1 im IF und in der Abfrage am Ende.

Hi, stehe vor dem Selben Problem, in was sollte man denn 0 und 1 ändern?

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [8. Dezember 2021 um 10:51 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/8 "2021-12-08T10:51:50Z")

</div>

@Marcel3802

> [@PStadtfeld](#):
>
> ```auto
> (SELECT max(IF(sob.ordernumber LIKE '%SS10230%' OR sob.ordernumber LIKE '%SS10229%',1,0)) 
> FROM s_order_basket sob 
> WHERE sob.sessionID = b.sessionID) = 1
> 
> ```

So z.B. ?  
Jetzt würde er schauen ob zumindest ein Artikel den gesuchten Artikelnummern entspricht und sofern ein Artikel dies tut liefert er mit max 1 zurück, was dann 1=1 also true ergibt.

---

<div class="post-metadata">

**Author:** ![Marcel3802](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Marcel3802](https://forum.shopware.com/u/Marcel3802)\
**Post date:** [8. Dezember 2021 um 12:15 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/9 "2021-12-08T12:15:46Z")

</div>

das klappt!! Danke

hast du noch eine idee wie ich diese regel am besten für eine individuelle anzahl an skus anpassen kann?

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [8. Dezember 2021 um 13:14 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/10 "2021-12-08T13:14:22Z")

</div>

@Marcel3802  
Bin mir nicht sicher, ob ich das richtig verstehe… Individuelle Anzahl von Artikeln?  
Du könntest aus dem Max() ein Sum() machen und dann am Ende statt = 1 ein \>= DeineZahl.  
Dann würde er jeden treffenden Artikel zählen und nachher schauen, ob die Summe an Artikeln ausreicht um die Anforderung zu erfüllen.  
Bei genauer Zahl \> entfernen, also sum(…) = DeineZahl statt \>=

---

<div class="post-metadata">

**Author:** ![Marcel3802](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Marcel3802](https://forum.shopware.com/u/Marcel3802)\
**Post date:** [8. Dezember 2021 um 13:39 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/11 "2021-12-08T13:39:13Z")

</div>

so wars nicht gemeint, sondern wie kann ich z.B. 5 verschiedene Skus einfügen, der Filter ist ja nur für 1 SKU

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [9. Dezember 2021 um 07:20 UTC](https://forum.shopware.com/t/eigene-bedingung-bei-versandart/67639/12 "2021-12-09T07:20:18Z")

</div>

@Marcel3802  
Was meinst du mit SKU, die Artikelnummer ?  
Kannst das Beispiel beliebig erweitern indem du zusätzliche Bereiche wie diesen hinzufügst:

```auto
OR sob.ordernumber LIKE '%[DeineNummerHier]%'

```
