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?
see Shopware documentation: Understanding the Shopware hook system
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?
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:
There you can change the value of partnerID
within the array.
Best regards from Schöppingen
Michael Telgmann
edit: private methods can not be hooked.
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