1
votes

I've been searching, trying, and failing alot here. What I want is to add a checkbox, on the Shipping page of Onepage checkout, the standard magento checkout.

I want to create a checkbox so that customers can check it if they want their products to be placed on their address without a signature.

I've been messing around with some old "Accept Terms" checkboxes, but with no luck.

I'm hoping that somebody might have had to make the same kind of customization.

1

1 Answers

4
votes

What you can do is save the preference in the checkout/session via an observer. First, add the checkbox to the shipping section and give it the property of name=shipping[no_signature]. Then, create a new module and hook into the event controller_action_postdispatch_checkout_onepage_saveShipping and then use this code:

public function controller_action_postdispatch_checkout_onepage_saveShipping($observer)
{
    $params = (Mage::app()->getRequest()->getParams()) ? Mage::app()->getRequest()->getParams() : array();
    if (isset($params['shipping']['no_signature']) && $params['shipping']['no_signature']) {
        Mage::getSingleton('checkout/session')->setNoSignature(true);
    } else {
        Mage::getSingleton('checkout/session')->setNoSignature(false);
    }

    return $this;
}

Then, when the order is about to be placed, hook into the event sales_order_place_before you can add a comment to the order like this:

public function sales_order_place_before($observer)
{
    $order = $observer->getOrder();
    if (Mage::getSingleton('checkout/session')->getNoSignature()) {
        $order->setCustomerNote('No signature required.');
    } else {
        $order->setCustomerNote(null);
    }

    return $this;
}

When you go to Sales > Orders, you should see a comment on the order regarding if the customer requires a signature or not. This is under the assumption that no other module or custom code is injecting anything into the customer_note field on the order object.