# Custom Rule (Shopware 6.4.13)

**URL:** <https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094>\
**Category:** Programmierung\
**Created:** [4. Juli 2022 um 08:51 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094 "2022-07-04T08:51:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milad](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Milad](https://forum.shopware.com/u/Milad)\
**Post date:** [4. Juli 2022 um 08:51 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/1 "2022-07-04T08:51:35Z")

</div>

Hi,

ich hatte in meinem Plugin eine custom Regel geschrieben und das hatte bis jzt problemolos funktioniert.

Als ich den Shop auf 6.4.13 aktualisiert habe, funktioniert es nicht mehr.

Ich habe mir die Dokumentation auf Git nochmal angeschaut, es wurde nicht aktualisiert.

Habe den Code geschaut und es gibt ein neues Attribut für addCondition, und das heißt „group.“  
Das habe ich in meinem Code hinzugefügt und jzt sieht es so aus:

```auto
Shopware.Application.addServiceProviderDecorator('ruleConditionDataProviderService', (ruleConditionService) => {
    ruleConditionService.addCondition('limit_order', {
        component: 'limit-order',
        label: 'Auftragshöhe Limit',
        scopes: ['global'],
        group: 'general'
    });

    return ruleConditionService;
});

```

Aber damit geht es auch nicht.

index.js:

```auto
import template from './limit-order.html.twig';

Shopware.Component.extend('limit-order', 'sw-condition-base', {
    template,

    computed: {
        selectValues() {
            return [
                {
                    label: this.$tc('global.sw-condition.condition.yes'),
                    value: true
                },
                {
                    label: this.$tc('global.sw-condition.condition.no'),
                    value: false
                }
            ];
        },

        isOrderLimit: {
            get() {
                this.ensureValueExist();

                if (this.condition.value.isOrderLimit == null) {
                    this.condition.value.isOrderLimit = false;
                }
                return this.condition.value.isOrderLimit;
            },
            set(isOrderLimit) {
                this.ensureValueExist();
                this.condition.value = { ...this.condition.value, isOrderLimit };
            }
        }
    }
});

```

limit-order.html.twig:

```auto
{% block sw_condition_value_content %}
    <div class="sw-condition-payment-method sw-condition__condition-value">
        {% block sw_condition_payment_method_field %}
            <sw-single-select name="limit-order"
                              id="limit-order"
                              size="medium"
                              :options="selectValues"
                              v-model="isOrderLimit"
                              class="field--main">
            </sw-single-select>
        {% endblock %}
    </div>
{% endblock %}

```

Gibt es eine andere Änderung, die ich verpasst habe?

Danke im Voraus!

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [4. Juli 2022 um 09:00 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/2 "2022-07-04T09:00:58Z")

</div>

Kann dir zu dem Thema nicht viel sagen, aber empfehlen die Implementierung der Shopware-Standard-Regeln in GitHub anzusehen. Da solltest du mögliche Änderungen ableiten können.

---

<div class="post-metadata">

**Author:** ![Milad](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Milad](https://forum.shopware.com/u/Milad)\
**Post date:** [4. Juli 2022 um 09:13 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/3 "2022-07-04T09:13:33Z")

</div>

Danke für die Antwort, @Max_Shop!

Das habe ich gemacht. Sehen gleich aus… Z.B.

> <https://github.com/shopware/platform/blob/d60cf205356282cc5a5227c088aeed078bcdd6e4/src/Administration/Resources/app/administration/src/app/decorator/condition-type-data-provider.decorator.js#L104>

> <https://github.com/shopware/platform/blob/01d2da25be8d437bae0e6617c6e11b102c9ece6d/src/Administration/Resources/app/administration/src/app/component/rule/condition-type/sw-condition-date-range/index.js>

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [4. Juli 2022 um 09:15 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/4 "2022-07-04T09:15:25Z")

</div>

Das einzige was mir auffällt in [platform/condition-type-data-provider.decorator.js at d60cf205356282cc5a5227c088aeed078bcdd6e4 · shopware/platform · GitHub](https://github.com/shopware/platform/blob/d60cf205356282cc5a5227c088aeed078bcdd6e4/src/Administration/Resources/app/administration/src/app/decorator/condition-type-data-provider.decorator.js) ist ein , nach dem group: ‚general‘, aber das Trailing comma kann eigentlich kein Unterschied ausmachen.

Per build-administration.sh bekommst du keine Notes oder Warnings?

---

<div class="post-metadata">

**Author:** ![Milad](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Milad](https://forum.shopware.com/u/Milad)\
**Post date:** [4. Juli 2022 um 09:29 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/5 "2022-07-04T09:29:59Z")

</div>

> Das einzige was mir auffällt in [platform/condition-type-data-provider.decorator.js at d60cf205356282cc5a5227c088aeed078bcdd6e4 · shopware/platform · GitHub](https://github.com/shopware/platform/blob/d60cf205356282cc5a5227c088aeed078bcdd6e4/src/Administration/Resources/app/administration/src/app/decorator/condition-type-data-provider.decorator.js) ist ein , nach dem group: ‚general‘, aber das Trailing comma kann eigentlich kein Unterschied ausmachen.

Wie Du selbst geschrieben hast, das machte kein Unteschied aus.

> Per build-administration.sh bekommst du keine Notes oder Warnings?

Leider nein… Ich bekomme sogar diese Meldung:  
`Plugin "UserConfigurator": Injected successfully`

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [4. Juli 2022 um 12:39 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/6 "2022-07-04T12:39:47Z")

</div>

@Milad was genau funktioniert denn nicht mehr? Wird die Regel im Admin nicht mehr angezeigt?

---

<div class="post-metadata">

**Author:** ![Milad](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Milad](https://forum.shopware.com/u/Milad)\
**Post date:** [5. Juli 2022 um 05:22 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/7 "2022-07-05T05:22:05Z")

</div>

@abdullah Ja, genau!

Ich habe es nochmal Lokal auf einem alten Shop installiert und hat funktioniert. Aber das geht leider nicht in Shopware 6.4.13 und da brauche ich es.

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [6. Juli 2022 um 00:01 UTC](https://forum.shopware.com/t/custom-rule-shopware-6-4-13/95094/8 "2022-07-06T00:01:27Z")

</div>

@Milad, ich habe mal meine CustomRules unter Shopware 6.4.13.0 angeguckt. Meine werden weiterhin angezeigt. Ich habe aber die Administration neu gebaut. Ob die alte ZIP Datei meines Plugins funktionieren würde, müsste ich bei Gelegenheit mal testen.

Bei deinem Code sehe ich aber bis jetzt auch keine Fehler.

Treten denn in der Browser Console irgendwelche Fehler auf?
