# Basket Attribut oder Order Attribut im Frontend in der checkout/confirm anzeigen

**URL:** <https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638>\
**Category:** Programmierung\
**Created:** [24. Januar 2018 um 10:59 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638 "2018-01-24T10:59:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [24. Januar 2018 um 10:59 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/1 "2018-01-24T10:59:18Z")

</div>

Ich versuche schon den ganzen Morgen ein Custom-Field (zuerst in der s\_order\_attributes, dann in der s\_order\_basket\_attributes angelegt) auf der checkout/confirm einzubinden. Das letztendliche Ziel ist, dass auf der Confirm mehrere Eingabefelder (oder ähnliches) dem User präsentiert werden die dann letztendlich in der Order in Freitextfeldern gespeichert werden.&nbsp;

Ich bekomme aber im Frontend unter sBasket keine Attribute angezeigt. Und wie kann ich dann die User-Eingabe per post mitsenden damit sie von confirmAction und finishAction verarbeitet werden? Ich habs nach dem Prinzip von&nbsp;[Attribute system](https://developers.shopware.com/developers-guide/attribute-system/#adding-an-input-element-for-the-attribute-to-the-registration-form) probiert aber dier checkout benutzt keinen FormBuilder und als Input-Name \*\*attribute[attributeName]&nbsp;\*\*hat auch nicht geklappt 😕

---

<div class="post-metadata">

**Author:** ![karlharris](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@karlharris](https://forum.shopware.com/u/karlharris)\
**Post date:** [24. Januar 2018 um 21:02 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/2 "2018-01-24T21:02:43Z")

</div>

Ich hatte in der Anfangszeit ein ähnliches Problem und habe dann das [form]&nbsp;der AGBs um Felder erweitert und anschließend&nbsp;über das Event „Shopware\_Modules\_Order\_SaveOrder\_FilterParams“ die POST-Parameter abgefangen und zumindest die sechs Standard-Attribute befüllt bekommen…

---

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [26. Januar 2018 um 10:44 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/3 "2018-01-26T10:44:28Z")

</div>

Ich bin wie folgt vorgegangen. Ich registriere mich direkt auf die confirmAction des Checkout Controllers per Enligh\_Controller\_Action\_Frontend\_Checkout\_Confirm und manipulier das Order object ganz banal.

```
  public function onFrontendCheckoutConfirm(\Enlight_Event_EventArgs $args) {
        $controller = $args->getSubject();
        $order = Shopware()->Modules()->Order();
        if (!empty($order)) {
            $order->orderAttributes['my_test_field_a'] = 'hooray!';
            $order->orderAttributes['my_test_field_b'] = 'hooray!';
        }
    }

```

my\_test\_field\_a wurde per Plugin als custom field in der s\_orders\_attributes registrierrt und my\_test\_field\_b nicht. Auf den ersten Blick sieht es gut aus, ich hab in der Datenbank in der s\_orders\_attributes in my\_test\_field\_a hooray stehen. Sollte auch mit der finishAction funktionieren.

---

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [26. Januar 2018 um 14:56 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/4 "2018-01-26T14:56:30Z")

</div>

Nachtrag: das ist nun meine “vorläufiger” Lösungsweg:

```
// erweitern von frontend/checkout/confirm.tpl

{extends file='parent:frontend/checkout/confirm.tpl'}
{block name="frontend_checkout_confirm_additional_free_text_display"}
    {$smarty.block.parent}

...

                        

...

{/block}

```

Auf Checkout::finishAction und dem normalen PostDispatchSecure von Checkout&nbsp;registrieren und die passenden Aktionen implementieren

```
    public static function getSubscribedEvents()
    {
        return [
            // ...
            'Enlight_Controller_Action_PostDispatchSecure_Frontend_Checkout'
            => 'onPostDispatchFrontendCheckout',

            'Enlight_Controller_Action_Frontend_Checkout_Finish'
            => 'onFrontendCheckoutFinish',
            // ...
        ]
    }

    public function onFrontendCheckoutFinish(\Enlight_Event_EventArgs $args) {
        // handle custom fields in checkout confirmation
        $controller = $args->getSubject();
        $efData = $controller->Request()->getParam('myExampleField', '');
        $order = Shopware()->Modules()->Order();
        if (!empty($order)) {
            $order->orderAttributes['my_example_field'] = $efData ;
        }
    }

    public function onPostDispatchFrontendCheckout(\Enlight_Event_EventArgs $args) {
        $checkoutController = $args->getSubject();
        $view = $checkoutController->View();
               
        // ...

        // add user input from post back to checkout/confirm template
        // in case the users clicks finish button, but gets redirect back
        // to confirm due to missing stuff and so he doesnt need to retype 
        // the value back into the field
        $efData = ($checkoutController->Request()->getParam('myExampleField', ''));
        $view->assign('my_example_field', $efData);
    }

```

Und dann halt nurnoch ddas custom field auf s\_orders installieren

```
public function install(InstallContext $context)
    {
        $service = $this->container->get('shopware_attribute.crud_service');
        $service->update(
            's_order_attributes',
            'my_example_field',
            TypeMapping::TYPE_STRING,
            [
                'displayInBackend' => true,
                'label' => 'Beispiel',
                'supportText' => 'Wird bei der Bestellung prominent ausgewiesen'
            ]
        );
    }

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![karlharris](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@karlharris](https://forum.shopware.com/u/karlharris)\
**Post date:** [27. Januar 2018 um 17:30 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/5 "2018-01-27T17:30:39Z")

</div>

Nice! Thank you&nbsp; ![Thumb-Up](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/thumb-up.png "Thumb-Up")

---

<div class="post-metadata">

**Author:** ![sschreier](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sschreier/32/23296_2.png) [@sschreier](https://forum.shopware.com/u/sschreier)\
**Post date:** [27. Januar 2018 um 17:52 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/6 "2018-01-27T17:52:53Z")

</div>

Hallo,

dafür gibt es aber ansich auch ein Beispiel von Shopware selbst auf github, siehe: [Advanced Example how to create 2 custom fields, fill them in order process, display them in backend order list as new columns and make them editable in order detail view · GitHub](https://gist.github.com/sthamann/5343247) . Ist zwar noch auf dem alten Pluginsystem basierend, aber funktioniert ja trotzdem noch.

Grüße

Sebastian

---

<div class="post-metadata">

**Author:** ![flavorSelection](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@flavorSelection](https://forum.shopware.com/u/flavorSelection)\
**Post date:** [9. Februar 2020 um 12:58 UTC](https://forum.shopware.com/t/basket-attribut-oder-order-attribut-im-frontend-in-der-checkout-confirm-anzeigen/50638/7 "2020-02-09T12:58:18Z")

</div>

Vielen dank für den Code!
