【问题标题】:ReferenceError: payment is not defined on checkout pageReferenceError:结帐页面上未定义付款
【发布时间】:2014-11-18 08:30:48
【问题描述】:

当我在结帐页面时,浏览器控制台上出现以下错误。

ReferenceError: payment is not defined

当我点击信用卡支付选项时,没有打开任何表单来输入信用卡详细信息,并引发上述错误。

正在使用 Magento 管理员中的信用卡 authorize.net 选项。我也在使用贝宝快速结帐

我在template\checkout\onepage\payment\methods.phtml 文件中有以下代码

    <dl class="sp-methods" id="checkout-payment-method-load">
<?php
    $methods = $this->getMethods();
    $oneMethod = count($methods) <= 1;
?>
 <?php echo $this->getfieldshtml(1); ?>
<?php
    foreach ($methods as $_method):
        $_code = $_method->getCode();
?>
    <dt>
    <?php if(!$oneMethod): ?>
        <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 $oneMethod = $_code; ?>
    <?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; ?>
    <?php echo $this->getfieldshtml(2); ?>
    <?php echo $this->getfieldshtml(3); ?>
</dl>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
//function obsrv(id){
//    if(id && id!=null){
//      $$("#"+id+" input,#"+id+" label,#"+id+" select").each(function(onebyone){if($(onebyone.id) && $(onebyone.id)!=null){$(onebyone.id).removeAttribute("disabled");}});
//    }
//  }


<?php echo $this->getChildChildHtml('scripts'); ?>

$$("#co-payment-form input,#co-payment-form select").each(function(onebyone){if($(onebyone.id) && $(onebyone.id)!=null && onebyone.name.startsWith('fm_fields')){if(true){$(onebyone.id).removeAttribute("disabled");}}});

<?php if (is_string($oneMethod)): ?>
    payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>

我将代码替换为以下代码,因为 Magento 默认代码文件中也有此代码

<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>

但还是没有运气

【问题讨论】:

  • 把你的代码放在这里。无需了解您的代码,我们无法说出您遇到的问题。
  • @Bhojendra-C-LinkNepal 我更新了我的问题
  • 什么是付款?你有没有在任何地方定义它?
  • 我已经使用自定义 jQuery 代码解决了这个问题

标签: javascript magento


【解决方案1】:

替换所有付款。通过计费。在那个文件和 ogone 的 osc_payment.js 和 payment.js 中 + 添加这个可配置的布局:

    <checkout_onestep_index>
    <reference name="head">
        <action method="addJs"><script>netresearch/ops/osc_payment.js</script></action>
        <action method="addJs"><script>netresearch/ops/payment.js</script></action>
    </reference>
    <reference name="head">
        <action method="addCss"><stylesheet>css/ops.css</stylesheet></action>
    </reference>
</checkout_onestep_index>

【讨论】:

    【解决方案2】:

    我遇到了同样的错误,也许是其他原因,也许不是,所以我就是这样解决的......

    我们已将 PHP 设置为使用逗号作为“float”类型。但是 payment.phtml 正在呼应这一点:

    var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
    

    当订单金额浮动为 19,83€ 时,结果为:

    var quoteBaseGrandTotal = 19,83;
    

    这产生了 javascript 错误。

    我没有足够的时间来正确修补这个问题,所以我将这一行替换为:

    var quoteBaseGrandTotal = <?php echo str_replace(',','.', (float)$this->getQuoteBaseGrandTotal() ); ?>;
    

    问题就消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-24
      • 2014-06-30
      • 2015-04-22
      • 1970-01-01
      • 2017-08-13
      • 2017-08-19
      • 1970-01-01
      • 2019-01-27
      相关资源
      最近更新 更多