You can add Pre Order backorder label option using Magento 2. Native Magento supports three backorders options status.
You can see available backorders from the admin panel, Product page -> Click on Advanced Inventory Link, Open new Modal box with backorders dropdown.
If you want to customize the backorders dropdown with a new option called Pre Order, You need to create a plugin to add new options in Backorders Option.
Full Path: app/code/Jesadiya/Preorder/etc/di.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\CatalogInventory\Model\Source\Backorders"> <plugin name="Jesadiya_Preorder::addOptionArray" type="Jesadiya\Preorder\Plugin\PreOrderOption" /> </type> </config>
Full Path: app/code/Jesadiya/Preorder/Plugin/PreOrderOption.php
<?php namespace Jesadiya\Preorder\Plugin; use Magento\CatalogInventory\Model\Source\Backorders; class PreOrderOption { /** * add new preorder options * * @return array */ public function afterToOptionArray( Backorders $subject, array $options ) { $options[] = [ 'value' => 50, 'label'=> __('Allow Pre Orders') ]; return $options; } }
We have added New Pre Order Option with Value id is 50 and Label is Allow Pre Orders. You can keep any id and label as per your choice.
Backorders Options coming from the Magento\CatalogInventory\Model\Source\Backorders file.
Backorders.php contains the value-label pair to display backorder options and we have modified the result array of the file and add our new options using after Plugin.
Using the code snippet, You can add Options to Backorders dropdown field Magento 2 admin panel. Pre Order Option is available on the Product Page with Inventory Modal Form.