Jump to content

urgent Required feild For home phone .. how to do (sloved)


Recommended Posts

Hi

i edited in Home phone as a required field ...

But i know know where to edit in address.php

here the code i will paste here any one should help me

<?php

/* SSL Management */
$useSSL = true;

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');

if (!$cookie->isLogged())
   Tools::redirect('authentication.php');

//CSS ans JS file calls
$js_files = array(
   _THEME_JS_DIR_.'tools/statesManagement.js'
);

if ($back = Tools::getValue('back'))
   $smarty->assign('back', Tools::safeOutput($back));
if ($mod = Tools::getValue('mod'))
   $smarty->assign('mod', Tools::safeOutput($mod));

$errors = array();

if ($id_address = intval(Tools::getValue('id_address')))
{
   $address = new Address(intval($id_address));
   if (Validate::isLoadedObject($address) AND Customer::customerHasAddress(intval($cookie->id_customer), intval($id_address)))
   {
       if (Tools::isSubmit('delete'))
       {
           if ($cart->id_address_invoice == $address->id)
               unset($cart->id_address_invoice);
           if ($cart->id_address_delivery == $address->id)
               unset($cart->id_address_delivery);
           if ($address->delete())
               Tools::redirect('addresses.php');
           $errors[] = Tools::displayError('this address cannot be deleted');
       }
       $smarty->assign(array(
           'address' => $address,
           'id_address' => intval($id_address)
       ));
   }
   else
       Tools::redirect('addresses.php');
}

if (Tools::isSubmit('submitAddress'))
{
   $address = new Address();
   $errors = $address->validateControler();
   $address->id_customer = intval($cookie->id_customer);

   if (Configuration::get('PS_TOKEN_ENABLE') == 1 &&
       strcmp(Tools::getToken(false), Tools::getValue('token')) &&
       $cookie->isLogged() === true)
       $errors[] = Tools::displayError('invalid token');

   if (!$country = new Country($address->id_country) OR !Validate::isLoadedObject($country))
           die(Tools::displayError());
       if (intval($country->contains_states) AND !intval($address->id_state))
           $errors[] = Tools::displayError('this country require a state selection');

   if (!sizeof($errors))
   {
       if (isset($id_address))
       {
           $country = new Country(intval($address->id_country));
           if (Validate::isLoadedObject($country) AND !$country->contains_states)
               $address->id_state = false;
           $address_old = new Address(intval($id_address));
           if (Validate::isLoadedObject($address_old) AND Customer::customerHasAddress(intval($cookie->id_customer), intval($address_old->id)))
           {
               if ($cart->id_address_invoice == $address_old->id)
                   unset($cart->id_address_invoice);
               if ($cart->id_address_delivery == $address_old->id)
                   unset($cart->id_address_delivery);

               if ($address_old->isUsed())
                   $address_old->delete();
               else
               {
                   $address->id = intval($address_old->id);
                   $address->date_add = $address_old->date_add;
               }
           }
       }

       if ($result = $address->save())
       {
           if ((bool)(Tools::getValue('select_address', false)) == true)
           {
               /* This new adress is for invoice_adress, select it */
               $cart->id_address_invoice = intval($address->id);
               $cart->update();
           }
           Tools::redirect($back ? ($mod ? $back.'&back;='.$mod : $back) : 'addresses.php');
       }
       $errors[] = Tools::displayError('an error occurred while updating your address');
   }
}
elseif (!$id_address)
{
   $customer = new Customer(intval($cookie->id_customer));
   if (Validate::isLoadedObject($customer))
   {
       $_POST['firstname'] = $customer->firstname;
       $_POST['lastname'] = $customer->lastname;
   }
}

if (Tools::isSubmit('id_country') AND Tools::getValue('id_country') != NULL AND is_numeric(Tools::getValue('id_country')))
   $selectedCountry = intval(Tools::getValue('id_country'));
elseif (isset($address) AND isset($address->id_country) AND !empty($address->id_country) AND is_numeric($address->id_country))
   $selectedCountry = intval($address->id_country);
elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
   $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
   if (!Validate::isLanguageIsoCode($array[0]) OR !($selectedCountry = Country::getByIso($array[0])))
       $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
}
else
   $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));

$countries = Country::getCountries(intval($cookie->id_lang), true);
$countriesList = '';
foreach ($countries AS $country)
   $countriesList .= ''.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'';

include(dirname(__FILE__).'/header.php');
$smarty->assign(array(
   'countries_list' => $countriesList,
   'countries' => $countries,
   'errors' => $errors,
   'token' => Tools::getToken(false),
   'select_address' => intval(Tools::getValue('select_address'))
));
Tools::safePostVars();
$smarty->display(_PS_THEME_DIR_.'address.tpl');
include(dirname(__FILE__).'/footer.php');
?>

Link to comment
Share on other sites

in order to add new field, you need at least do following

1. add field to database table ps_address
2. add field to class /classes/Address.php for validation if you want
3. add field to to address /address.php
4. add field to field to theme file /themes/yourtheme/address.tpl

Link to comment
Share on other sites

Try to replace following line of file /classed/Address.php

before change

   protected    $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city');



after change

   protected    $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'postcode', 'city','phone');

Link to comment
Share on other sites

The best way to do this is to use the translate functionality of PrestaShop.

Back office
Tools
Translations

Select error messages and language from drop down list

You can do the same thing for the field name by choose "Field name" in the drop down list



Thanks a lot

Thanks for help me



my problem was sloved
Link to comment
Share on other sites

×
×
  • Create New...