/** * store an address and associate it with this user * @param $type str billing or shipping * @param $addr array assoc address values * @param $forcenew force creation of a new cm_address_book entry, defaults to true * @see cmAddressBook * @return success */ function store_address($type, $addr, $forcenew = true) { if (!$this->get_id()) { return $this->raiseError("user id not set"); } $addr['user_id'] = $this->get_id(); if (!$forcenew) { // look for existing addr and update it. if ($addrid = $this->get_header($type . '_addr_id')) { $this->addr->set_id($addrid); } else { // not known. $this->addr->reset(); } } /* use the full country name, not ISO code, whenever possible */ if (!empty($this->addr->colmap['country'][3]['iso_codes']) && $addr['country'] != 'US' and is_callable(array('formex', 'get_country_opts'))) { $addr['country'] = formex::get_country_opts(true, $addr['country']); } $this->addr->store($addr, $forcenew); return $this->activateAddress($type, $this->addr->get_id()); }
if ($ACTION) { $SHOWFORM = true; } /** either show an adding/editing form **************************************************/ if ($SHOWFORM) { $c = CSHOP_CLASSES_PRODUCT; $pc = new $c($pdb); $fex = new formex(); $fex->js_src_inline = true; $fex->left_td_style = ''; $fex->field_prefix = ''; $fex->add_element($sm->colmap_zones); // all those things in $colmap are in the form now $fex->add_element('op', array($ACTION, 'submit')); // the button $country_opts = formex::get_country_opts(true); $fex->set_element_opts('cm_shipmethods_zone_locales', $country_opts); if ($ACTION == OP_EDIT) { $vals = $sm->fetch_zone($req_id); /* convert linear array of ISO codes to isocode => countryname */ $cy = array(); foreach ($vals['cm_shipmethods_zone_locales'] as $iso) { $cy[$iso] = $country_opts[$iso]; } $vals['cm_shipmethods_zone_locales'] = $cy; $fex->elem_vals = $vals; $method_title = $vals['zone_name']; $fex->add_element('id', array('hid id', 'hidden', $req_id)); // important } else { $method_title = 'ADD NEW ZONE';