1

I am using the code below to get the delivery date for trusted store badge

 <span id="gts-o-est-delivery-date"><?php echo $deliveryDate=Date('Y-m-d', strtotime("+7 days")); ?></span>

I need to replace the static number 7 with this code

 <?php 
    $order_items = $order->getAllItems();
    $maxDelivery = 0;
    foreach($order_items as $item) {
        $product = Mage::getModel('catalog/product')->load($item->getProductId());

        if ($product->getAttributeText('estdelivery') > $maxDelivery) { 
            $maxDelivery = $product->getAttributeText('estdelivery');
        }

    }
    echo $maxDelivery;
?>

what would the merged code be

1 Answer 1

0

Well I reckon you can just do:

 <?php 
    $order_items = $order->getAllItems();
    $maxDelivery = 0;
    foreach($order_items as $item) {
        $product = Mage::getModel('catalog/product')->load($item->getProductId());

        if ($product->getAttributeText('estdelivery') > $maxDelivery) { 
            $maxDelivery = $product->getAttributeText('estdelivery');
        }

    }
?>

 <span id="gts-o-est-delivery-date"><?php echo $deliveryDate=Date('Y-m-d', strtotime("+" . $maxDelivery . " days")); ?></span>
2
  • Thanks that worked perfectly and that would help alot of magento owners who are trying to setup their google trusted store badge, i tried a couple extensions and all failed. The first bit of coding would be great for someone whoo does need a per items delivery date, in our case some of our items take longer than others to arrive and are shipped seperately, thanks saved me from banging my head on the desk about it magento is a finicky one :) Commented Jun 1, 2016 at 1:25
  • now we are running into a issue somehow we need to be able to do a adjustment for states like hawaii alaska puerto rico to have a higher delivery date as well as foreign countries due to time going through customs Commented Sep 30, 2016 at 19:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.