-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update order modifiers to fix data updates (#32)
* Update order modifiers to fix data updates * Fix coding standard issues * Optimize order item configuration * Add variables to reduce cyclomatic complexity
- Loading branch information
1 parent
69181d4
commit 96eeb94
Showing
8 changed files
with
127 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright Youwe. All rights reserved. | ||
* https://www.youweagency.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JcElectronics\ExactOrders\Modifiers\Order; | ||
|
||
use JcElectronics\ExactOrders\Api\Data\ExternalOrderInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
|
||
class SetExternalOrderData extends AbstractModifier | ||
{ | ||
/** | ||
* @param ExternalOrderInterface $entity | ||
*/ | ||
public function supports(mixed $entity): bool | ||
{ | ||
return $entity instanceof ExternalOrderInterface && | ||
$entity->getExtOrderId(); | ||
} | ||
|
||
/** | ||
* @param ExternalOrderInterface $model | ||
* @param OrderInterface $result | ||
* | ||
* @return OrderInterface | ||
*/ | ||
public function process(mixed $model, mixed $result): mixed | ||
{ | ||
if ($result->getExtOrderId()) { | ||
return $result; | ||
} | ||
|
||
$result->setExtOrderId($model->getExtOrderId()) | ||
->setExtCustomerId($model->getExternalCustomerId()); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters