There is a pricing table array that holds a set of prices associated with each damage area, dent size and number of dents. I'm trying to get the specific price depending on which was selected.
To explain: A user will select have the option to select a Damage Area > Dent Size > Number of Dents, then there is a specific cost associated. (For example, Hood > Nickel > 6-15 will cost $225)
$pricing_table => Array (
[Hood] => Array (
[Dime] => Array (
[1-5] => 100
[6-15] => 200
[16-30] => 250
[31-50] => 375
[51-75] => 425
[76-100] => 475
[101-150] => 475
[151-200] => 600 )
[Nickel] => Array (
[1-5] => 125
[6-15] => 225
[16-30] => 300
[31-50] => 400
[51-75] => 475
[76-100] => 525
[101-150] => 625
[151-200] => 700 )
[Quarter] => Array (
[1-5] => 150
[6-15] => 250
[16-30] => 400
[31-50] => 500
[51-75] => 575
[76-100] => 625
[101-150] => 725
[151-200] => 800 )
[Halfdollar] => Array (
[1-5] => 200
[6-15] => 300
[16-30] => 375
[31-50] => 500
[51-75] => 675
[76-100] => 825
[101-150] => 925
[151-200] => 975 ) )
[Roof] => Array...
[Trunk] => Array...
Etc.
REPEAT x 12
The array above ($pricing_table) is created with the following code below in the backend, the user sees none of this:
$pricing_table = get_option( 'hailbids_pricing_table' );
$is_submit = 0;
foreach($pricing_table as $damage_area_title => &$damage_area) {
foreach($damage_area as $dent_size_title => &$dent_size) {
foreach($dent_size as $number_dents_title => &$number_dents) {
if($_POST[sanitize_title('submit-tab-'.$damage_area_title)]) {
$is_submit = 1;
$number_dents = $_POST[sanitize_title($damage_area_title.'-'.$dent_size_title.'-'.$number_dents_title)];
}
}
}
}
The code below is what I have so far:
<?php
$dent_size = get_post_meta(get_the_ID(), 'dent_size', true);
$number_dents = get_post_meta(get_the_ID(), 'number_dents', true);
if ($price > 0) {
?>
<?php
$pricing_table = get_option( 'hailbids_pricing_table' );
$damage_area_no = 1;
foreach ( $pricing_table as $damage_area_title => $damage_area ) :
$i = $damage_area_no - 1;
if(!empty($dent_size[$i]) and !empty($number_dents[$i])) {
echo $number_dents[$i][0];
echo $number_dents[$i];
} else
echo 0;
?>
<?php
$damage_area_no++;
endforeach;
?>
<?PHP } else { ?>
<?PHP } ?>
The script will loop through each $damage_area and check to see if the *$*dent_size[$i] and $number_dents[$i] is not empty. If they are not empty, then I need to echo the correct price associated with $number_dents[$i] from the pricing table array $pricing_table.
This was all passed to me and I'm still figuring it out, so let me know if I didn't explain something well enough.