# Fix hardcoded custom code that goes on each shopware update

**URL:** <https://forum.shopware.com/t/fix-hardcoded-custom-code-that-goes-on-each-shopware-update/95340>\
**Category:** Shopware 5\
**Tags:** programming\
**Created:** [18. Juli 2022 um 11:04 UTC](https://forum.shopware.com/t/fix-hardcoded-custom-code-that-goes-on-each-shopware-update/95340 "2022-07-18T11:04:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nisamudeen97](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@nisamudeen97](https://forum.shopware.com/u/nisamudeen97)\
**Post date:** [18. Juli 2022 um 11:04 UTC](https://forum.shopware.com/t/fix-hardcoded-custom-code-that-goes-on-each-shopware-update/95340/1 "2022-07-18T11:04:15Z")

</div>

We have currently hard coded a piece of code to check customer group and based on the result saving the cookie data. It is done in dev\>engine\>shopware\>core\>sOrder.php Below code is added which does the check. Meanwhile this is getting removed on each shopware upgrade.

private function getPartnerCode($userAffiliate, $customerGroupId)  
{  
$isPartner = $this-\>getSession()-\>offsetGet(‚sPartner‘);  
if (!empty($isPartner) && $customerGroupId == 1 ) {  
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]  
);  
}

work flow

1. affiliate link apply only when customer group is EK
2. if not empty customer is partner and customer group is EK

customerGroupId == 1 mean when is not EK do nothing… (not need to save the coockie)

Is it possible to add this custom code some where so that it wont go in each shopware upgrade? How it can be done? Can some one provide an idea about the same?
