# Is there a way to extend sOrder.php in order to write custom logic in shopware 5?

**URL:** <https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228>\
**Category:** Shopware 5\
**Created:** [11. Juli 2022 um 11:03 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228 "2022-07-11T11:03:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aswathy](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@aswathy](https://forum.shopware.com/u/aswathy)\
**Post date:** [11. Juli 2022 um 11:03 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/1 "2022-07-11T11:03:27Z")

</div>

There is a need to write custom logic in sOrder.php(engine/ Shopware/ Core/sOrder.php). Is there a way to extend sOrder.php in order to write custom logic in shopware 5?

---

<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:** [11. Juli 2022 um 11:49 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/2 "2022-07-11T11:49:41Z")

</div>

see Shopware documentation: [Understanding the Shopware hook system](https://developers.shopware.com/blog/2015/06/09/understanding-the-shopware-hook-system/)

---

<div class="post-metadata">

**Author:** ![aswathy](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@aswathy](https://forum.shopware.com/u/aswathy)\
**Post date:** [13. Juli 2022 um 11:13 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/3 "2022-07-13T11:13:39Z")

</div>

Hi, I want to extend getPartnerCode(), Which is private (sOrder.php). Is it possible to extend a private function using Hooks? If not , Is there any other method for adding custom code/extend this function?

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [13. Juli 2022 um 11:29 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/4 "2022-07-13T11:29:19Z")

</div>

Hi @aswathy

what do you want to achieve? If you want to implement your own logic for identifying the `partner` you can use this event:

> <https://github.com/shopware/shopware/blob/v5.7.13/engine/Shopware/Core/sOrder.php#L631>

There you can change the value of `partnerID` within the array.

Best regards from Schöppingen  
Michael Telgmann

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [14. Juli 2022 um 10:40 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/5 "2022-07-14T10:40:49Z")

</div>

edit: private methods can not be hooked.

---

<div class="post-metadata">

**Author:** ![aswathy](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@aswathy](https://forum.shopware.com/u/aswathy)\
**Post date:** [14. Juli 2022 um 11:48 UTC](https://forum.shopware.com/t/is-there-a-way-to-extend-sorder-php-in-order-to-write-custom-logic-in-shopware-5/95228/6 "2022-07-14T11:48:44Z")

</div>

private function getPartnerCode($userAffiliate)  
{  
$isPartner = $this-\>getSession()-\>offsetGet(‚sPartner‘);  
if (!empty($isPartner)) {  
return $this-\>getSession()-\>offsetGet(‚sPartner‘);  
}

if (empty($userAffiliate)) {  
return null;  
}

// Get Partner code  
return $this-\>db-\>fetchOne(  
‚SELECT idcode FROM s\_emarketing\_partner WHERE id = ?‘,  
[$userAffiliate]  
);  
}  
In the above function I need to modify the  
if (!empty($isPartner)) {} -  
to  
if (!empty($isPartner) && $customerGroupId == 1 ) {}

Is there any way to do this?

I have googled , but no solutions found. Can you please help me with this.

Thanks in advance
