-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: using existing bold order instead of always creating a new one …
…[CSE-28] (#307)
- Loading branch information
Showing
10 changed files
with
197 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
//phpcs:disable Magento2.Annotation.MethodArguments.NoCommentBlock | ||
//phpcs:disable Magento2.Annotation.MethodArguments.ParamMissing | ||
//phpcs:disable Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation | ||
|
||
namespace Bold\Checkout\Api; | ||
|
||
use Bold\Checkout\Api\Data\BoldQuoteInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
interface BoldQuoteRepositoryInterface | ||
{ | ||
/** | ||
* @param int $cartId | ||
* @return BoldQuoteInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function getByCartId(int $cartId): BoldQuoteInterface; | ||
} |
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,29 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
//phpcs:disable Magento2.Annotation.MethodArguments.NoCommentBlock | ||
//phpcs:disable Magento2.Annotation.MethodArguments.ParamMissing | ||
//phpcs:disable Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation | ||
|
||
namespace Bold\Checkout\Api\Data; | ||
|
||
interface BoldQuoteInterface | ||
{ | ||
public function getId(); | ||
|
||
public function getQuoteId(): ?int; | ||
|
||
public function setQuoteId(int $quoteId): void; | ||
|
||
public function getOrderCreated(): ?bool; | ||
|
||
public function setOrderCreated(bool $orderCreated): void; | ||
|
||
public function getApiType(): ?string; | ||
|
||
public function setApiType(string $apiType): void; | ||
|
||
public function getPublicOrderId(): ?string; | ||
|
||
public function setPublicOrderId(string $publicOrderId): void; | ||
} |
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,49 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
//phpcs:disable Magento2.Annotation.MethodArguments.NoCommentBlock | ||
//phpcs:disable Magento2.Annotation.MethodArguments.ParamMissing | ||
//phpcs:disable Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation | ||
|
||
namespace Bold\Checkout\Model; | ||
|
||
use Bold\Checkout\Api\BoldQuoteRepositoryInterface; | ||
use Bold\Checkout\Api\Data\BoldQuoteInterface; | ||
use Bold\Checkout\Model\ResourceModel\Quote\QuoteExtensionData as QuoteExtensionDataResource; | ||
use Bold\Checkout\Model\Quote\QuoteExtensionDataFactory; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
class BoldQuoteRepository implements BoldQuoteRepositoryInterface | ||
{ | ||
/** | ||
* @var QuoteExtensionDataResource | ||
*/ | ||
private $boldQuoteResource; | ||
|
||
/** | ||
* @var QuoteExtensionDataFactory | ||
*/ | ||
private $quoteExtensionDataFactory; | ||
|
||
public function __construct( | ||
QuoteExtensionDataResource $boldQuoteResource, | ||
QuoteExtensionDataFactory $quoteExtensionDataFactory, | ||
) { | ||
$this->boldQuoteResource = $boldQuoteResource; | ||
$this->quoteExtensionDataFactory = $quoteExtensionDataFactory; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getByCartId(int $cartId): BoldQuoteInterface | ||
{ | ||
$boldQuote = $this->quoteExtensionDataFactory->create(); | ||
$this->boldQuoteResource->load($boldQuote, $cartId, QuoteExtensionDataResource::QUOTE_ID); | ||
if ($boldQuote->getId() === null) { | ||
throw new NoSuchEntityException(__('No Bold Quote found for ID: %1.', $cartId)); | ||
} | ||
|
||
return $boldQuote; | ||
} | ||
} |
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
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