首页 文章

在opencart的其他页面中获取唯一选中的复选框值[关闭]

提问于
浏览
-1

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

我将使用季节性日期和值,当选中一个复选框时,它应该比较用户选择的日期,如果匹配则从那里获取值 . 现在我在 product_option_value 表中添加了开始日期和结束日期 . 通过管理区域,我们可以输入特定选项的日期 .

我没有得到在产品/购物车页面中只计算选定值的方式和位置 .

请建议我

这是我的网站,因为我无法附加图像,我提供链接以查看我的页面 .

resort

我将在我的产品页面中进行多项选择,我的意思是三个选项,单个,3个成人选项...(取决于seasong)将在产品页面中的选项选项卡的日期区域中指定,通过管理区域 . 现在我的所有计算都没问题 . 但是当我选中复选框(比如我选择单一)时,应该用用户输入的日期检查开始日期和结束日期,其中“单个”(因为单个条目有多个条目)具有用户输入日期之间的日期,它应该为此选择价格,然后它应该在购物车页面中给出单价 .

但现在它只是在不检查日期的情况下选择价格 . 如果我可以在没有价格的情况下传递所选复选框的ID,那么我可以在那里计算其余部分 . 我没有得到这个 .

这是我的目录/ controller / 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;
                }

我没有得到它被选中复选框值的位置 . (演示/演示)您可以通过演示/演示http://netelity.com/resort/admin查看此链接中的管理员

1 回答

  • 0

    这是我的方式 . 这可能对你没什么帮助:

    First, Make checkbox:

    <?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++; } ?>
    

    Make Javascript function:

    <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>
    

    And do this in your form:

    <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>
    

    And in your anotherpage.php file:

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

    而且,你会看到结果 .

相关问题