获取openart中其他页面中唯一选定的复选框值


getting the only selected checkbox values in other page in opencart

我正在为一家度假预订公司修改openart。为此,我需要在产品页面有多个复选框选项。但我不是从哪里得到它计算单价,其中包括所有我的复选框,单选按钮选择的选项(价格)。如果我想编辑它,我可以在哪里编辑。

我将有季节性的日期和值,当一个复选框被选中时,它应该比较用户选择的日期,如果匹配,然后从那里得到值。现在我已经在product_option_value表中添加了开始日期和结束日期。通过管理区,我们可以在特定选项的前面输入日期。

我不知道在产品/购物车页面中如何以及在哪里只计算选定的值。

请推荐我

这是我的网站,因为我不能附加图像,我给链接看到我的页面。

度假村

我将有多个选择在我的产品页面,我的意思是三个选项的单人,3个选项的成人…(取决于季节)我要在产品页面选项卡的日期区域指定,通过管理区域。现在我所有的计算都没问题了。但是当我选择复选框时(假设我选择single),它应该用用户输入的日期检查开始日期和结束日期,其中'single'(因为有多个条目为single)在用户输入的日期之间有日期,它应该为其选择价格,然后它应该在购物车页面中给出单价。

但是现在它只是选择价格而不检查日期。如果我可以传递所选复选框的id而不包含其价格,那么我就可以计算剩下的部分。我不明白。

这里是我的目录/控制器/checkout/cart.php

$option_data[] = array(
                        'product_option_id' => $option['product_option_id'],
                        'option_id'         => $option['option_id'],
                        'type'              => $option['type'],
                        'name'              => $option['name'],
                        'price'             => $option['value'],
                        'value'             => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
                    );
                    //echo $option['value'];
                    //echo $option['option_value_id'];
                    //echo $option['type'];
                    if($option['type'] == "checkbox")
                                {
                                    $id = $option['option_value_id'];
                                    //echo $id;
                                    }
                    if($option['name'] =="Check-In")
                    {
                        $this->data['value1'] = $value;
                        $this->data['date1'] = $this->data['value1'];
                        // $this->data['date1'];
                        $_SESSION['data12'] = $this->data['date1'];
                    }
                    //echo $_SESSION['data12'];
                    $this->data['mydate1'] = strtotime($_SESSION['data12']);
                    if($option['name'] == "Check-Out")
                    {
                    $this->data['value2'] = $option['option_value'];
                    $this->data['date2'] = $this->data['value2'];
                    $_SESSION['data13'] = $this->data['date2'];
                    // $this->data['date2'];
                    }
                $this->data['mydate2'] = strtotime($_SESSION['data13']);

                $difference = abs(($this->data['mydate2']) - ($this->data['mydate1']));
                $this->data['totaldays1'] = floor($difference/(60*60*24));
                // $this->data['totaldays1'];
                $total123 = (int)$this->data['totaldays1'];
                // $total123;
                $_SESSION['tot123'] = $total123;
                //$my3 = $_SESSION['tot123'];
                //$this->data['my3'] = $_SESSION['tot123'];
                }
                ////////////////////////////////////////////////////////////MY CODE SHOULD GO HERE******************************************
                $roomRate = $this->currency->format($this->tax->getRatesofRooms($id, $_SESSION['data12'],$_SESSION['data13'] ));
                //$roomRate = $this->currency->format($this->tax->getRatesofRooms($id, $_SESSION['data12'],$_SESSION['data13'] ));
                //echo $roomRate;
                //$price = $roomRate;
                //echo $price;
                //$product['price'] = $roomRate;
                $product['price'] += $roomRate;
                //echo $product['price'];
                // Display prices
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                    $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
                    //echo $price;
                } 
                else {
                    $price = false;
                }
                //$product['price'];
                // Display prices
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                    $total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $_SESSION['tot123']);
                } else {
                    $total = false;
                }
                // $total1;
                // $total1;
                $this->data['products'][] = array(
                    'key'      => $product['key'],
                    'thumb'    => $image,
                    'name'     => $product['name'],
                    'model'    => $product['model'],
                    //'checkin'  => $product['checkin'],
                    //'checkout'  => $product['checkout'],
                    'option'   => $option_data,
                    'quantity' => $product['quantity'],
                    'stock'    => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
                    'reward'   => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
                    'price'    => $price,
                    'total'    => $total,
                    'href'     => $this->url->link('product/product', 'product_id=' . $product['product_id']),
                    'remove'   => $this->url->link('checkout/cart', 'remove=' . $product['key'])
                );
            }

这里它计算价格,其中包括选中的复选框价格,而不比较日期

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                    $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
                    //echo $price;
                } 
                else {
                    $price = false;
                }

我不是从它得到选择复选框的值。(演示/演示)你可以通过给出demo/demo来检查这个链接中的管理员http://netelity.com/resort/admin

我是这样做的。这可能对您有点帮助:

首先,使复选框:

<?php 
$i = 1;
foreach ($result as $res) { ?>
 <tr>
<td>   <input id="cb<?=$i; ?>" name="cb<?=$i; ?>" type="checkbox" onClick="check(<?=$i; ?>,<?=$res['entry_id']; ?> ,this.checked);" 
value="<?php echo $res['entry_id']; ?>" > </td>
 <td> //rest of your code </td>
 </tr>
<?php $i++; } ?>

创建Javascript函数:

<script>
function check(cb_id,entry_id,val)
  {
     if(val == true){
         document.getElementById('cb_hidden_entry_id'+cb_id).value = entry_id;  
         //alert(document.getElementById('cb_hidden_entry_id'+cb_id).value);
     } else {
          document.getElementById('cb_hidden'+cb_id).value = '';
    }
  }
</script>

在你的表单中这样做:

<form name="form_name" id="form_name" action="anotherpage.php" method="post">

        <?php 
        $i = 1;
        foreach ($result as $res) { ?>
            <input type="hidden" id="cb_hidden_entry_id<?=$i; ?>" name="cb_hidden_entry_id<?=$i; ?>" value="" >  
            <?php //rest of your code ?>
        <?php $i++; }  //foreach closed ?> 
      <input class="button" type="submit" name="btn_submit" id="btn_submit" value="Send Email"/></div>   

</form>

在你的anotherpage.php文件中:

<?php
$_POST = array_filter($_POST); //filter empty array in $_POST
echo '<pre>';
print_r($_POST);
?>

然后,您将看到结果