How to display estimated delivery date in product page when the user selects country and zip code ?
-
When I have such a requirement with one of our client, we agreed to use a paid module store.plumrocket.com/…– Kumar A.Commented May 23, 2017 at 10:12
-
but i want to apply in my module...programmatically..– user52726Commented May 23, 2017 at 12:51
-
you can check this magento 2 estimated delivery date module and test demo hopefully it solve– nikunjCommented Jun 2, 2021 at 11:04
5 Answers
Update this code :
app/code/[NameSpace]/[ModuleName]/view/frontend/layout/catalog_product_view.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="alert.urls">
<block class="Magento\Catalog\Block\Product\View" name="product.info.[ModuleName]" as="[ModuleName]"
after="-" template="[NameSpace]_[ModuleName]::product/view/temp.phtml"/>
</referenceContainer>
</body>
app/code/[NameSpace]/[ModuleName]/view/frontend/templates/product/view/temp.phtml
<?php
$product = $this->getProduct()
?>
<div>Estimated Delivery Date</div>
<div><?php // your code ?></div>
<div>Estimated Shipping Date</div>
<div><?php // your code ?></div>
You can add block and .phtml in product view page and add your code as you want
Create catalog_product_view.xml in app/code/[NameSpace]/[ModuleName]/view/frontend/layout/
<?xml version="1.0"?>
<body>
<referenceContainer name="alert.urls">
<block class="Magento\Catalog\Block\Product\View" name="product.info.[ModuleName]" as="[ModuleName]"
after="-" template="[NameSpace]_[ModuleName]::product/view/[fileName].phtml"/>
</referenceContainer>
</body>
Create [fileName].phtml in app/code/[NameSpace]/[ModuleName]/view/frontend/templates/product/view
<?php
$product = $this->getProduct()
?>
<div>Estimated Delivery Date</div>
<div><?php // Your code ?></div>
<div>Estimated Shipping Date</div>
<div><?php // Your code ?></div>
Here you can add you logic to get Delivery and Shipping date and display according to Product
-
i'll try this way thank You :) Manoj Mondal– user52726Commented May 24, 2017 at 6:09
Crate xml file on this path :
app/code/[NameSpace]/[ModuleName]/view/frontend/layout/catalog_product_view.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="alert.urls">
<block class="Magento\Catalog\Block\Product\View" name="product.info.[ModuleName]" as="[ModuleName]"
after="-" template="[NameSpace]_[ModuleName]::product/view/temp.phtml"/>
</referenceContainer>
</body>
app/code/[NameSpace]/[ModuleName]/view/frontend/templates/product/view/temp.phtml
<?php
$product = $this->getProduct()
?>
<div>Estimated Delivery Date</div>
<div><?php // add your date function ?></div>
<div>Estimated Shipping Date</div>
<div><?php // add your date function ?></div>
In Magento 2.3 you can add following code in /public_html/vendor/magento/module-catalog/view/frontend/templates/product/view/form.phtml
<?php
$product = $this->getProduct()
?>
<div>Estimated Delivery Date</div>
<div><?php // Your code ?></div>
<div>Estimated Shipping Date</div>
<div><?php // Your code ?></div>
Here you can add you logic to get Delivery and Shipping date and display according to Product.
I DONT KNOW HOW TO CALL TODAY'S DATE IN MAGENTO THOUGH.
Magento 2.4 UPDATE:
app/code/[NameSpace]/[ModuleName]/view/frontend/layout/catalog_product_view.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="alert.urls">
<block class="Magento\Catalog\Block\Product\View" name="product.info.[ModuleName]" as="[ModuleName]"
after="-" template="[NameSpace]_[ModuleName]::product/view/temp.phtml"/>
</referenceContainer>
</body>
app/code/[NameSpace]/[ModuleName]/view/frontend/templates/product/view/temp.phtml
<?php
$product = $this->getProduct()
?>
<div>Estimated Delivery Date</div>
<div><?php // add your date function ?></div>
<div>Estimated Shipping Date</div>
<div><?php // add your date function ?></div>