Arrange the payment options in checkout - php

I am trying to edit the layout of payment options in magento that are in the
path:- **/template/checkout/onepage/payment/methods.phtml
<dl class="sp-methods" id="checkout-payment-method-load">
<?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode(); ?>
<dt class="p_method">
<?php if( sizeof($this->getMethods()) > 1 ): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->getMethodTitle($_method) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
How could I change the order from the getMethods() array ?

You can set the order of payment methods from admin directly where every payment method has a order field that you can set
system > configuration > sales > payment methos

Related

Grouped Product won't be added to cart and there is a message "Please specify the quantity of product(s)."

I am developing a store and the product I tried to add is a grouped product which I had done some design and configuration on the front end. Then, I added sample grouped product and when I click "Add to cart" , there is message "Please specify the quantity of product(s)."
Please see the website (Sorry the website is in Thai but you can try to increase the Quantity of each product and then click add to cart - Pink button)
http://www.preciosathailand.com/eyeline-0001.html
This is PHP code that I made the configuration
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
<tr>
<td width="80%"><span class="product-<?php echo $_item->getId() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></span></td>
<?php if ($this->getCanShowProductPrice($_product)): ?>
<td class="a-right">
<?php if ($this->getCanShowProductPrice($_item)): ?>
<?php echo $this->getPriceHtml($_item, true) ?>
<?php echo $this->getTierPriceHtml($_item) ?>
<?php endif; ?>
</td>
<?php endif; ?>
<?php if ($_product->isSaleable()): ?>
<td class="a-center" width="20%">
<?php if ($_item->isSaleable()) : ?>
<div class="qty-tools">
<div class="minus-qty minus-<?php echo $_item->getId() ?>"><a class="click-to-minus" id="minus-<?php echo $_item->getId() ?>" href="#" data-id-p="<?php echo $_item->getId() ?>">-</a></div>
<div class="input-qty-wrapper">
<input type="text" name="super_group[<?php echo $_item->getId() ?>]" data-qty-product-id="<?php echo $_item->getId() ?>" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" />
</div>
<div class="plus-qty plus-<?php echo $_item->getId() ?>"><a class="click-to-plus" href="#" id="plus-<?php echo $_item->getId() ?>" data-id-p="<?php echo $_item->getId() ?>">+</a></div>
</div>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
</tr>
<?php endif; ?>
This is jQuery that I have done.
jQuery(document).ready(function(){
jQuery('.click-to-minus').click(function(){
var IDInput = jQuery(this).data('id-p');
var CurrentVal = jQuery('input[name="super_group['+IDInput+']"]').val();
var minusedVal = CurrentVal-1;
jQuery('input#'+IDInput).val(minusedVal);
});
jQuery('.click-to-plus').click(function(){
var pIDInput = jQuery(this).data('id-p');
var CurrentPlusVal = jQuery('input[name="super_group['+pIDInput+']"]').val();
/* if ( CountPlus == 0){
var plusedVal = 1;
}else{
jQuery('input#'+pIDInput).val('');
var plusedVal = CurrentPlusVal+1;
}*/
var plusedVal = +CurrentPlusVal+1;
jQuery('input[data-qty-product-id="'+pIDInput+'"]').val(plusedVal);
});
});
Did I do anything wrong?
Are you trying to group configurable products, then you should know that magento doesnt allow it.
you can check this answer here

How to use plugin functions inside of child theme template

So,
I've been trying to make a template, which runs plugin functions.
Here is template I've tried to make.
And here are the errors I get
Warning: Invalid argument supplied for foreach() in C:\www\htdocs\FCN-GIT\wp-content\themes\Avada-Child-Theme\single-wpt_test.php on line 39
Fatal error: Call to undefined method WP::doAction() in C:\www\htdocs\FCN-GIT\wp-content\themes\Avada-Child-Theme\single-wpt_test.php on line 44
<?php
/**
* Template Name: Test
*
* #package WordPress
* #subpackage Avada
* #since 2016
*/
?>
<?php
// Can be overriden in your theme as entry-content-wpt-test-fill-form.php
/* #var $answerIdName string */
/* #var $answerIndex integer */
/* #var $isShowContent boolean */
/* #var $formAttributes array */
/* #var $content string */
/* #var $subTitle string */
/* #var $shortDescription string */
/* #var $test WpTesting_Model_Test */
/* #var $questions WpTesting_Model_Question[] */
/* #var $isFinal boolean */
/* #var $isMultipleAnswers boolean */
/* #var $submitButtonCaption string */
/* #var $stepsCounter string */
/* #var $wp WpTesting_WordPressFacade */
/* #var $hiddens array */
?>
<div class="wpt_test fill_form">
<?php if ($isShowContent): ?>
<div class="content">
<?php echo $content ?>
</div>
<?php endif ?>
<div class="content"><form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach ?>>
<?php if ($subTitle): ?><h2 class="subtitle"><?php echo $subTitle ?></h2><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="question">
<div class="title">
<span class="number"><?php echo $q+1 ?>.</span><span class="title"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<label for="<?php echo $answerId ?>">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
<?php echo $answer->getTitleOnce() ?>
</label>
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form></div>
</div>
I managed to fix this, but overriding the default template of the plugin, I needed to have two templates which differences in one, so essentially, a template which has code for my homepage and for another page.
The homepage has the changes, and the other page does not, and it uses the default theme template.
Here was my solution to having two templates in one using the plugin code.
<?php
// Can be overriden in your theme as entry-content-wpt-test-fill-form.php
/* #var $answerIdName string */
/* #var $answerIndex integer */
/* #var $isShowContent boolean */
/* #var $formAttributes array */
/* #var $content string */
/* #var $subTitle string */
/* #var $shortDescription string */
/* #var $test WpTesting_Model_Test */
/* #var $questions WpTesting_Model_Question[] */
/* #var $isFinal boolean */
/* #var $isMultipleAnswers boolean */
/* #var $submitButtonCaption string */
/* #var $stepsCounter string */
/* #var $wp WpTesting_WordPressFacade */
/* #var $hiddens array */
?>
<?php if (is_front_page()): ?>
<div class="home-health-insight wpt_test fill_form">
<div class="answers">
<div class="content">
<form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach; ?>>
<?php if ($isShowContent): ?><div class="content" style="margin:0;"><?php echo $content ?></div><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<div class="question">
<div class="question-titles">
<div class="question-labels">
<label class="answerlbl" for="<?php echo $answerId ?>">
None of the time
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Rarely
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Some of the time
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Often
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
All of the time
</label>
</div>
</div>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="title">
<span class="question-title" style="width:100%;"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<div class="answer-block">
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form>
</div>
</div>
</div>
<?php else: ?>
<div class="wpt_test fill_form">
<?php if ($isShowContent): ?>
<div class="content">
<?php echo $content ?>
</div>
<?php endif ?>
<div class="content"><form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach ?>>
<?php if ($subTitle): ?><h2 class="subtitle"><?php echo $subTitle ?></h2><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="question">
<div class="title">
<span class="number"><?php echo $q+1 ?>.</span><span class="title"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<label for="<?php echo $answerId ?>">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
<?php echo $answer->getTitleOnce() ?>
</label>
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form></div>
</div>
<?php endif ?>

Disable Cash on Delivery for specific products

I am running Magento v1.9.0.1. I want to disable Cash on Delivery for specific products. I have installed COD extension from magento commerce.
I am new to Magento structure and no nothing to little about it. Tried some debugging on it but it is going up above my head.
Also, I have search every where over the internet but no one has ever provided the code for Magento v1.9.0.1.
Create a custom attribute with attribute code as cod and assign it to General of attribute sets.
Now as per you requirement change your methods.phtml (if there is no custom code included in this) as follows.
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<dt>
<?php
//cod verification starts
$attr_cod = array();
$cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach ($cartItems as $item) {
$attr_cod[] = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getCod();
}
if(in_array('1', $attr_cod) && $_code == 'cashondelivery') {continue; }
//cod verification ends
?>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
I have tested this and works fine.
COD is already in magento you didn't need to install it.
There are two way
create a new config setting in which you can enter ids of products
for which you didn't want COD option.
You can create product attribute too for checking COD option.
and check these ids (if you create config settings ) with the
product id or check for the product attribute on
app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml.
And by simple if else conditions you can avoid COD option for these
products.

PHP/CSS & Alignment of Columns

I started learning PHP/CSS/HTML5 & Java a month ago and I'm currently setting up an online shop for my new home business. I'm using opencart, but i'm having difficulty with transforming some of the PHP in terms of getting it to display side by side.
This is how I would like it to look.
Price: $000.00000
<table width="200" border="0">
<tr>
<td>Option 1</td>
<td>Option 2</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
</tr>
</table>
I've figured out how to do this in CSS, but the required radio radio buttons (see the code below) is the same code for option 1 & 2.
It currently looks like this
Price $000.0000
Option 1
1
2
3
Option 2
1
2
3
<?php if ($price) { ?>
<div class="price">
<span class="text-price"><?php echo $text_price; ?></span>
<?php if (!$special) { ?>
<span class="price-new"><?php echo $price; ?> <span style="font-size:10px;">pp</span></span>
<?php } else { ?>
<span class="price-new"><?php echo $special; ?></span><span class="price-old"><?php echo $price; ?></span>
<?php } ?>
<?php if ($tax) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span>
<?php } ?>
<?php if ($points) { ?>
<span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span>
<?php } ?>
<?php if ($discounts) { ?>
<div class="discount">
<?php foreach ($discounts as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php if ($profiles): ?>
<div class="option">
<h2><span class="required">*</span><?php echo $text_payment_profile ?></h2>
<br />
<select name="profile_id">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($profiles as $profile): ?>
<option value="<?php echo $profile['profile_id'] ?>"><?php echo $profile['name'] ?></option>
<?php endforeach; ?>
</select>
<br />
<br />
<span id="profile-description"></span>
<br />
<br />
</div>
<?php endif; ?>
<?php if ($options) { ?>
<div class="options">
<h2><?php echo $text_option; ?></h2>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'select') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<label><?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b></label>
<select name="option[<?php echo $option['product_option_id']; ?>]">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</option>
<?php } ?>
</select>
</div>
<?php } ?>
<?php if ($option['type'] == 'radio') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<label>
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b></label>
<?php foreach ($option['option_value'] as $option_value) { ?>
<label class="radio" for="option-value-<?php echo $option_value['product_option_value_id']; ?>">
<input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" /><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</label>
<?php } ?>
Why don't you display your table dynamically and then simply style it in CSS using nth-child(#)? You can simply loop through an array and display echo each row before closing out the table after.

select option in payment method instead of radion button in magento

This is my methods.phtml file in onepagecheckout in magento,I want the dropdown(select option) button instead of radio button .........so that i could select the payment method to pay the payment.
<?php if (!$methods = $this->getMethods()) : ?>
<p><?php echo $this->helper('checkout')->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else : ?>
<dl class="sp-methods">
<?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode() ?>
<dt>
<?php if( sizeof($this->getMethods()) > 1 ): ?>
<input value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /> </span>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->htmlEscape($_method->getTitle()) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
//]]>
</script>
<?php endif; ?>
You can do the select option dropdown for payment method as setup below code in methods.phtml file.
Also you have to changes in opcheckout.js line no 715 to change "elements[i].checked" to "elements[i].value".
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
?>
<dt>Select Payment Method:</dt>
<select name="payment[method]" onchange="payment.switchMethod(this.value);">
<?php
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<option id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" <?php if($this->getSelectedMethodCode()==$_code): ?> selected="selected"<?php endif; ?>>
<?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?>
</option>
<?php endforeach; ?>
</select>
<?php
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd id="dd_method_<?php echo $_code ?>">
<?php echo $html; ?>
</dd>
<?php endif;
endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
I used this one to get my select list if helpful
<?php
$ptId1=mysql_query(" some query here")
echo"<select name=ptId>";
while($ptId=mysql_fetch_array($ptId1))
{
echo '<option value="'.$ptId['id'].'">'.$ptId['id'].'</option>';
}
echo '</select>';?>
}

Categories