2

这是我在 magento 的 onepagecheckout 中的 methods.phtml 文件,我想要下拉(选择选项)按钮而不是单选按钮……这样我就可以选择付款方式来支付付款。

<?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; ?>
4

2 回答 2

2

您可以在methods.phtml文件中按照以下代码设置付款方式的选择选项下拉菜单。

此外,您必须更改opcheckout.js 第 715 行才能更改"elements[i].checked""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>
于 2016-01-20T11:45:09.177 回答
-1

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>';?>
}
于 2013-03-28T06:27:28.333 回答