このような配列があり、製品が選択されたデータを持っています。
$option_data[] = array(
'product_option_id' => $product_option_id,
'product_option_value_id' => $option_value,
'name1' => $option_value['name'],
'option_id' => $option_query->row['option_id'],
'option_value_id' => $option_value_query->row['option_value_id'],
'name' => $option_query->row['name'],
'option_value' => $option_value_query->row['name'],
'type' => $option_query->row['type'],
'quantity' => $option_value_query->row['quantity'],
'subtract' => $option_value_query->row['subtract'],
'price' => $option_value_query->row['price'],
'sdate' => $option_value_query->row['sdate'],
'edate' => $option_value_query->row['edate'],
'price_prefix' => $option_value_query->row['price_prefix'],
'points' => $option_value_query->row['points'],
'points_prefix' => $option_value_query->row['points_prefix'],
'weight' => $option_value_query->row['weight'],
'weight_prefix' => $option_value_query->row['weight_prefix']
);
そして、価格の値が必要なので、このように価格値を割り当てました
$pricelist = $option_value_query->row['price'];
実際には 2 つの値があり、これら 2 つの値を追加したいと思います。それを分離してそれらの値を追加する方法がわかりません。
編集済み* ***
私の機能はこのようなものです
public function getProducts12() {
if ($this->data) {
foreach ($this->session->data['cart'] as $key => $quantity) {
$product = explode(':', $key);
$product_id = $product[0];
$stock = true;
//echo $product_id;
// Options
if (isset($product[1])) {
$options = unserialize(base64_decode($product[1]));
} else {
$options = array();
}
$product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'");
if ($product_query->num_rows) {
$option_price = 0;
$option_points = 0;
$option_weight = 0;
foreach ($options as $option)
{
$array123[] = $option;
$var123 = $array123[0];
}
$option_data = array();
foreach ($options as $product_option_id => $option_value) {
$option_query = $this->db->query("SELECT po.product_option_id, po.option_id, od.name, o.type FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_option_id = '" . (int)$product_option_id . "' AND po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "'");
if ($option_query->num_rows) {
if ($option_query->row['type'] == 'radio' ){
$option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.price, pov.sdate, pov.edate, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$option_value . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
if ($option_value_query->num_rows) {
if ($option_value_query->row['price_prefix'] == '+') {
$option_price += $option_value_query->row['price'];
} elseif ($option_value_query->row['price_prefix'] == '-') {
$option_price -= $option_value_query->row['price'];
}
if ($option_value_query->row['points_prefix'] == '+') {
$option_points += $option_value_query->row['points'];
} elseif ($option_value_query->row['points_prefix'] == '-') {
$option_points -= $option_value_query->row['points'];
}
if ($option_value_query->row['weight_prefix'] == '+') {
$option_weight += $option_value_query->row['weight'];
} elseif ($option_value_query->row['weight_prefix'] == '-') {
$option_weight -= $option_value_query->row['weight'];
}
$option_data[] = array(
'product_option_id' => $product_option_id,
'product_option_value_id' => $option_value,
'name1' => $option_value['name'],
'option_id' => $option_query->row['option_id'],
'option_value_id' => $option_value_query->row['option_value_id'],
'name' => $option_query->row['name'],
'option_value' => $option_value_query->row['name'],
'type' => $option_query->row['type'],
'quantity' => $option_value_query->row['quantity'],
'subtract' => $option_value_query->row['subtract'],
'price' => $option_value_query->row['price'],
'sdate' => $option_value_query->row['sdate'],
'edate' => $option_value_query->row['edate'],
'price_prefix' => $option_value_query->row['price_prefix'],
'points' => $option_value_query->row['points'],
'points_prefix' => $option_value_query->row['points_prefix'],
'weight' => $option_value_query->row['weight'],
'weight_prefix' => $option_value_query->row['weight_prefix']
);
}
//var_dump ($option_value_query->row['price']);
$pricelist = $option_value_query->row['price'];
//$_SESSION['m'] = $pricelist[0];
}
}
}
var_dump($pricelist);
}
}
}
//echo ($option_price);
return $this->data;
//echo $this->data;
}
}