-
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.
- Loading branch information
1 parent
6c5cc10
commit 312cc1e
Showing
15 changed files
with
554 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
Block/Adminhtml/DeliveryDateAndTime/ExpectedDeliveryDateAndTime.php
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,15 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Block\Adminhtml\DeliveryDateAndTime; | ||
|
||
/** | ||
* Class ExpectedDeliveryDateAndTime | ||
* | ||
* @package Sourabh\DeliveryDateAndTime\Block\Adminhtml\DeliveryDateAndTime | ||
*/ | ||
class ExpectedDeliveryDateAndTime extends \Magento\Sales\Block\Adminhtml\Order\View\Info | ||
{ | ||
|
||
} |
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,55 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Controller\DeliveryDateAndTime; | ||
|
||
/** | ||
* Class Index | ||
* | ||
* @package Sourabh\DeliveryDateAndTime\Controller\DeliveryDateAndTime | ||
*/ | ||
class Index extends \Magento\Framework\App\Action\Action | ||
{ | ||
|
||
/** | ||
* | ||
* @var \Magento\Framework\App\Action\Context | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* | ||
* @var \Magento\Checkout\Model\Session | ||
*/ | ||
protected $checkoutSession; | ||
|
||
/** | ||
* | ||
* @var \Sourabh\DeliveryDateAndTime\Model\AddDeliveryDateAndTimeFactory | ||
*/ | ||
protected $addDeliveryDateAndTimeFactory; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Action\Context $context, | ||
\Magento\Checkout\Model\Session $checkoutSession, | ||
\Sourabh\DeliveryDateAndTime\Model\AddDeliveryDateAndTimeFactory $addDeliveryDateAndTimeFactory | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->checkoutSession = $checkoutSession; | ||
$this->addDeliveryDateAndTimeFactory = $addDeliveryDateAndTimeFactory; | ||
} | ||
public function execute() | ||
{ | ||
$deliverydateandtimeadd = $this->addDeliveryDateAndTimeFactory->create()->load($this->checkoutSession->getData('quote_id_1'),'quote_id'); | ||
if (empty($deliverydateandtimeadd->getData())) | ||
{ | ||
$deliverydateandtimeadd = $this->addDeliveryDateAndTimeFactory->create(); | ||
} | ||
$deliverydateandtimeadd->setQuoteId($this->checkoutSession->getData('quote_id_1')); | ||
$deliverydateandtimeadd->setDeliveryDateAndTime($this->_request->getParam('expdeliverydateandtime')); | ||
$deliverydateandtimeadd->save(); | ||
} | ||
|
||
} |
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,20 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Model; | ||
|
||
/** | ||
* Class AddDeliveryDateAndTime | ||
* | ||
* @package Sourabh\DeliveryDateAndTime\Model | ||
*/ | ||
class AddDeliveryDateAndTime extends \Magento\Framework\Model\AbstractModel | ||
{ | ||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
$this->_init('Sourabh\DeliveryDateAndTime\Model\ResourceModel\AddDeliveryDateAndTime'); | ||
} | ||
} | ||
?> |
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,33 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Model\ResourceModel; | ||
|
||
/** | ||
* Class AddDeliveryDateAndTime | ||
* | ||
* @package Sourabh\DeliveryDateAndTime\Model\ResourceModel | ||
*/ | ||
class AddDeliveryDateAndTime extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb | ||
{ | ||
|
||
/** | ||
* | ||
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context | ||
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface | ||
*/ | ||
public function __construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface | ||
) | ||
{ | ||
$this->scopeConfigInterface = $scopeConfigInterface; | ||
$this->resource = $context->getResources(); | ||
parent::__construct($context); | ||
} | ||
|
||
public function _construct() | ||
{ | ||
$this->_init('sourabh_delivery_date_and_time', 'id'); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Model\ResourceModel\AddDeliveryDateAndTime; | ||
|
||
/** | ||
* Class Collection | ||
* | ||
* @package Sourabh\DeliveryDateAndTime\Model\ResourceModel\AddDeliveryDateAndTime | ||
*/ | ||
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection | ||
{ | ||
protected function _construct() | ||
{ | ||
$this->_init('Sourabh\DeliveryDateAndTime\Model\AddDeliveryDateAndTime', 'Sourabh\DeliveryDateAndTime\Model\ResourceModel\AddDeliveryDateAndTime'); | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
namespace Sourabh\DeliveryDateAndTime\Setup; | ||
|
||
use Magento\Framework\Setup\InstallSchemaInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\SchemaSetupInterface; | ||
|
||
class InstallSchema implements InstallSchemaInterface | ||
{ | ||
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$installer = $setup; | ||
|
||
$installer->startSetup(); | ||
$table = $installer->getConnection() | ||
->newTable($installer->getTable('sourabh_delivery_date_and_time')) | ||
->addColumn( | ||
'id', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
null, | ||
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], | ||
'Id' | ||
) | ||
->addColumn( | ||
'quote_id', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
10, | ||
['nullable' => false], | ||
'quote_id' | ||
) | ||
->addColumn( | ||
'delivery_date_and_time', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], | ||
'Delivery Date And Time' | ||
); | ||
$installer->getConnection()->createTable($table); | ||
$installer->endSetup(); | ||
} | ||
} | ||
?> |
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,28 @@ | ||
{ | ||
"name": "sourabhcoder/deliverydateandtime", | ||
"description": "This is a Magento 2 Module for adding delivery date and time field to the Magento 2 checkout field in one page checkout, it is tested on the Magento 2 luma theme. ", | ||
"require": { | ||
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0" | ||
}, | ||
"type": "magento2-module", | ||
"version" : "1.0.0", | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Sourabhcoder", | ||
"email": "sourabhkumarsharma778@gmail.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Sourabh\\DeliveryDateAndTime\\": "" | ||
} | ||
} | ||
} |
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,8 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> | ||
<router id="standard"> | ||
<route id="soudeliverydateandtime" frontName="soudeliverydateandtime"> | ||
<module name="Sourabh_DeliveryDateAndTime" /> | ||
</route> | ||
</router> | ||
</config> |
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,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> | ||
<module name="Sourabh_DeliveryDateAndTime" setup_version="1.0.0" schema_version="1.0.0"> | ||
</module> | ||
</config> |
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,10 @@ | ||
<?php | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
|
||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'Sourabh_DeliveryDateAndTime', | ||
__DIR__ | ||
); |
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,13 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceBlock name="order_info"> | ||
<block class="Sourabh\DeliveryDateAndTime\Block\Adminhtml\DeliveryDateAndTime\ExpectedDeliveryDateAndTime" name="sou_deliver_date_and_time" template="Sourabh_DeliveryDateAndTime::deliverydateandtime/expected-delivery-date-and-time.phtml" ></block> | ||
</referenceBlock> | ||
</body> | ||
</page> |
4 changes: 4 additions & 0 deletions
4
view/adminhtml/templates/deliverydateandtime/expected-delivery-date-and-time.phtml
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,4 @@ | ||
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | ||
$devliveryDateAndTimeFactory = $objectManager->create('\Sourabh\DeliveryDateAndTime\Model\AddDeliveryDateAndTime')->load($this->getOrder()->getQuoteId(),'quote_id'); | ||
?> | ||
<p>Expected Delivery Date And Time:<?php echo $devliveryDateAndTimeFactory->getDeliveryDateAndTime(); ?></p> |
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,74 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © sourabhcoder. All rights reserved. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceBlock name="checkout.root"> | ||
<arguments> | ||
<argument name="jsLayout" xsi:type="array"> | ||
<item name="components" xsi:type="array"> | ||
<item name="checkout" xsi:type="array"> | ||
<item name="children" xsi:type="array"> | ||
<item name="steps" xsi:type="array"> | ||
<item name="children" xsi:type="array"> | ||
<item name="shipping-step" xsi:type="array"> | ||
<item name="children" xsi:type="array"> | ||
<item name="shippingAddress" xsi:type="array"> | ||
<item name="children" xsi:type="array"> | ||
<item name="shipping-address-fieldset" xsi:type="array"> <!-- before-shipping-method-form is used for positioning this custom form --> | ||
<item name="children" xsi:type="array"> | ||
<!-- Your form declaration here --> | ||
<item name="custom-checkout-form-container" xsi:type="array"> | ||
<item name="component" xsi:type="string">Sourabh_DeliveryDateAndTime/js/view/custom-checkout-form</item> | ||
<item name="provider" xsi:type="string">checkoutProvider</item> | ||
|
||
<item name="children" xsi:type="array"> | ||
<item name="custom-checkout-form-fieldset" xsi:type="array"> | ||
<!-- uiComponent is used as a wrapper for form fields (its template will render all children as a list) --> | ||
<item name="component" xsi:type="string">uiComponent</item> | ||
<!-- the following display area is used in template (see below) --> | ||
<item name="displayArea" xsi:type="string">custom-checkout-form-fields</item> | ||
<item name="children" xsi:type="array"> | ||
<item name="expected_delivery_date_time" xsi:type="array"> | ||
<item name="component" xsi:type="string">Sourabh_DeliveryDateAndTime/js/form/element/date</item> | ||
<item name="config" xsi:type="array"> | ||
<!--customScope is used to group elements within a single form (e.g. they can be validated separately)--> | ||
<item name="customScope" xsi:type="string">customCheckoutForm</item> | ||
<item name="template" xsi:type="string">ui/form/field</item> | ||
<item name="elementTmpl" xsi:type="string">ui/form/element/date</item> | ||
</item> | ||
<item name="provider" xsi:type="string">checkoutProvider</item> | ||
<item name="dataScope" xsi:type="string">customCheckoutForm.expected_delivery_date_time</item> | ||
<item name="label" xsi:type="string">Expected Delivery Date And Time.</item> | ||
<item name="validation" xsi:type="array"> | ||
<item name="required-entry" xsi:type="string">true</item> | ||
</item> | ||
<item name="options" xsi:type="array"> | ||
<item name="dateFormat" xsi:type="string">yyyy-MM-dd</item> | ||
<item name="timeFormat" xsi:type="string">HH:mm:ss</item> | ||
<item name="showsTime" xsi:type="boolean">true</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</item> | ||
</argument> | ||
</arguments> | ||
</referenceBlock> | ||
</body> | ||
</page> |
Oops, something went wrong.