Javascript 未分配到我的购物车的客户-Prestashop-Personnal模块

Javascript 未分配到我的购物车的客户-Prestashop-Personnal模块,javascript,php,ajax,prestashop,Javascript,Php,Ajax,Prestashop,为什么大家, 我的Prestashop中有一个由朋友开发的商店接口模块。我正在使用症状阻滞剂。我现在无法联系我的朋友,我需要解决这个问题 在我的模块中,我有: -控制器,用于所有功能(添加客户、添加购物车、将购物车转换为订单等) -一个Javascript文件,用于所有Ajax调用 当我想要添加客户并验证表单时,未分配给购物车。我用Chrome开发工具检查了ajax调用,我看到了: createCustomer调用后,必须调用函数assignCustomer,但不调用任何函数 您可以在crea

为什么大家,

我的Prestashop中有一个由朋友开发的商店接口模块。我正在使用症状阻滞剂。我现在无法联系我的朋友,我需要解决这个问题

在我的模块中,我有:
-控制器,用于所有功能(添加客户、添加购物车、将购物车转换为订单等)
-一个Javascript文件,用于所有Ajax调用

当我想要添加客户并验证表单时,未分配给购物车。我用Chrome开发工具检查了ajax调用,我看到了:

createCustomer调用后,必须调用函数assignCustomer,但不调用任何函数

您可以在createCustomer和assignCustomer函数下面找到:

public function ajaxProcessCreateCustomer(){
  // Collecting datas form
    $lastname = Tools::getValue('lastname');
    $firstname = Tools::getValue('firstname');
    $id_gender = Tools::getValue('gender');
    $postcode = Tools::getValue('postcode');
    $address1 = Tools::getValue('address1');
    $address2 = Tools::getValue('address2');
    $city = Tools::getValue('city');
    $phone = Tools::getValue('phone');
    $phone_mobile = Tools::getValue('mobile');
    $email = Tools::getValue('email');
    $id_country = Tools::getValue('country');
    $newsletter = Tools::getValue('newsletter');

  // Create new customer only if we get at least postcode
  if(!empty($postcode)){
    $this->create_account = true;
    if(!Tools::getValue('is_new_customer', 1))
      $_POST['passwd'] = md5(time()._COOKIE_KEY_);
    if(empty($email)){
      $email = "part.part@example.com";
    }
    else {
      // Checked the user address in case he changed his email address
      if(Validate::isEmail($email) && !empty($email))
        if(Customer::customerExists($email))
          Caisse::$errors[] = Tools::displayError('E-mail address already used.', false);
    }
    // Preparing customer
    $customer = new Customer(); 

    if(!count(Caisse::$errors)){
      $customer->id_gender =(!empty($id_gender) ? $id_gender : 1);
      $customer->firstname =(!empty($firstname) ? ucwords($firstname) : ' ');
      $customer->lastname =(!empty($lastname) ? ucwords($lastname) : ' ');
      $customer->newsletter =(!empty($newsletter) ? $newsletter : 0);
      $customer->passwd = md5(time()._COOKIE_KEY_);
      $customer->email = $email;
      $customer->is_guest = 0;
      $customer->active = 1;
      if($customer->add()){
        $customer->cleanGroups();
        $customer->addGroups(array(3,4));
        if(!empty($address1) || !empty($postcode) || !empty($phone) || !empty($phone_mobile)){
          $address = new Address();
          $address->id_customer =(int)$customer->id;
          $address->alias = "Mon adresse";
          $address->lastname =(!empty($lastname) ? $lastname : ' ');
          $address->firstname =(!empty($firstname) ? $firstname : ' ');
          $address->address1 =(!empty($address1) ? $address1 : ' ');
          $address->address2 =(!empty($address2) ? $address2 : ' ');
          $address->postcode =(!empty($postcode) ? $postcode : ' ');
          $address->phone =(!empty($phone) ? $phone : ' ');
          $address->phone_mobile =(!empty($phone_mobile) ? $phone_mobile : ' ');
          $address->id_country = $id_country;
          $address->id_state = 0;
          $address->city =(!empty($city) ? $city : ' ');
          if($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC')){
            include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
            $normalize = new AddressStandardizationSolution;
            $address->address1 = $normalize->AddressLineStandardization($address->address1);
            $address->address2 = $normalize->AddressLineStandardization($address->address2);
          }
          if(!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
            Caisse::$errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
          if($country->need_identification_number &&(!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
            Caisse::$errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
          elseif(!$country->need_identification_number)
            $address->dni = null;
          $address->save();

          $_POST['id_customer'] =(int)$customer->id;

          Caisse::assignCustomer($customer->firstname.' '.$customer->lastname);
        }
      }
      else{
        Caisse::$errors[] = Tools::displayError('The account creation failed.');
      }
    }
  }
  else{
    Caisse::$errors[] = Tools::displayError('Please, give at least the postal code.');
  }

  $this->dieCaisseAjax();
}


public function ajaxProcessAssignCustomer(){
  Caisse::assignCustomer();
  $this->dieCaisseAjax();
}
在我的javascript中,函数如下:

.result(function(e, data, formatted) {
  ajaxCall('assignCustomer', data);    
});
$('#add-new-client').submit(function(e) {
  $('#modal-new-client').modal('hide');
  ajaxCall('createCustomer', $(this).serialize());
  e.preventDefault();
});

谢谢你的帮助

你能发布完整的javascript吗?还有“ajaxCall”功能。顺便说一下,我看到函数assignCustomer在createCustomer中被调用。你确定没有调用该函数吗?你能解释一下该模块的总体功能吗?不太清楚。