|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / Amasty / CheckoutDeliveryDate / Model / |
Filename | /home/dev2.destoffenstraat.com/app/code/Amasty/CheckoutDeliveryDate/Model/DeliveryDateProvider.php |
Size | 1.83 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 23-Nov-2022 12:33 |
Last accessed | 23-Aug-2025 01:51 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package One Step Checkout Delivery Date for Magento 2 (System)
*/
namespace Amasty\CheckoutDeliveryDate\Model;
use Amasty\CheckoutDeliveryDate\Api\Data\DeliveryInterface;
use Amasty\CheckoutDeliveryDate\Model\ResourceModel\Delivery\Collection;
use Amasty\CheckoutDeliveryDate\Model\ResourceModel\Delivery\CollectionFactory;
use Magento\Quote\Api\Data\CartItemInterface;
use Magento\Sales\Api\Data\OrderItemInterface;
class DeliveryDateProvider
{
/**
* @var CollectionFactory
*/
private $deliveryCollectionFactory;
public function __construct(CollectionFactory $deliveryCollectionFactory)
{
$this->deliveryCollectionFactory = $deliveryCollectionFactory;
}
/**
* @param int $quoteId
* @return DeliveryInterface
*/
public function findByQuoteId(int $quoteId): DeliveryInterface
{
$delivery = $this->findByField($quoteId, CartItemInterface::KEY_QUOTE_ID);
if (!$delivery->getId()) {
$delivery->setData(CartItemInterface::KEY_QUOTE_ID, $quoteId);
}
return $delivery;
}
/**
* @param int $orderId
* @return DeliveryInterface
*/
public function findByOrderId(int $orderId): DeliveryInterface
{
return $this->findByField($orderId, OrderItemInterface::ORDER_ID);
}
/**
* @param int $value
* @param string $field
* @return DeliveryInterface
*/
public function findByField(int $value, string $field): DeliveryInterface
{
/** @var Collection $deliveryCollection */
$deliveryCollection = $this->deliveryCollectionFactory->create();
return $deliveryCollection
->addFieldToFilter($field, $value)
->getFirstItem();
}
}
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package One Step Checkout Delivery Date for Magento 2 (System)
*/
namespace Amasty\CheckoutDeliveryDate\Model;
use Amasty\CheckoutDeliveryDate\Api\Data\DeliveryInterface;
use Amasty\CheckoutDeliveryDate\Model\ResourceModel\Delivery\Collection;
use Amasty\CheckoutDeliveryDate\Model\ResourceModel\Delivery\CollectionFactory;
use Magento\Quote\Api\Data\CartItemInterface;
use Magento\Sales\Api\Data\OrderItemInterface;
class DeliveryDateProvider
{
/**
* @var CollectionFactory
*/
private $deliveryCollectionFactory;
public function __construct(CollectionFactory $deliveryCollectionFactory)
{
$this->deliveryCollectionFactory = $deliveryCollectionFactory;
}
/**
* @param int $quoteId
* @return DeliveryInterface
*/
public function findByQuoteId(int $quoteId): DeliveryInterface
{
$delivery = $this->findByField($quoteId, CartItemInterface::KEY_QUOTE_ID);
if (!$delivery->getId()) {
$delivery->setData(CartItemInterface::KEY_QUOTE_ID, $quoteId);
}
return $delivery;
}
/**
* @param int $orderId
* @return DeliveryInterface
*/
public function findByOrderId(int $orderId): DeliveryInterface
{
return $this->findByField($orderId, OrderItemInterface::ORDER_ID);
}
/**
* @param int $value
* @param string $field
* @return DeliveryInterface
*/
public function findByField(int $value, string $field): DeliveryInterface
{
/** @var Collection $deliveryCollection */
$deliveryCollection = $this->deliveryCollectionFactory->create();
return $deliveryCollection
->addFieldToFilter($field, $value)
->getFirstItem();
}
}