Let’s initiate a discussion!!
Step 1: First you need to add registration.php file in the following path: app/code/Magemonkey/Orderstatus/
Add below code in it.
1 2 3 4 5 6 |
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Magemonkey_Orderstatus', __DIR__ ); |
Step 2: Next, you need to add module.xml file in the following path:
app/code/Magemonkey/Orderstatus/etc/
Add below code in it.
1 2 3 4 5 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Magemonkey_Orderstatus" setup_version="1.0.0"> </module> </config> |
Step 3: Now you need to add Orderstatus.php file in the following path: app/code/Magemonkey/Orderstatus/Cron/
Add below code in it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
<?php namespace Magemonkey\Orderstatus\Cron; class Orderstatus { protected $_logger; protected $_orderCollectionFactory; protected $orderObj; protected $timezoneInterface; public function __construct( \Psr\Log\LoggerInterface $logger, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, \Magento\Sales\Model\Order $orderObj, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezoneInterface ) { $this->_logger = $logger; $this->_orderCollectionFactory = $orderCollectionFactory; $this->_orderObj = $orderObj; $this->_timezoneInterface = $timezoneInterface; } public function execute() { $paymentMethod = 'stripe_payments_sofort'; /* get order collection */ $collection = $this->_orderCollectionFactory->create()->addFieldToSelect('*') ->addFieldToFilter('status', ['in' => 'pending']); /* join with payment table */ $collection->getSelect() ->join( ["sop" => "sales_order_payment"], 'main_table.entity_id = sop.parent_id', array('method') ) ->where('sop.method = ?',$paymentMethod); /* get current date time */ $current_datetime = $this->_timezoneInterface->date()->format('Y-m-d H:i:s'); /* set default time in second */ $set_default_time = 3600; foreach ($collection->getData() as $key => $orders) { $created_at = $orders['created_at']; $dateTimeZone_order = $this->_timezoneInterface->date(new \DateTime($created_at))->format('Y-m-d H:i:s'); /* get time diff from order datetime and current datetime */ $time_diff = strtotime($current_datetime) - strtotime($dateTimeZone_order); /* change order status to processing */ if($set_default_time <= $time_diff){ /* @var $order \Magento\Sales\Model\Order */ $order = $this->_orderObj->load($orders['entity_id']); $order->setStatus("processing"); $order->save(); } } } } |
[crayon-641fadc376993981859913/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.