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>';?>
}
Related
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.
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.
I am using onestepcheckout in Magento. I have added in some extra flat rates and I am using two of them. I want to be able to only show one of the flat rates depending on the subtotal of the cart.
I have got the subtotal into a variable but the code has a foreach through each shipping method available so I need a way to say if $total is over 500 only show the second shipping method, if the total is under 500 only show the first shipping method.
<?php $total = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(); ?>
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<dd><?php echo $this->getCarrierName($code) ?></dd>
<?php foreach ($_rates as $_rate): ?>
<dt style="margin-bottom: 5px;">
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
<?php else: ?>
<input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
<label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
<strong>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</strong>
</label>
<?php endif ?>
</dt>
<?php endforeach; ?>
<?php endforeach; ?>
Just do ...
//first method here by default
if($total>500){
//second method here
}
Something tells me you already know how to do this though
I can't decipher, what the first and second method are in your code, otherwise I would've posted a more complete code
I have overriden the following core template in checkout process shipping section.
app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
I have two shipping methods. First one is 'Deliveryrate'. In this module I have overriden the above template file. Second shipping module is 'Store-Pickup'. But when I load the 'Store-Pickup' always loading the Deliveryrate'. I couldn't find the error. Please any suggestions?
following is the edited template file.
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
<dl class="sp-methods">
<?php $shippingCodePrice = array(); ?>
<?php $_sole = count($_shippingRateGroups) == 1;
foreach ($_shippingRateGroups as $code => $_rates): ?>
<?php
$helper = Mage::helper('deliveryrate');
$isFlorist = $helper->IsCollectFromFlorist();
if(!$isFlorist)
{
?>
<?php if($code == 'deliveryrate') // If the shipping method is deliveryshipping
{?>
<?php
// Get deliveryrate option details.
$all_options = Mage::getModel('deliveryrate/alloptions')->getCollection();
?>
<dt><?php echo $this->getCarrierName($code) ?></dt> <?php //header ?>
<dd>
<ul>
<table id="tbl-delivery-shipping">
<tbody>
<tr>
<td><label for="delivery-options" class="required" style="float:right;"><em>*</em>Delivery Time :</label></td>
<td>Option 1 - Standard Delivery
</tr>
<tr>
<td></td>
<td>
<?php $_sole = $_sole && count($_rates) == 1;
foreach ($_rates as $_rate): ?>
<?php
$option = $_rate->getCode();
$optionArray = explode( '_', $option );
$array_last_index = count($optionArray)-1;
$delivery_option = $optionArray[$array_last_index-1];
if($delivery_option == 1)
{
?>
<li>
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages">
<li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li>
</ul>
<?php else: ?>
<?php if ($_sole) : ?>
<span class="no-display">
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
</span>
<?php else: ?>
<?php // radio button ?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
<script type="text/javascript">
//<![CDATA[
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<?php // option name ?>
<label for="s_method_<?php echo $_rate->getCode() ?>">
<?php $option_name = $_rate->getMethodTitle();
$optionNameArray = explode( '(', $option_name );
if(count($optionNameArray)>1)
{
echo $optionNameArray[0];
?>
<br>
<?php
echo '('.$optionNameArray[1];
}
else
{
echo $optionNameArray[0];
}
?>
<?php // echo $_rate->getMethodTitle() ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php // echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php
$carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
if($carrier->getFormBlock()){
$block = $this->getLayout()->createBlock($carrier->getFormBlock());
$block->setMethodCode($code);
$block->setRate($_rate);
$block->setMethodInstance($carrier);
echo $block->_toHtml();
}
?>
<?php endif ?>
</li>
<?php } ?>
<?php endforeach; ?>
</td>
</tr>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<td></td>
<td>Option 2 - specific Time
<label style="font-size: 12px;font-weight:normal;color:silver;">(There will be an additional delivery charge for specific delivery time.)</label>
</tr>
<tr>
<td></td>
<td>
<ul>
<?php $_sole = $_sole && count($_rates) == 1;
foreach ($_rates as $_rate): ?>
<?php
$option = $_rate->getCode();
$optionArray = explode( '_', $option );
$array_last_index = count($optionArray)-1;
$delivery_option = $optionArray[$array_last_index-1];
if($delivery_option == 2)
{
?>
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
<li style="width:250px;float:left;">
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages">
<li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li>
</ul>
<?php else: ?>
<?php if ($_sole) : ?>
<span class="no-display">
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
</span>
<?php else: ?>
<?php // radio button ?>
<?php
foreach($all_options as $opt)
{
$data = $opt->getData();
if($current_category_id == 12)//Cake
{$kk = trim(date("Y-m-d", $tomorrow));
if(trim(date("Y-m-d", $tomorrow)) == trim($order_delivery_date))
{
if(strcmp(trim($_rate->getMethodTitle()),trim($data['delivery_type'])) == 0)
{
$start_time = $data['start_time'];
$end_time = $data['end_time'];
if($delivery_start_time < $start_time)// || (($start_time < $delivery_start_time) && ($delivery_start_time < $end_time)))
{
// Enable option.
?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
}
else
{
?>
<input disabled="disabled" name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
}
}
}
else
{
?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
break;
}
}
else //Rest all products
{
if(trim(date("Y-m-d")) == trim($order_delivery_date))//today's delivery
{
//check the server time to enable option
if(strcmp(trim($_rate->getMethodTitle()),trim($data['delivery_type'])) == 0)
{
$start_time = $data['start_time'];
$end_time = $data['end_time'];
if($server_time < $start_time)// || (($start_time < $server_time) && ($server_time < $end_time)))
{
// Enable option.
?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
}
else
{
?>
<input disabled="disabled" name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
}
}
}
else
{
?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php
break;
}
}
}//foreach
?>
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
<script type="text/javascript">
//<![CDATA[
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<?php // option name ?>
<label for="s_method_<?php echo $_rate->getCode() ?>">
<?php $option_name = $_rate->getMethodTitle();
$optionNameArray = explode( '(', $option_name );
if(count($optionNameArray)>1)
{
echo $optionNameArray[0];
?>
<br>
<?php
echo '('.$optionNameArray[1];
}
else
{
echo $optionNameArray[0];
}
?>
<?php // echo $_rate->getMethodTitle() ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php // echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php
$carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
if($carrier->getFormBlock()){
$block = $this->getLayout()->createBlock($carrier->getFormBlock());
$block->setMethodCode($code);
$block->setRate($_rate);
$block->setMethodInstance($carrier);
echo $block->_toHtml();
}
?>
<?php endif ?>
</li>
<?php } ?>
<?php endforeach; ?>
</ul>
<div style="clear: both;"></div>
</td>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<td style="text-align: right;"><label >Special<br> Instruction : </label></td>
<td><textarea class="textarea-delivery" rows="3" cols="50" name="shipping_deliveryrate[special_instructions]" id="shipping_deliveryrate[special_instructions]" cols="20" rows="4"></textarea></td>
</tr>
<tr>
<td></td>
<td><label style="font-size: 12px;font-weight:normal;font-style:italic;color:silver;">Enter any special instructions or notes about this order<br>
Example: "Call the recipient before the delivery. Try to deliver before 4.00pm"
</label></td>
</tr>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<td></td>
<td style="text-align: right;">
<div style="width: 430px;padding-right: 83px;padding-bottom: 4px;">
<div style="float: left;width: 322px;height: 30px;"><a href="#" style="text-decoration: none;"><label style="font-size: 10px;font-weight:normal;color: #839821;">If you need to type our personal message<br>
in Sinhala or Tamil, please use relevant keyboard here</label></a>
</div>
<div style="width: 108px;height: 30px;float: left;padding-bottom: 4px;padding-top: 8px;">
<input type="button" name="sinhala_keyboard" id="sinhala_keyboard" class="button-checkout-language" value="Sinhala" onclick="opensinhalakeyboard();" />
<input type="button" name="tamil_keyboard" id="tamil_keyboard" class="button-checkout-language" value="Tamil" onclick="opentamilkeyboard();" />
</div>
</div>
</td>
</tr>
<tr>
<td><label style="float:right;">Personel <br>Message : </label></td>
<td><textarea class="textarea-delivery" rows="3" cols="50" name="shipping_deliveryrate[msg]" id="shipping_deliveryrate[msg]" cols="20" rows="4"></textarea></td>
</tr>
<tr>
<td></td>
<td><label style="font-size: 12px;font-weight:normal;font-style:italic;color:silver;">Your message will be hand written on a white card & sent with the gift item.</label></td>
</tr>
</tbody>
</table>
</li>
</ul>
</dd>
<?php
break;
}
}//not florist
else
{
// if florist selected
if($code == 'pickup') // If the shipping method is pickup
{
?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
<?php else: ?>
<?php if ($_sole) : ?>
<span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
<?php else: ?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
<script type="text/javascript">
//<![CDATA[
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php
$carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
if($carrier->getFormBlock()){
$block = $this->getLayout()->createBlock($carrier->getFormBlock());
$block->setMethodCode($code);
$block->setRate($_rate);
$block->setMethodInstance($carrier);
echo $block->_toHtml();
}
?>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php
break;
}
} ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
//<![CDATA[
<?php if (!empty($shippingCodePrice)): ?>
var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
<?php endif; ?>
$$('input[type="radio"][name="shipping_method"]').each(function(el){
Event.observe(el,'click', function(){
if (el.checked == true) {
var getShippingCode = el.getValue();
<?php if (!empty($shippingCodePrice)): ?>
var newPrice = shippingCodePrice[getShippingCode];
if (!lastPrice) {
lastPrice = newPrice;
quoteBaseGrandTotal += newPrice;
}
if (newPrice != lastPrice) {
quoteBaseGrandTotal += (newPrice-lastPrice);
lastPrice = newPrice;
}
<?php endif; ?>
checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
return false;
}
});
});
//]]>
jQuery(document).ready(function(){
hideShippingAll();
jQuery('input[type="radio"][name="shipping_method"]').click(function(){
hideShippingAll();
var code = jQuery(this).val();
if(jQuery(this).is(':checked')){
showShipping(code);
}
});
jQuery('input[type="radio"][name="shipping_method"]').each(function(){
var code = jQuery(this).val();
if(jQuery(this).is(":checked")){
showShipping(code);
}
});
});
function showShipping(code){
if(jQuery('#'+'shipping_form_'+code).length != 0){
jQuery('#'+'shipping_form_'+code).show();
jQuery(this).find('.required-entry').attr('disabled','false');
}
}
function hideShippingAll(){
jQuery('input[type="radio"][name="shipping_method"]').each(function(){
var code = jQuery(this).val();
jQuery('#'+'shipping_form_'+code).hide();
jQuery(this).find('.required-entry').attr('disabled','true');
});
}
function open_in_new_tab(url)
{
window.open(url, '_blank');
window.focus();
}
</script>
<?php endif; ?>
I found the solution.
Both of the shipping methods have same event observer names. That is why it always execute one observer. So changing the event observer names worked
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