Fix hardcoded custom code that goes on each shopware update

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?