I am new to Magento2.
I have created a new shipment method programmatically and name it "Same Day Delivery". Also, I have created a product attribute programmatically and name it "Same Day Delivery Available: (Yes/No).
I would like to add the restriction on the Checkout page - If all items in cart have (Same Day Delivery Available as Yes). Then display the new shipment option or hide them in the shipment selection section.
Here is my source code: https://github.com/balajimrv/app
In the method
Balaji\CustomShipping\Model\Carrier\Customshipping::collectRatesadd after the enabled verificationthis code that checks if same day delivery is available
you also need to tell magento to load your attribute when loading partial product data in checkout. For this create the file
etc/catalog_attributes.xmlwith this content