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

Add one checkbox in order confirmation
 
fuseuser
Jr. Member
 
Total Posts:  18
Joined:  2011-06-06
 

Hi all,

I need to change slightly the checkout form to add a checkbox in the order Order Confirmation block (see attached).
Then I need to know how to retrieve its value after the user clicks the final Place Order button.
All the tutorials about creating a payment module explain how to change the credit card form, but not the last confirmation block.

Any idea ?
Thank you in advance !

 
Magento Community Magento Community
Magento Community
Magento Community
 
webkul
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2010-10-27
 

i can’t see any attached doc/image ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
fuseuser
Jr. Member
 
Total Posts:  18
Joined:  2011-06-06
 

Woops sorry, just forgot it smile

Image Attachments
Screen shot 2011-06-27 at 12.54.20.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Try the following two steps:
1> add checkbox in agreements.phtml so that the new code looks like:

<?php //if (!$this->getAgreements()) return; ?>
<form action="" id="checkout-agreements" onsubmit="return false;">
<
ol class="checkout-agreements">
<?php foreach ($this->getAgreements() as $_a): ?>
    
<li>
        <
div class="agreement-content"<?php echo ($_a->getContentHeight() ? ' style="height:' $_a->getContentHeight() . '"' '')?>>
            
<?php if ($_a->getIsHtml()):?>
                <?php 
echo $_a->getContent() ?>
            <?php 
else:?>
                <?php 
echo nl2br($this->htmlEscape($_a->getContent())) ?>
            <?php 
endif; ?>
        
</div>
        <
class="agree">
            <
input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->htmlEscape($_a->getCheckboxText()) ?>" class="checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $this->htmlEscape($_a->getCheckboxText()) ?></label>
        </
p>
    </
li>
<?php endforeach ?>
</ol>
    <
ol>
        <
class="agree">
            <
input type="checkbox" id="extra_checkbox" name="extra_checkbox" value="1" title="" class="checkbox" /><label for="extra_checkbox">Extra Checkbox</label>
        </
p>
    </
ol>
</
form>
2>add following code in Mage_Checkout_OnepageController::saveOrderAction() as:
public function saveOrderAction()
{
    
if ($this->_expireAjax()) {
        
return;
    
}

    $result 
= array();
    try 
{
        
if($this->getRequest()->getPost('extra_checkbox'false)){
            $result[
'success'false;
            
$result['error'true;
            
$result['error_messages'$this->__('Please check extra checkbox before placing the order.');
            
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
            return;
        
}
//rest code continues...

Hope this helps you.
Let me know.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
fuseuser
Jr. Member
 
Total Posts:  18
Joined:  2011-06-06
 

Hi MagePsycho,

Thanks a lot for your answer.
The first step is working, that\’s great, but php side, what I\’d like to do is get this value to save it. Not returning an error if not checked.
Can I do something like:

Mage_Checkout_OnepageController::saveOrderAction()

$extraChecked $this->getRequest()->getPost(\'extra_checkbox\'true);
$this->getOnepage()->getOrder()->setValue(\'extra_checkbox\'$extraChecked)

And then in my payment Model, do something like

$extraChecked $payment->getOrder()->getValue(\'extra_checkbox\')

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

I think if you have created new field for extra checkbox in ‘sales_flat_order’ table then you can set the field and system will auto save the field in the table.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
fuseuser
Jr. Member
 
Total Posts:  18
Joined:  2011-06-06
 

Hi,

Basically, I haven’t changed the table, as this field is only used in my payment gateway module.
So do not need to save it (sorry if I haven’t been clear).

I have tried :

$this->getOnepage()->getQuote()->setData("custom""foo");

But I can’t retrieve the data in the model.

Am I forced to create a new field in the order table to achieve this ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Or you can save the data in session and fetch data from another model or controller. But this will be effective only for that session.
Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
fuseuser
Jr. Member
 
Total Posts:  18
Joined:  2011-06-06
 

I’ve tried using sessions, but it was’nt working properly. Sometimes picking the right value, sometimes not.
I ended up using hte POST variable inside my Model, which was luckily accessible.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top