array and variables
Results 1 to 3 of 3

Thread: array and variables

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    28

    array and variables

    $products_array[] = array('id' => $products_id,
    'name' => $products['products_name'],
    'model' => $products['products_model'],
    'image' => $products['products_image'],
    'price' => $products_price,
    'quantity' => $this->contents[$products_id]['qty'],
    'weight' => $products['products_weight'],
    'final_price' => ($products_price + $this->attributes_price($products_id)),
    'tax_class_id' => $products['products_tax_class_id'],
    'fr_currencies_id' => $products['fr_currencies_id'],
    'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
    }
    }

    return $products_array;

    i try to understand codes and structure and try to use one of the variable from the array.

    what i understood is, array is a storage if datas are called. in order to write select statement all the time, it storages datas and we can use them many times if we need.

    the upper side array has 11 variables. this array is in shopping card.php. if i have 5 items in my shopping card, this means 5 columns or lines?

    then how can i select $products['products_tax_class_id']'s of 5 items and compare them whether (i have products_tax_class_id's 1, 2, 3) they are bigger than 2 ?

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,390
    $products_array is a numerically-indexed array; each item in the array is an associative array with 12 named indexes (one being 'tax_class_id' - I'm assuming this is what you're wanting to compare). You could use a foreach() (or a for()) loop on the $products_array array to examine each of these associative arrays.

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    28
    thx for help.

    i have %1 (tax_class_id=10), %8(tax_class_id=20) %20 (tax_class_id=30) tax classes. i need to call tax class id of (shopping card) products in checkout payment, compare them and if any of the product has %20, i will warn customer and offer a option.exam. i have 3 products in shopping card, two of them has %8 tax and one of them has %20 tax.

    $tax20 = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_id = '".$orders_products[$products_id]."'");
    while ($warn20 = tep_db_fetch_array($tax20)) {
    if (warn20== '30') { echo "attention ....";} else { echo "..."}}

    but ths does not work.

    '".$orders_products[$products_id]."'" this part is wrong ? these ids must be products id of shopping card
    Last edited by zeberrun; 04-09-2013 at 06:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •