1

How to display estimated delivery date in product page when the user selects country and zip code ?

3
  • 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..
    – user52726
    Commented May 23, 2017 at 12:51
  • you can check this magento 2 estimated delivery date module and test demo hopefully it solve
    – nikunj
    Commented Jun 2, 2021 at 11:04

5 Answers 5

0

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>
2

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

1
  • i'll try this way thank You :) Manoj Mondal
    – user52726
    Commented May 24, 2017 at 6:09
0

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>
0

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.

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.