How to change the label of add to cart to pre order on all magento 2.4.5 based on the below conditions:
if(qty<0 , product is salable and getBackorders()/true ) to show pre order else add to cart.
Please suggest a way to implement this.
catalog_category_view.xml into your custom extension at following path.app\code\Vendor\Extension\view\frontend\layout\catalog_category_view.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="category.products.list"> <action method="setTemplate"> <argument name="template" xsi:type="string">Vendor_Extension::catalog/product/list.phtml</argument> </action> </referenceBlock> </body> </page> vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
to
app\code\Vendor\Extension\view\frontend\templates\catalog\product\list.phtml
Add To Cart Button according to your requirements.