Skip to content

Commit

Permalink
create function for getRecipientCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
vegimcarkaxhija committed Jan 16, 2024
1 parent 9536f11 commit 23767ad
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions library/checkout/billinkcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,9 @@ public function getBillingAddress()
}
$country = new Country($this->invoice_address->id_country);

$category = self::CUSTOMER_TYPE_B2C;
if ($this->customerType == self::CUSTOMER_TYPE_B2B
|| $this->companyExists($this->invoice_address->company)) {
$category = self::CUSTOMER_TYPE_B2B;
}

$payload = [
'recipient' => [
'category' => $category,
'category' => $this->getRecipientCategory(),
'careOf' => $this->invoice_address->firstname . ' ' . $this->invoice_address->lastname,
'firstName' => $this->invoice_address->firstname,
'lastName' => $this->invoice_address->lastname,
Expand Down Expand Up @@ -134,6 +128,16 @@ public function getArticles()
return $mergedProducts;
}

public function getRecipientCategory()
{
$category = self::CUSTOMER_TYPE_B2C;
if ($this->customerType == self::CUSTOMER_TYPE_B2B
|| $this->companyExists($this->invoice_address->company)) {
$category = self::CUSTOMER_TYPE_B2B;
}
return $category;
}

protected function prepareProductArticles()
{
$articles = [];
Expand Down Expand Up @@ -250,15 +254,9 @@ public function getShippingAddress()
$country = $sendCloudData['country'];
}

$category = self::CUSTOMER_TYPE_B2C;
if ($this->customerType == self::CUSTOMER_TYPE_B2B
|| $this->companyExists($this->invoice_address->company)) {
$category = self::CUSTOMER_TYPE_B2B;
}

$payload = [
'recipient' => [
'category' => $category,
'category' => $this->getRecipientCategory(),
'careOf' => $this->shipping_address->firstname . ' ' . $this->shipping_address->lastname,
'firstName' => $this->shipping_address->firstname,
'lastName' => $this->shipping_address->lastname,
Expand Down

0 comments on commit 23767ad

Please sign in to comment.