Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4063276
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:42:17+00:00 2026-05-20T15:42:17+00:00

I have an array with arrays in it: Array ( [0] => Array (

  • 0

I have an array with arrays in it:

Array (
  [0] => Array (
    [qty] => 2
    [name] => thing 1
    [model] => 70001
    [price] => 129.00
    [weight] => 75.00
    [id] => 139
  )
  [1] => Array (
    [qty] => 1 
    [name] => thing 2
    [model] => 70002
    [price] => 199.00
    [weight] => 45.00
    [id] => 53
  )
)

I need to pull the weight of each product compare it to a MySQL DB (I can do this) multiply that by the qty and return a cost; then do the same to the next and so on.

Final Update (with complete class function):

function quote($method = '') {
        global $order, $cart, $shipping_weight, $shipping_num_boxes;

        $order->delivery['postcode'] = strtoupper($order->delivery['postcode']);
        $order->delivery['postcode'] = str_replace (' ', '', $order->delivery['postcode']);

    foreach($order->products as $value){//loop through arrays within arrays
        $weight = $value['weight'];
        $qty = $value['qty'];
        $id = $value['id'];

        if($weight <= 25)//find rate
            $weight_class = 'w25';
        elseif(25 < $weight && $weight <= 50)
            $weight_class = 'w50';
        elseif(50 < $weight && $weight <= 100)
            $weight_class = 'w100';
        elseif(100 < $weight && $weight <= 150)
            $weight_class = 'w150';
        else
            $weight_class = 'w300';

        //strip postal code to fsa
        $postalcode = strtoupper(substr($order->delivery['postcode'],0,3));
        //query database for cost
        $postal_query = 'SELECT ' . $weight_class . ' FROM postal_codes WHERE fsa = "' . $postalcode . '"';
        $result = mysql_query($postal_query) or die(mysql_error());

        while($row = mysql_fetch_array($result)){
            $rate = $row[$weight_class].'<br>';
        }
        $cost = $rate * $qty;//multiple by number of products
        $shipping_total[$id] = $cost;//add total cost for this product(s) to array
    }
    $shipping_rate = array_sum($shipping_total);//sum array to total(s)

        $this->quotes = array(  'id' => $this->code,
                                'module' => MODULE_SHIPPING_DLY3_TEXT_TITLE,
                                'methods' => array(array(   'id' => $this->code,
                                                            'title' => MODULE_SHIPPING_DLY3_TEXT_WAY,
                                                            'cost' =>  $shipping_rate)));
        if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
        if ($this->tax_class > 0) {
            $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
        return $this->quotes;
    }

I’ll update if i figure out a way to reduce the number of queries..

Jesse

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:42:18+00:00Added an answer on May 20, 2026 at 3:42 pm
    //Go over all products
    foreach($array as $value){
        $weight = $value['weight'];
        // query goes here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an array of arrays. I have been using array_map(null,$a,$b,$c) to
I have two arrays with following structure: $arr1 = array( array( name => name1,
Say we have array of arrays: tree_limbs = Array.new tree_limbs << %w(1 2 3
I have an array of arrays: Array ( [0] => Array ( [id] =
I have an array that contains an array of arrays if that makes any
Hello frnds actually i have a array of arrays as given below:-` parrent array{
i have an array $mainArray of arrays and i would like to remove /
I have a multidimensional array of arrays (source below), where my keys and values
So basically I have a huge array of arrays (only a 2-d array)... My
I have an array ($configOptions) which contains some arrays. Each array ($option) in that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.