Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 14 Ответов
  • 906 Просмотров
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
При выборе атрибутов, не учитывается цена независимого НО не учитывается только в корзине, в карточке товара все отлично. В зависимых атрибутах стоит стандартная цена 7000. https://prnt.sc/j4h09i - здесь видно корзину с уже добавленным товаром который должен стоить 9800(все цены условные).
« Последнее редактирование: 16.04.2018, 00:42:15 от Trime »
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
не очень понятно, зачем вы создаете новую тему? еще и вырываете происходящее из контекста того, что у вас логика добавления в корзину поменяна. зачем? :)
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
не очень понятно, зачем вы создаете новую тему? еще и вырываете происходящее из контекста того, что у вас логика добавления в корзину поменяна. зачем? :)
Я понимаю, что на форуме очень маленькая активность, тем более таких специалистов как вы. Перекопал кучу всего в интернете, не нашел даже намека, куда нужно копать, логику я поменял только убрав проверку атрибутов, но в карточке товара цена то меняется, можно ли ее передать ( ее переменную) в корзину, это единственное, что осталось сделать. И фактически проект сдан. Прошу у вас помощи, пожалуйста. Мне кажется, что где-то в коде стоит такая же проверка IF которую нужно просто закомментировать или изменить условие выполнения. Но вот куда ведет кнопка "В КОРЗИНУ" я не знаю. Пролистал по 2-3 раза cart.php(models), cart.php(controllers), function.php, function.js, product.php(table). Не могу понять последовательность.
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
Но вот куда ведет кнопка "В КОРЗИНУ" я не знаю.
ведет в cart.php(controllers) function add
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
ведет в cart.php(controllers) function add
Спасибо.
Значит формирование цены в зависимости от выбранного атрибута находится там же? Если да, то подскажите пожалуйста какие это строки? И какие переменные у зависимого атрибута и независимого ?
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
Значит формирование цены в зависимости от выбранного атрибута находится там же?
не думаю, скорее в модели. надо смотреть там.
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
не думаю, скорее в модели. надо смотреть там.
Код
function getSum( $incShiping = 0, $incRabatt = 0, $incPayment = 0 ) {
        $jshopConfig = JSFactory::getConfig();
       
        $this->summ = $this->price_product;
       
        if ($jshopConfig->display_price_front_current==1){
            $this->summ = $this->summ + $this->getTax($incShiping, $incRabatt, $incPayment);
        }

        if ($incShiping){
            $this->summ = $this->summ + $this->getShippingPrice();
            $this->summ = $this->summ + $this->getPackagePrice();
        }
       
        if ($incPayment){
            $price_payment = $this->getPaymentPrice();
            $this->summ = $this->summ + $price_payment;
        }
       
        if ($incRabatt){
            $this->summ = $this->summ - $this->getDiscountShow();
            if ($this->summ < 0) $this->summ = 0;
        }
        $dispatcher = JDispatcher::getInstance();
        $dispatcher->trigger('onAfterCartGetSum', array(&$this, &$incShiping, &$incRabatt, &$incPayment));
        return $this->summ;
    }


Здесь? Тогда какие параметры за что отвечают?
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
нет, не здесь. getSum возвращает сумму всех уже добавленных товаров в корзине. а вам надо смотреть в методе add логику, там менять
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
нет, не здесь. getSum возвращает сумму всех уже добавленных товаров в корзине. а вам надо смотреть в методе add логику, там менять
Нашел add, подскажите какие параметры или условия отвечают за цену атрибутов
Код
function add($product_id, $quantity, $attr_id, $freeattributes, $additional_fields = array(), $usetriggers = 1, &$errors = array(), $displayErrorMessage = 1){
        $jshopConfig = JSFactory::getConfig();
        if ($quantity <= 0){
            $errors['100'] = _JSHOP_ERROR_QUANTITY;
if ($displayErrorMessage){
                JError::raiseNotice(100, $errors['100']);
            }
            return 0;
        }
        $updateqty = 1;

        if ($usetriggers){
            $dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeAddProductToCart', array(&$this, &$product_id, &$quantity, &$attr_id, &$freeattributes, &$updateqty, &$errors, &$displayErrorMessage, &$additional_fields, &$usetriggers));
        }

        $attr_serialize = serialize($attr_id);
        $free_attr_serialize = serialize($freeattributes);

        $product = JSFactory::getTable('product', 'jshop');
        $product->load($product_id);

        //check attributes
        if ( (count($product->getRequireAttribute()) == count($attr_id)) || in_array(0, $attr_id)){
            $errors['101'] = _JSHOP_SELECT_PRODUCT_OPTIONS;
            if ($displayErrorMessage){
                JError::raiseNotice(101, $errors['101']);
            }
            return 0;
        }

        //check free attributes
        if ($jshopConfig->admin_show_freeattributes){
            $allfreeattributes = $product->getListFreeAttributes();
if ($usetriggers){
$dispatcher->trigger('onBeforeCheckFreeAttrAddProductToCart', array(&$this, &$product, &$freeattributes, &$allfreeattributes, &$errors, &$displayErrorMessage));
}
            $error = 0;
            foreach($allfreeattributes as $k=>$v){
                if ($v->required && trim($freeattributes[$v->id])==""){
                    $error = 1;
                    $errors['102_'.$v->id] = sprintf(_JSHOP_PLEASE_ENTER_X, $v->name);
                    if ($displayErrorMessage){
                        JError::raiseNotice(102, $errors['102_'.$v->id]);
                    }
                }
            }
            if ($error){
                return 0;
            }
        }

$product->setAttributeActive($attr_id);
        $product->setFreeAttributeActive($freeattributes);
        $qtyInStock = $product->getQtyInStock();
        $pidCheckQtyValue = $product->getPIDCheckQtyValue();

        $new_product = 1;
        if ($updateqty){
        foreach ($this->products as $key => $value){
            if ($value['product_id'] == $product_id && $value['attributes'] == $attr_serialize && $value['freeattributes']==$free_attr_serialize){
                $product_in_cart = $this->products[$key]['quantity'];
                $save_quantity = $product_in_cart + $quantity;

                $sum_quantity = $save_quantity;
                foreach ($this->products as $key2 => $value2){
                    if ($key==$key2) continue;
                    if ($value2['pid_check_qty_value'] == $pidCheckQtyValue){
                        $sum_quantity += $value2["quantity"];
                        $product_in_cart += $value2["quantity"];
                    }
                }

                if ($jshopConfig->max_count_order_one_product && $sum_quantity > $jshopConfig->max_count_order_one_product){
                    $errors['103'] = sprintf(_JSHOP_ERROR_MAX_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->max_count_order_one_product);
                    if ($displayErrorMessage){
                        JError::raiseNotice(103, $errors['103']);
                    }
                    return 0;
                }
                if ($jshopConfig->min_count_order_one_product && $sum_quantity < $jshopConfig->min_count_order_one_product){
                    $errors['104'] = sprintf(_JSHOP_ERROR_MIN_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->min_count_order_one_product);
                    if ($displayErrorMessage){
                        JError::raiseNotice(104, $errors['104']);
                    }
                    return 0;
                }

                if (!$product->unlimited && $jshopConfig->controler_buy_qty && ($sum_quantity > $qtyInStock)){
                    $balans = $qtyInStock - $product_in_cart;
                    if ($balans < 0) $balans = 0;
                    $errors['105'] = sprintf(_JSHOP_ERROR_EXIST_QTY_PRODUCT_IN_CART, $this->products[$key]['quantity'], $balans);
                    if ($displayErrorMessage){
                        JError::raiseWarning(105, $errors['105']);
                    }
                    return 0;
                }

                $this->products[$key]['quantity'] = $save_quantity;               
                $this->products[$key]['price'] = $product->getPrice($this->products[$key]['quantity'], 1, 1, 1, $this->products[$key]);
if ($jshopConfig->cart_basic_price_show){
                    $this->products[$key]['basicprice'] = $product->getBasicPrice();
                }

                if ($usetriggers){
$dispatcher->trigger('onBeforeSaveUpdateProductToCart', array(&$this, &$product, $key, &$errors, &$displayErrorMessage, &$product_in_cart, &$quantity));
                }

                $new_product = 0;
                break;
            }
        }
        }

        if ($new_product){
            $product_in_cart = 0;
            foreach ($this->products as $key2 => $value2){
                if ($value2['pid_check_qty_value'] == $pidCheckQtyValue){
                    $product_in_cart += $value2["quantity"];
                }
            }
            $sum_quantity = $product_in_cart + $quantity;

            if ($jshopConfig->max_count_order_one_product && $sum_quantity > $jshopConfig->max_count_order_one_product){
                $errors['106'] = sprintf(_JSHOP_ERROR_MAX_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->max_count_order_one_product);
                if ($displayErrorMessage){
                    JError::raiseNotice(106, $errors['106']);
                }
                return 0;
            }
            if ($jshopConfig->min_count_order_one_product && $sum_quantity < $jshopConfig->min_count_order_one_product){
                $errors['107'] = sprintf(_JSHOP_ERROR_MIN_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->min_count_order_one_product);
                if ($displayErrorMessage){
                    JError::raiseNotice(107, $errors['107']);
                }
                return 0;
            }

            if (!$product->unlimited && $jshopConfig->controler_buy_qty && ($sum_quantity > $qtyInStock)){
                $balans = $qtyInStock - $product_in_cart;
                if ($balans < 0) $balans = 0;
                $errors['108'] = sprintf(_JSHOP_ERROR_EXIST_QTY_PRODUCT, $balans);
                if ($displayErrorMessage){
                    JError::raiseWarning(108, $errors['108']);
                }
                return 0;
            }

            $product->getDescription();
            $temp_product['quantity'] = $quantity;
            $temp_product['product_id'] = $product_id;
            $temp_product['category_id'] = $product->getCategory();
            $temp_product['tax'] = $product->getTax();
            $temp_product['tax_id'] = $product->product_tax_id;
            $temp_product['product_name'] = $product->name;
            $temp_product['thumb_image'] = getPatchProductImage($product->getData('image'), 'thumb');
            $temp_product['delivery_times_id'] = $product->getDeliveryTimeId();
            $temp_product['ean'] = $product->getEan();
            $temp_product['attributes'] = $attr_serialize;
            $temp_product['attributes_value'] = array();
            $temp_product['extra_fields'] = array();
            $temp_product['weight'] = $product->getWeight();
            $temp_product['vendor_id'] = fixRealVendorId($product->vendor_id);
            $temp_product['files'] = serialize($product->getSaleFiles());
            $temp_product['freeattributes'] = $free_attr_serialize;
            if ($jshopConfig->show_manufacturer_in_cart){
                $manufacturer_info = $product->getManufacturerInfo();
                $temp_product['manufacturer'] = $manufacturer_info->name;
            }else{
                $temp_product['manufacturer'] = '';
            }
            $temp_product['pid_check_qty_value'] = $pidCheckQtyValue;
            $i = 0;
            if (is_array($attr_id) && count($attr_id)){
                foreach($attr_id as $key=>$value){
                    $attr = JSFactory::getTable('attribut', 'jshop');
                    $attr_v = JSFactory::getTable('attributvalue', 'jshop');
                    $temp_product['attributes_value'][$i] = new stdClass();
$temp_product['attributes_value'][$i]->attr_id = $key;
$temp_product['attributes_value'][$i]->value_id = $value;
                    $temp_product['attributes_value'][$i]->attr = $attr->getName($key);
                    $temp_product['attributes_value'][$i]->value = $attr_v->getName($value);
                    $i++;
                }
            }
           
            if ($jshopConfig->admin_show_product_extra_field && count($jshopConfig->getCartDisplayExtraFields())>0){
                $extra_field = $product->getExtraFields(2);               
                $temp_product['extra_fields'] = $extra_field;
            }

foreach($additional_fields as $k=>$v){
                if ($k!='after_price_calc'){
                    $temp_product[$k] = $v;
                }
            }
           
            if ($usetriggers){
                $dispatcher->trigger('onBeforeSaveNewProductToCartBPC', array(&$this, &$temp_product, &$product, &$errors, &$displayErrorMessage));
            }

            $temp_product['price'] = $product->getPrice($quantity, 1, 1, 1, $temp_product);
if ($jshopConfig->cart_basic_price_show){
                $temp_product['basicprice'] = $product->getBasicPrice();
                $temp_product['basicpriceunit'] = $product->getBasicPriceUnit();
            }

if (isset($additional_fields['after_price_calc']) && is_array($additional_fields['after_price_calc'])){
                foreach($additional_fields['after_price_calc'] as $k=>$v){
                    $temp_product[$k] = $v;
                }
            }

            if ($usetriggers){
                $dispatcher->trigger('onBeforeSaveNewProductToCart', array(&$this, &$temp_product, &$product, &$errors, &$displayErrorMessage));
            }
            $this->products[] = $temp_product;
        }

        $this->loadPriceAndCountProducts();
        $this->reloadRabatValue();
        $this->saveToSession();
        if ($usetriggers){
            $dispatcher->trigger('onAfterAddProductToCart', array(&$this, &$product_id, &$quantity, &$attr_id, &$freeattributes, &$errors, &$displayErrorMessage) );
        }
        return 1;
    }
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
Сегодня заметил ещё такую особенность, что если я задаю цену первому атрибуту, то все работает, но только на первых атрибутах, на остальные атрибуты не реагирует.
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
ну вот поэтому и есть проверка на выбор атрибутов при добавлении в корзину. слишком много вопросов появляется если ее убирать.
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
ну вот поэтому и есть проверка на выбор атрибутов при добавлении в корзину. слишком много вопросов появляется если ее убирать.
Подумал, что можно пойти по иному пути. Сделать во всех атрибутах 1 значение "Нет" и если переключать в одном из атрибутов radio, то остальные автоматом встают на 1 позицию, то есть "Нет".
Вопрос, как через скрипт это организовать? подскажите пожалуйста
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0

Написал следующий скрипт, который при выборе одного атрибута, на остальных атрибутах выставляет первое значение.

Код
  jQuery(document).ready(function() {
            jQuery('.input_type_radio2 label').click(function(){
               jQuery('.input_type_radio3:first-child>input').prop('checked', true);
               jQuery('.input_type_radio4:first-child>input').prop('checked', true);
               jQuery('.input_type_radio5:first-child>input').prop('checked', true);
               jQuery('.input_type_radio6:first-child>input').prop('checked', true);
            });
            jQuery('.input_type_radio3 label').click(function(){
               jQuery('.input_type_radio2:first-child>input').prop('checked', true);
               jQuery('.input_type_radio4:first-child>input').prop('checked', true);
               jQuery('.input_type_radio5:first-child>input').prop('checked', true);
               jQuery('.input_type_radio6:first-child>input').prop('checked', true);
            });
            jQuery('.input_type_radio4 label').click(function(){
               jQuery('.input_type_radio2:first-child>input').prop('checked', true);
               jQuery('.input_type_radio3:first-child>input').prop('checked', true);
               jQuery('.input_type_radio5:first-child>input').prop('checked', true);
               jQuery('.input_type_radio6:first-child>input').prop('checked', true);
            });
            jQuery('.input_type_radio5 label').click(function(){
               jQuery('.input_type_radio2:first-child>input').prop('checked', true);
               jQuery('.input_type_radio3:first-child>input').prop('checked', true);
               jQuery('.input_type_radio4:first-child>input').prop('checked', true);
               jQuery('.input_type_radio6:first-child>input').prop('checked', true);
            });
            jQuery('.input_type_radio6 label').click(function(){
               jQuery('.input_type_radio2:first-child>input').prop('checked', true);
               jQuery('.input_type_radio3:first-child>input').prop('checked', true);
               jQuery('.input_type_radio4:first-child>input').prop('checked', true);
               jQuery('.input_type_radio5:first-child>input').prop('checked', true);
            });
         });
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
боюсь что это самый безболезненный способ... хоть конечно и вообще не универсальный, зато без хаков.
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Trime

  • Осваиваюсь на форуме
  • 22
  • 0 / 0
боюсь что это самый безболезненный способ... хоть конечно и вообще не универсальный, зато без хаков.
Хаки все равно есть, пришлось function.php менять, иначе нужных переменных не вытянуть нормально. Ещё думаю 1 элемент скрывать в стилях, тогда вообще все будет как задумал. Кстати ещё одну проблему нашел, при выборе атрибутов, цена в карточке товара меняется раз через раз. Как это исправить? Чтобы цена каждый раз обновлялась при выборе любого атрибута, как зависимого так и независимого
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться