Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 7
How to add a “delivery date” field (one per shipment)
 
Brikou Carré
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-04
 

I’d like to let the customer add a delivery date (required) and a message field (and maybe a signature field) (one by product, or bettre one by shipment address (so multiple with multiple addresses))

How can I do this ??? I first thought about configurable products and specials attribute, but don’t feel like this is the answer

(Magento is great)

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

The message field should be added to Magento, hopefully by the end of the year. The delivery date sounds like something custom that will probably require some development on your side. Please follow the development process and watch out for documentations on customizing Magento.

Thanks

Yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brikou Carré
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-04
 

The message feature will be a great thing to add. For the “Shipping date” feature I’ll do it by myself, because I understand that this is a too specific task for my project but can you give me some clue to add this.

I already took a look a the implementation, I think I’ll add the “shipping date” like we have the “shipping method”. Thanks to the magic use of __call function setter and getter are natively recognized…

I’ve changed the “Multishipping checkout shipping template” in order to add a date input for each address.

here is the addition i’ve made in the template:

<!-- ... -->
<
label>Date <input type="text" name="shipping_date[<?=$_address->getId()?>]" /></label>
<!-- ... -->

inside the MultishippingController

public function shippingPostAction()
    
{
        $shippingMethods 
$this->getRequest()->getPost('shipping_method');
        
// i've added this....
        
$shippingDates $this->getRequest()->getPost('shipping_date');

        try 
{
            $this
->_getCheckout()->setShippingMethods($shippingMethods);
            
// and i've added also this....
            
$this->_getCheckout()->setShippingDates($shippingDates);

            
$this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING);
            
$this->_redirect('*/*/billing');
        
}
        
catch (Exception $e){
            Mage
::getSingleton('checkout/session')->addError($e->getMessage());
            
$this->_redirect('*/*/shipping');
        
}
    }

Here is my new function (inserted just after existing setShippingMethods function inside Multishipping model)

public function setShippingDates($dates)
    
{
        $addresses 
$this->getQuote()->getAllShippingAddresses();
        foreach (
$addresses as $address{
            
if (isset($dates[$address->getId()]) && !empty($dates[$address->getId()])) {
                $address
->setShippingDate($dates[$address->getId()]);
                
//die($address->getShippingDate()); // this works as expected... but when calling this inside the template it doesn't work
            
}
            
elseif (!$address->getShippingDate()) {
                Mage
::throwException(__('Please select shipping dates for all addresses'));
            
}
        }
        
// $addresses = $this->getQuote()->collectTotals()->save(); // not usefull because total price is not changed
        
return $this;
    
}

This seems (to me) to be correct but when calling $_address->getShippingDate() (inside the template), i get NULL value, can you give me a clue…

Cheer

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Nice smile

To save the information in tables you will need to add ‘shipping_date’ attribute to ‘quote_address’ entity.

Take a look in app/code/core/Mage/Sales/Model/Entity/Setup.php - here you have default set of attributes for sales module entities.

As a quick solution: update this file to have your attribute, then run once in one of your controllers this code:

$setup Mage::getModel('sales/entity_setup');
$setup->installEntities($setup->getDefaultEntities());
This will update your EAV configuration to have your attribute.
 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Oh, and you will need still to save the quote with addresses after you set the dates:

$this->getQuote()->save();
 
Magento Community Magento Community
Magento Community
Magento Community
 
Brikou Carré
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-04
 

Quicker solution

Moshe - 20 October 2007 01:54 PM

As a quick solution: update this file to have your attribute, then run once in one of your controllers this code:

$setup Mage::getModel('sales/entity_setup');
$setup->installEntities($setup->getDefaultEntities());
This will update your EAV configuration to have your attribute.

I found an even quicker solution… just open this page in my browser : http://localhost/magento/checkout/test/createEntities/ ... So what is my next step?… doing some validation of course!

Validation...Howto?

I’ll have to check that this date is given (because this is mandatory for my project) and of course this date should be in the future (i can add also check other things like that this date is not a sunday etc...)

I already checked that date is given in the setShippingDates($dates), (because it throw an exception if date is empty) but I’m not sure it’s the right place to do it. Maybe I should override the sefault setter (providen by __call magical) setShippingDate($date) and throw an exception if my validation fails.

What do you think of it?

Formating this date...(solved i think)

Another thing I’d like to know is about formating date in the shop depending of the L10N of the shop. Is there any helper to display the date in the right format (and of course convert from posting format to timestamp)? I’ve just found what i need in /magento/app/code/core/Mage/Core/Helper/Data.php

// in the template...
<?$this->formatDate($_address->getShippingDate(), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT?>

// getting the right formatting before saving it to the db...
$date Mage::app()->getLocale()->date($dates[$address->getId()]Zend_Date::DATE_SHORT);
$address->setShippingDate($date->toString('YYYY-MM-dd HH:mm:ss'));

Display shipping date in the backend...

Now that the shipping date is written in the db, i’d like to display it in the backend (and in the customer dashboard). I’ve found the template corresponding to /magento/admin/sales_order/view/order_id/7/ page, but I can’t achieve the display of this value… Furthermore in the list view I’d like to add a new input filter in order to sort orders by “shipping date”. But one thing at a time, let’s find a solution for the view…

// I tried... but NULL is given
<? var_dump($_order->getShippingDate()) ?>

I guess that this attribute (shipping date) is saved for the quote but not for the order, so I should take a look in “importQuoteAddressAttributes(Mage_Sales_Model_Quote_Address $address)” function i guess… or can I touch this attribute with the help of ‘quote_address_id’ attribute of the order…

Help me to light my way wink, do I forgot/misunderstood something ?

I think I’ve made it, I just needed to add the shipping_date to the order (or order_address?) entity (like you’ve told me for quote_adress)…

Thank again for your help, and let me know if you think I forgot something…

 
Magento Community Magento Community
Magento Community
Magento Community
 
AKS
Jr. Member
 
Total Posts:  4
Joined:  2007-11-19
 

Hi Brikou Carré ,

I am following your footsteps on programming a delivery date at checkout.  Basically ours is a flower shop and we want to capture a delivery date with order.

Were you successfully in implementing the entire piece i.e. date picker, storing into DB, validation, and backend display?

I am new to this product and having difficulties.  Can you share your final code snippets or files here?  This will be a great help.

Thanks,

AKS

 
Magento Community Magento Community
Magento Community
Magento Community
 
Allysin
Sr. Member
 
Avatar
Total Posts:  215
Joined:  2008-04-03
 

Does anyone have a working version of this?

Thanks wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
finch8243
Sr. Member
 
Total Posts:  79
Joined:  2007-08-31
 

I think a quick way may be to access the function that adds comments to orders.  You could add the delivery date as a comment and send an updated order receipt to the customer.  I know it’s a hack, but it may work.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

I’m looking into adding a date field everywhere the gift message lives.  There are quite a few files that need to be touched, but I’ll report back when I’ve got something or I’ve gone as far as I can.

Basically I’m doing a site wide search for anything that looks remotely related to gift message and duplicating it to make an “gift calendar”.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
Allysin
Sr. Member
 
Avatar
Total Posts:  215
Joined:  2008-04-03
 

Hi MunchyMonster!  tongue wink

How is it coming? That sounds very promising! wink The problem for me might be that I will need both - a gift card message and a delivery date....

I’m looking forward to reading about your progress! wink

Good luck and thanks from all of us excaim

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

Well it has been a couple of days.  This is a part time job for me (which means I can work as many hours as I want so long as it isn’t during my day job). 

I’ve been copying/converting everything with the barest mention of “gift message” in it to have an exact duplicate called calendar.  There are a ton of files and a good number of database tables that I’m going to need to touch.  I’m not even sure if this is going to work.  If it does, I’ll post as much about what I did as I can.  If it doesn’t, I’ll be here begging for advice.  Thanks for the well wishes.  Can’t wait to see if it does anything or if it just blows a gasket.  Even if it works, I’ll need to disentangle it from the standard code so I don’t lose it all when the next upgrade comes out.  Like I said I’ll check in every few days and post progress.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
MunchyMonster
Member
 
Avatar
Total Posts:  71
Joined:  2008-02-05
New Hampshire, USA
 

Well my first cut didn’t fare so well.  I took a few days off to regroup and tackled writing a shipping module.  With that successfully under my belt I’m going to have another crack at adding a “gift” calendar to the checkout.  I’ll keep you posted here in this thread.

MunchyMonster

 
Magento Community Magento Community
Magento Community
Magento Community
 
rvelton
Sr. Member
 
Total Posts:  82
Joined:  2007-09-07
 

What was the shipping module that you created?

Does it have anything to do with auto creating the shipping label? smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Allysin
Sr. Member
 
Avatar
Total Posts:  215
Joined:  2008-04-03
 

Hi wink

Any progress on a delivery calendar?  kiss  Anyone?  rolleyes

Or at least a drop down with dates or a fill in field?

Thanks - you rock!  kiss

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brikou Carré
Member
 
Avatar
Total Posts:  37
Joined:  2007-10-04
 
Moshe - 20 October 2007 01:54 PM

Nice smile

To save the information in tables you will need to add ‘shipping_date’ attribute to ‘quote_address’ entity.

Take a look in app/code/core/Mage/Sales/Model/Entity/Setup.php - here you have default set of attributes for sales module entities.

As a quick solution: update this file to have your attribute, then run once in one of your controllers this code:

$setup Mage::getModel('sales/entity_setup');
$setup->installEntities($setup->getDefaultEntities());
This will update your EAV configuration to have your attribute.

I’m trying to work again on this feature but with current Magento version, things seems to have changed, when I try to install entities with this solution, I get an error (or something unusual :( )

Notice: Array to string conversion  in /home/me/Zend/workspaces/DefaultWorkspace/MyShop/magento/app/code/core/Mage/Core/Model/Config.php on line 749

Can you help me, because things are getting so complicated right now :(

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 7