Dropdown out of order

I have been working on a third party php scripts(tomatocart) and can’t get the drop down select to come up in order 1,2,3 etc…

See the working site
banster dot com / banners / 20-church-banner dot html

Here is the code that deal with the image area:

function getProductVariantsId($variants){ $product_id_string = osc_get_product_id_string($this->getID(), $variants);
  if(isset($this->_data['variants']) && isset($this->_data['variants'][$product_id_string])){
    return $this->_data['variants'][$product_id_string]['variants_id'];
  }else{
    return false;
  }
}

function getVariantsComboboxArray() {
  if ($this->hasVariants()) {
    $combobox_array = array();

    foreach ($this->_data['variants_groups'] as $groups_id => $groups_name) {
      $values = array();
      foreach($this->_data['variants_groups_values'][$groups_id] as $values_id) {
        $values[] = array('id' => $values_id, 'text' => $this->_data['variants_values'][$values_id]);
      }
      
      $combobox_array[$groups_name] = osc_draw_pull_down_menu(
        'variants[' . $groups_id . ']', 
        $values, 
        $this->_data['default_variant']['groups_id'][$groups_id]);
    }
    return $combobox_array;
  }
  
  return false;
}

function getDefaultVariant() {
  if ($this->hasVariants()) {
    return $this->_data['default_variant'];
  }
  
  return false;
}

function iniProductVariants() {
global $osC_Database, $osC_Language, $osC_Currencies;

$products_variants = array();

$Qvariants = $osC_Database->query(‘select * from :table_products_variants where products_id = :products_id order by is_default DESC’);
$Qvariants->bindTable(’:table_products_variants’, TABLE_PRODUCTS_VARIANTS);
$Qvariants->bindInt(’:products_id’, $this->getID());
$Qvariants->execute();

$groups = array();
$values = array();
$groups_values = array();
while ($Qvariants->next()) {
$Qvalues = $osC_Database->query(‘select pve.products_variants_groups_id as groups_id, pve.products_variants_values_id as variants_values_id, pvg.products_variants_groups_name as groups_name, pvv.products_variants_values_name as variants_values_name from :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = pvv.language_id and pvg.language_id = :language_id and pve.products_variants_id = :products_variants_id order by pve.products_variants_groups_id’);
$Qvalues->bindTable(’:table_products_variants_entries’, TABLE_PRODUCTS_VARIANTS_ENTRIES);
$Qvalues->bindTable(’:table_products_variants_groups’, TABLE_PRODUCTS_VARIANTS_GROUPS);
$Qvalues->bindTable(’:table_products_variants_values’, TABLE_PRODUCTS_VARIANTS_VALUES);
$Qvalues->bindInt(’:language_id’, $osC_Language->getID());
$Qvalues->bindInt(’:products_variants_id’, $Qvariants->valueInt(‘products_variants_id’));
$Qvalues->execute();

$variants = array();
$groups_name = array();
while ($Qvalues->next()) {
$variants[$Qvalues->value(‘groups_id’)] = $Qvalues->value(‘variants_values_id’);
$groups_name[$Qvalues->value(‘groups_name’)] = $Qvalues->value(‘variants_values_name’);

$groups[$Qvalues->value(‘groups_id’)] = $Qvalues->value(‘groups_name’);
$values[$Qvalues->value(‘variants_values_id’)] = $Qvalues->value(‘variants_values_name’);

if (!is_array($groups_values[$Qvalues->value(‘groups_id’)])) {
$groups_values[$Qvalues->value(‘groups_id’)] = array();
}

if (!in_array($Qvalues->value(‘variants_values_id’), $groups_values[$Qvalues->value(‘groups_id’)])) {
$groups_values[$Qvalues->value(‘groups_id’)][] = $Qvalues->value(‘variants_values_id’);
}
}
$Qvalues->freeResult();
$product_id_string = osc_get_product_id_string($this->getID(), $variants);

$products_variants[$product_id_string][‘variants_id’] = $Qvariants->valueInt(‘products_variants_id’);
$products_variants[$product_id_string][‘is_default’] = $Qvariants->valueInt(‘is_default’);
$products_variants[$product_id_string][‘sku’] = $Qvariants->value(‘products_sku’);
$products_variants[$product_id_string][‘price’] = $Qvariants->value(‘products_price’);
$products_variants[$product_id_string][‘display_price’] = $osC_Currencies->displayPrice($Qvariants->value(‘products_price’), $this->_data[‘tax_class_id’]);
$products_variants[$product_id_string][‘status’] = $Qvariants->valueInt(‘products_status’);
//quantity will not be cached, it will be retrieved at runtime
// $products_variants[$product_id_string][‘quantity’] = $Qvariants->value(‘products_quantity’);
$products_variants[$product_id_string][‘weight’] = $Qvariants->value(‘products_weight’);
$products_variants[$product_id_string][‘image’] = $this->getImageByID($Qvariants->value(‘products_images_id’));
$products_variants[$product_id_string][‘groups_id’] = $variants;
$products_variants[$product_id_string][‘groups_name’] = $groups_name;
$products_variants[$product_id_string][‘filename’] = $Qvariants->value(‘filename’);
$products_variants[$product_id_string][‘cache_filename’] = $Qvariants->value(‘cache_filename’);

if ($Qvariants->valueInt(‘is_default’) == 1) {
$this->_data[‘default_variant’] = $products_variants[$product_id_string];
$this->_data[‘default_variant’][‘product_id_string’] = $product_id_string;
}

if ($this->_data[‘type’] == PRODUCT_TYPE_DOWNLOADABLE) {
$products_variants[$product_id_string][‘filename’] = $Qvariants->value(‘filename’);
$products_variants[$product_id_string][‘cache_filename’] = $Qvariants->value(‘cache_filename’);
}
}

$Qvariants->freeResult();

$this->_data[‘variants’] = $products_variants;
$this->_data[‘variants_groups’] = $groups;
$this->_data[‘variants_values’] = $values;
$this->_data[‘variants_groups_values’] = $groups_values;
}

Thank you for your time and attention.
RJGonzalez

Sponsor our Newsletter | Privacy Policy | Terms of Service