Hello, Magento Fans,

Last time we learned how you can show the list of all categories at the sidebar for Magento 2.

Today we are going to learn about how you can remove the item from the cart automatically after 30 minutes.

In the rising world of Ecommerce, the work of developers is to make things fast, smart, and easy with their coding knowledge. As developers, we are destined to play around with numerous codes and numbers to save time and efforts of our clients and end-users. To stay ahead in the game, Ecommerce store owners have become demanding and want to add tons of new features and functions to their store.

While doing one project, we came across the requirement of the client to remove the cart item automatically after 30 Minutes. As a developer, we regularly come across such situations, so we thought of penning it down on our blog page.

Using the below codes, you can remove cart items automatically after 30minutes.

Step 1: First, we need to create a “Registration.php” file inside our extension at the following path..
app\code\Vendor\Extension

Step 2: After that, we need to create a “Module.xml” file inside extension etc folder. app\code\Vendor\Extension\etc

Step 3: After that, we need to create “crontab.xml” file inside extension etc folder. app\code\Vendor\Extension\etc

Step 4: Lastly, Create the “Removecart.php” file inside the Cron folder of extension. app\code\Vendor\Extension\Cron

If you have to execute this code on your site, then execute all codes in your root command. If you have executed all codes successfully, then run the below command in your command prompt.

php bin/magento cron:install

php bin/magento cron:run

Every 30 minutes, the cron is executed. If there is an item available in the cart, it will be then removed Automatically.

So, that was all for the day! With the help of these codes, you can successfully achieve the task of removing cart items automatically after every 30 minutes in Magneto 2. You are free to play around and customize these codes according to your needs of fetching data. If you face any issues while implementing, then contact our support team. We will be happy to help you.

Lastly, if you found this helpful, then let us know in the comments below. Also, don’t forget to share this with your Magento partners.

Click to rate this post!
[Total: 4 Average: 4.5]