# Update order to add attribute

**URL:** <https://forum.shopware.com/t/update-order-to-add-attribute/50633>\
**Category:** International (English Only)\
**Tags:** programming\
**Created:** [24. Januar 2018 um 09:49 UTC](https://forum.shopware.com/t/update-order-to-add-attribute/50633 "2018-01-24T09:49:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@roberto](https://forum.shopware.com/u/roberto)\
**Post date:** [24. Januar 2018 um 09:49 UTC](https://forum.shopware.com/t/update-order-to-add-attribute/50633/1 "2018-01-24T09:49:21Z")

</div>

Hi,

I’m trying to update an order to add content to an attribute depending on user’s selection. It is working so far but the attribute value is saved in the ‘preorder’ row which I don’t know how to relate to the actual order row in the database:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/b/b7e0dce235557c64d147d84ff7cefe977cc69148.jpeg)

Once the user clicks on the order now button it saves my value using the order id but this id it’s not the final one, so when the order is confirmed a new row is inserted but they have nothing in common. Maybe I’m subscribed to the wrong event? At the moment I’m using **Enlight\_Controller\_Action\_Frontend\_Checkout\_Finish** but the order seems to be not created at this stage, any other idea on how can I add information to an order?

Thank you

---

<div class="post-metadata">

**Author:** ![Jan\_Bucker](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Jan\_Bucker](https://forum.shopware.com/u/Jan_Bucker)\
**Post date:** [24. Januar 2018 um 14:57 UTC](https://forum.shopware.com/t/update-order-to-add-attribute/50633/2 "2018-01-24T14:57:35Z")

</div>

Hey, there are some more events you can use. If you take a look into the engine/Shopware/Core/sOrder.php file, there is a method called sSaveOrder() which will be called when saving an order.

When the method is executed, there are some events dispatched which may be useful for your use-case. For example:

- Shopware\_Modules\_Order\_SaveOrder\_FilterParams
- Shopware\_Modules\_Order\_SaveOrder\_FilterAttributes
- Shopware\_Modules\_Order\_SaveOrder\_FilterDetailAttributes
- Shopware\_Modules\_Order\_SaveOrder\_ProcessDetails

They will be dispatched in order I’ve listed them.

&nbsp;

---

<div class="post-metadata">

**Author:** ![roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@roberto](https://forum.shopware.com/u/roberto)\
**Post date:** [24. Januar 2018 um 15:01 UTC](https://forum.shopware.com/t/update-order-to-add-attribute/50633/3 "2018-01-24T15:01:28Z")

</div>

Hi Jan,

Thank you for your answer, I’m going to try it 🙂

---

<div class="post-metadata">

**Author:** ![vasims\_zignuts](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vasims\_zignuts](https://forum.shopware.com/u/vasims_zignuts)\
**Post date:** [1. Oktober 2019 um 13:23 UTC](https://forum.shopware.com/t/update-order-to-add-attribute/50633/4 "2019-10-01T13:23:40Z")

</div>

I am going to create a plugin. This plugin will call external API once stock level updated (i.e. decrease qty). My plugin file consist following code. I can’t find var\_dump or expected output not display. :

```
scheduleClearCache(ActivateContext::CACHE_LIST_DEFAULT);
    }
    public function deactivate(DeactivateContext $context)
    {
        $context->scheduleClearCache(DeactivateContext::CACHE_LIST_DEFAULT);
    }
    public function uninstall()
    {
        return true;
    }
    public function install()
    {
        # this event will be used after saving the order in the database
        return [
            'Shopware_Modules_Order_SaveOrder_ProcessDetails' => 'OnOrder_SaveOrderProcessDetails',
        ];
      
    }

    public function onOrder_SaveOrderProcessDetails(Enlight_Event_EventArgs $args)
	{
       // get SKU of Order items

       // Write here a qty you want to update on external 
       //CURL code will place here
	}
  
}

?>

```

&nbsp;
