Commit 3bb86a2f authored by Vincent Mrose's avatar Vincent Mrose 💬
Browse files

Updated autocapture for categories


Signed-off-by: Vincent Mrose's avatarVincent Mrose <v.mrose@crefopay.de>
parent 198eb653
......@@ -82,8 +82,8 @@ class Order
}
/**
* Checks whether all the order products contained in the allowed categories for auto capture. And whether payment method
* allowed to perform auto capture.
* Checks whether at least one product from the order is assigned to the allowed categories for auto capture.
* And whether payment method allowed to perform auto capture.
*
* @param SalesOrder $order
*
......@@ -109,18 +109,20 @@ class Order
$allowedCategoryIds = array_map('intval', $this->gatewayConfig->getAutoCaptureCategoryIds());
if (empty($allowedCategoryIds)) {
return true;
return false;
}
/** @var \Magento\Sales\Model\Order\Item $orderItem */
foreach ($order->getItemsCollection() as $orderItem) {
$productCategoryIds = array_map('intval', $orderItem->getProduct()->getCategoryIds());
if (!empty(array_diff($productCategoryIds, $allowedCategoryIds))) {
return false;
foreach ($productCategoryIds as $categoryId) {
if (in_array($categoryId, $allowedCategoryIds)) {
return true;
}
}
}
return true;
return false;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment