Beispiel #1
0
 /**
  * Map and build the address form fields
  *
  * Method will call mapFieldData() to map the field data and then biuld each
  * field HTML
  *
  * @access private
  * @param array $fields The field list
  * @param array $data The optional database record to map against
  * @return string The constructed HTML on success, empty string on failure
  */
 private function buildFieldData($addressId = 0, $customerId = 0)
 {
     $data = array();
     /**
      * Do we have a valid address record ID?
      */
     if (isId($addressId)) {
         /**
          * We must also have a customer ID
          */
         if (!isId($customerId)) {
             $customerId = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();
         }
         if (!isId($customerId)) {
             return '';
         }
         $entity = new ISC_ENTITY_SHIPPING();
         $data = $entity->get($addressId, $customerId);
         if (!$data) {
             return '';
         }
     }
     $getFromRequest = false;
     $getFromFormSessionId = '';
     if (isId($addressId) && isId($data['shipformsessionid'])) {
         $getFromFormSessionId = $data['shipformsessionid'];
     } else {
         $getFromRequest = true;
     }
     $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ADDRESS, $getFromRequest, $getFromFormSessionId);
     /**
      * OK, we got the fields, now we need to map the database record to it. This method has to
      * be called as it also adds in the country and state options, so call this regardless
      */
     if (!$this->mapFieldData($fields, $data)) {
         return '';
     }
     /**
      * Remove the 'Save this address' option as this is for single page checkout only
      */
     $html = '';
     foreach (array_keys($fields) as $fieldId) {
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'savethisaddress' || isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'shiptoaddress') {
             continue;
         }
         $html .= $fields[$fieldId]->loadForFrontend();
     }
     return $html;
 }