Skip to content

Commit

Permalink
Bp 2661 magento 2 reward points module conflict when using klarna kp (#…
Browse files Browse the repository at this point in the history
…744)

* Fix reward points

* restore reward points on cancel

* remove restore functionality

---------

Co-authored-by: Ivascu Madalin <[email protected]>
  • Loading branch information
harli91 and Ivascu Madalin authored Jun 29, 2023
1 parent c64dc3c commit a1e6569
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Model/Method/Klarnakp.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,13 @@ public function getRequestArticlesData($payment)
$requestData = array_merge($requestData, $discountline);
}

$group++;
$reward = $this->getRewardLine($quote, $group);

if (!empty($reward)) {
$requestData = array_merge($requestData, $reward);
}

return $requestData;
}

Expand Down Expand Up @@ -821,6 +828,60 @@ public function getDiscountLine($payment, $group)
return $article;
}

/**
* Get the reward cost lines
*
* @param Quote $quote
* @param $group
*
* @return array
*/
public function getRewardLine($quote, $group)
{
$article = [];
$discount = (float)$quote->getRewardCurrencyAmount();

if ($discount <= 0) {
return $article;
}

$article = [
[
'_' => 4,
'Group' => 'Article',
'GroupID' => $group,
'Name' => 'ArticleNumber',
],
[
'_' => -$discount,
'Group' => 'Article',
'GroupID' => $group,
'Name' => 'ArticlePrice',
],
[
'_' => 1,
'Group' => 'Article',
'GroupID' => $group,
'Name' => 'ArticleQuantity',
],
[
'_' => 'Discount Reward Points',
'Group' => 'Article',
'GroupID' => $group,
'Name' => 'ArticleTitle',
],
[
'_' => 0,
'Group' => 'Article',
'GroupID' => $group,
'Name' => 'ArticleVat',
],
];

return $article;
}


/**
* @param OrderInterface $order
* @param $group
Expand Down

0 comments on commit a1e6569

Please sign in to comment.