繁体   English   中英

警告:非法字符串偏移“数量”Opencart 2.1

[英]Warning: Illegal string offset 'quantity' Opencart 2.1

我试图解决这个问题大约 5 个小时,但我不能。 问题是我有一个错误“警告:C:\laragon\www\opencart\system\library\cart.php 中的非法字符串偏移‘数量’在第 211 行”

我的代码来自 system\library\cart.php

elseif ($option_query->row['type'] == 'checkbox_shildik2') {
                        $value = json_decode(json_encode($value),true);
                            foreach ($value as $product_option_value_id => $data) {
                                $qnt = (int)$data['quantity'];
                                if($qnt > 0){
                                    $option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, 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)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
                                    $qnt = (int)$qnt;
                                    if ($option_value_query->num_rows) {
                                        if ($option_value_query->row['price_prefix'] == '+') {
                                            $option_price += $qnt*$option_value_query->row['price'];
                                        } elseif ($option_value_query->row['price_prefix'] == '-') {
                                            $option_price -= $qnt*$option_value_query->row['price'];
                                        }

                                        if ($option_value_query->row['points_prefix'] == '+') {
                                            $option_points += $qnt*$option_value_query->row['points'];
                                        } elseif ($option_value_query->row['points_prefix'] == '-') {
                                            $option_points -=$qnt* $option_value_query->row['points'];
                                        }

                                        if ($option_value_query->row['weight_prefix'] == '+') {
                                            $option_weight += $qnt*$option_value_query->row['weight'];
                                        } elseif ($option_value_query->row['weight_prefix'] == '-') {
                                            $option_weight -= $qnt*$option_value_query->row['weight'];
                                        }

                                        if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $qnt * $cart['quantity']))) {
                                            $stock = false;
                                        }

                                        $option_data[] = array(
                                            'product_option_id'       => $product_option_id,
                                            'product_option_value_id' => $product_option_value_id,
                                            'option_id'               => $option_query->row['option_id'],
                                            'option_value_id'         => $option_value_query->row['option_value_id'],
                                            'name'                    => $qnt.' x '.$option_query->row['name'],
                                            'value'                   => $option_value_query->row['name'],
                                            'type'                    => $option_query->row['type'],
                                            'quantity'                => $option_value_query->row['quantity'],
                                            'subtract'                => $option_value_query->row['subtract'],
                                            'price'                   => $qnt*$option_value_query->row['price'],
                                            'price_prefix'            => $option_value_query->row['price_prefix'],
                                            'points'                  => $qnt*$option_value_query->row['points'],
                                            'points_prefix'           => $option_value_query->row['points_prefix'],
                                            'weight'                  => $qnt*$option_value_query->row['weight'],
                                            'weight_prefix'           => $option_value_query->row['weight_prefix']
                                        );
                                    }
                                }
                    }
                    }

所以当我点击添加到购物车时,我有意外的令牌 json。 我什至不知道如何解决这个问题以及问题所在

211 行是 $qnt = (int)$data['quantity'];

使用: $qnt =?empty((int)$data['quantity']): (int)$data['quantity']; ' '; $qnt =?empty((int)$data['quantity']): (int)$data['quantity']; ' ';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM