Opencart中的结账验证在哪里?

时间:2013-08-16 22:36:46

标签: php jquery opencart

我遇到的问题是,在“交付方法”部分中,Ajax由于某种原因无法验证。

在下面的代码中(来自checkout / checkout.tpl),BeforeSend和complete函数被触发,但成功中的函数没有触发。

有谁能告诉我'index.php?route = checkout / shipping_method / validate'在哪里设置?

谢谢

$('#button-shipping-method').live('click', function() {
   $.ajax({
      url: 'index.php?route=checkout/shipping_method/validate',
      type: 'post',
      data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),
      dataType: 'json',
      beforeSend: function() {
         $('#button-shipping-method').attr('disabled', true);
         $('#button-shipping-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
      },   
      complete: function() {
         $('#button-shipping-method').attr('disabled', false);
         $('.wait').remove();
      },         
      success: function(json) {
         $('.warning, .error').remove();

         if (json['redirect']) {
            location = json['redirect'];
         } else if (json['error']) {
            if (json['error']['warning']) {
               $('#shipping-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');

               $('.warning').fadeIn('slow');
            }         
         } else {
            $.ajax({
               url: 'index.php?route=checkout/payment_method',
               dataType: 'html',
               success: function(html) {
                  $('#payment-method .checkout-content').html(html);

                  $('#shipping-method .checkout-content').slideUp('slow');

                  $('#payment-method .checkout-content').slideDown('slow');

                  $('#shipping-method .checkout-heading a').remove();
                  $('#payment-method .checkout-heading a').remove();

                  $('#shipping-method .checkout-heading').append('<a>Modify &raquo;</a>');   

               },
               error: function(xhr, ajaxOptions, thrownError) {
                  alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
               }
            });               
         }
      },
      error: function(xhr, ajaxOptions, thrownError) {
         alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
      }
   });   
});

2 个答案:

答案 0 :(得分:4)

由于url向控制器结构显示validate函数,您可以在名称为ControllerCheckoutShippingMethod的类中找到该函数,该类位于

  

目录\控制器\结帐\ shipping_method.php

答案 1 :(得分:0)

  

结帐使用多页   因为您的Ajax URL是

url: 'index.php?route=checkout/shipping_method/validate',
  

它使用函数从页面checkout / shipping_method.php中检索数据   验证

     

和   客人结账

checkout/guest.php    


public function save() {//this function consist validation

checkout/shipping_method.php
checkout/payment_method.php
  

您可以使用firebug中的控制台进行检查,这将使您清楚   关于通过ajax调用哪个部分或页面当前正在运行。