-
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.
Merge pull request #169 from bold-commerce/Q1-609
Fix update payment store id for shop id validation.
- Loading branch information
Showing
4 changed files
with
93 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Model\Quote\LoadAndValidate; | ||
|
||
use Bold\Checkout\Model\ResourceModel\Quote\GetStoreIdByCartId; | ||
|
||
/** | ||
* Resolve store id by cart id. | ||
*/ | ||
class StoreIdResolver | ||
{ | ||
/** | ||
* @var GetStoreIdByCartId | ||
*/ | ||
private $getStoreIdByCartId; | ||
|
||
/** | ||
* @param GetStoreIdByCartId $getStoreIdByCartId | ||
*/ | ||
public function __construct(GetStoreIdByCartId $getStoreIdByCartId) | ||
{ | ||
$this->getStoreIdByCartId = $getStoreIdByCartId; | ||
} | ||
|
||
/** | ||
* Get store id by cart id. | ||
* | ||
* @param int $cartId | ||
* @return int | ||
*/ | ||
public function resolve(int $cartId): int | ||
{ | ||
return $this->getStoreIdByCartId->getStoreId($cartId); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Model\ResourceModel\Quote; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
|
||
/** | ||
* Get store id by cart id resource model. | ||
*/ | ||
class GetStoreIdByCartId | ||
{ | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
/** | ||
* @param ResourceConnection $resourceConnection | ||
*/ | ||
public function __construct(ResourceConnection $resourceConnection) | ||
{ | ||
$this->resourceConnection = $resourceConnection; | ||
} | ||
|
||
/** | ||
* Retrieve store id by cart id. | ||
* | ||
* @param int $cartId | ||
* @return int | ||
*/ | ||
public function getStoreId(int $cartId): int | ||
{ | ||
$select = $this->resourceConnection->getConnection()->select()->from( | ||
$this->resourceConnection->getTableName('quote'), | ||
['store_id'] | ||
)->where('entity_id = (?)', $cartId); | ||
return (int)$this->resourceConnection->getConnection()->fetchOne($select); | ||
} | ||
} |