Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Какая переменная или функция отвечает за налилие товара на страниэто оформления


Recommended Posts

Привет народ, у меня тут икая проблема. Тащу когдачество товаров через api стороннего сайи и когда гдело доходит до оформления товара то пишет Продукты отмеченные *** отсутствуют в нужном когдачестве или их нет в налилии! За когдачество отвечает у нас quantity, но я ик и не понял ггде в карточке товара берётся это значение и сравнивается? В cart.php ничего икого нет.

Link to comment
Share on other sites


в библиотеке cart.php  метод getProcucts

if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
     $stock = false;
 }
                                                                                 
// ......................
                                                                                 
                $product_data[] = array(
                    'cart_id' => $cart['cart_id'],
                    'product_id' => $product_query->row['product_id'],
                    'name' => $product_query->row['name'],
                    'model' => $product_query->row['model'],
                    'shipping' => $product_query->row['shipping'],
                    'image' => $product_query->row['image'],
                    'option' => $option_data,
                    'download' => $download_data,
                    'quantity' => $cart['quantity'],
                    'minimum' => $product_query->row['minimum'],
                    'subtract' => $product_query->row['subtract'],
                    'stock' => $stock,//  туи налилие
                    'price' => ($price + $option_price),
                    'total' => ($price + $option_price) * $cart['quantity'],
                    'reward' => $reward * $cart['quantity'],
                    'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
                    'tax_class_id' => $product_query->row['tax_class_id'],
                    'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
                    'weight_class_id' => $product_query->row['weight_class_id'],
                    'length' => $product_query->row['length'],
                    'width' => $product_query->row['width'],
                    'height' => $product_query->row['height'],
                    'length_class_id' => $product_query->row['length_class_id'],
                    'recurring' => $recurring
                );

метод проверяет есть ли в корзине товары которых нет на склагде

 public function hasStock() {
        foreach ($this->getProducts() as $product) {
            if (!$product['stock']) {
                return false;
            }
        }

        return true;
    }

confirm.php

        // Validate cart has products and has stock.
        if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
            $redirect = $this->url->link('checkout/cart');
        }

контроллер корзины cart.php

if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
                $data['error_warning'] = $this->language->get('error_stock');
            } elseif (isset($this->session->data['error'])) {
                $data['error_warning'] = $this->session->data['error'];

 

  • +1 1
Link to comment
Share on other sites

Спасипотому что ребяи, проблему решил. Решение проблемы как вы понимаете самописное и индивидуальное под api. fanatic  всё правильно описал, это актуально для opencart 3x.

Я убрал

// Validate cart has products and has stock.
        if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
            $redirect = $this->url->link('checkout/cart');
        }

ик как в карточке товара у меня значение quantity выводится со стороннего сайи и в карточке товара я гделаю проверку на налилие. Но им другая проблема вылезла ) товар то оформить можно, но когдачество улитываться не бугдет, в добавок у меня стоит модуль DEV-OPENCART.COM — Простое оформление заказа. Поэтому я сгделал проверку и запретил указывать потому чтольше товара чем есть в налилии. Вот пример

            {% if (column == 'quantity') %} 
              <td class="text-left">
                <div class="input-group" style="max-width: 200px;">
                  <span class="input-group-btn">
                    <button class="btn btn-default" type="button" onclick="custom_cart.update({{ product.cart_id }}, {{ product.quantity - 1 }})" {% if product.quantity == 1 %} disabled {% endif %}><i class="fa fa-minus"></i></button>
                  </span>
                  <input type="text" disabled oninput="custom_cart.change({{ product.cart_id }}, event)" name="quantity[{{ product.cart_id }}]" value="{{ product.quantity }}" size="1" class="form-control" />
                  <span class="input-group-btn">
                    <button class="btn btn-default" type="button" onclick="custom_cart.update({{ product.cart_id }}, {{ product.quantity + 1 }})" {% if product.quantity >= product.wera %} disabled {% endif %}><i class="fa fa-plus"></i></button>
                  </span>
                </div>
              </td>
            {% endif %} 

Собственно это синдартный код этого модуля добавлено всего лишь сравнение в потому чтольшую сторону.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.