subLane Posted June 3, 2012 Report Share Posted June 3, 2012 Подскажите пожалуйста как это можно сделать. Само собой если товаров больше 0 то выводится "Есть в наличии" и наоборот это можно сделать по средствам обыкновенного if и else а вот как найти переменную отвечающую за количество товаров и как ее вывести не очень понимаю помогите с кодом пожалуйста. Quote Link to post Share on other sites
AndryFroggy Posted June 3, 2012 Report Share Posted June 3, 2012 У товара есть варианты. Логично что "нет в наличии" стоит светить в том случае, если всех вариантов товара нет в этом самом наличии. Quote Link to post Share on other sites
Kosjak76 Posted June 3, 2012 Report Share Posted June 3, 2012 Тут не совсем согласен, многие торгуют товарами из Китая, например... И одно дело, если товар лежит на складе, а если его привезут в течении 3х недель - это совсем другое... Делал подобное с тремя вариантами: В наличии, Под заказ и Ожидается Quote Link to post Share on other sites
Kosjak76 Posted June 3, 2012 Report Share Posted June 3, 2012 В базе поле, вывод в шаблон, из админки сохранение... Это все к продукту, а не к варианту. Подробных инструкций писать не умею и не хочу)) Если есть знания - то этого хватит, если нет - то лучше не лезть никуда, а кому-то заплатить... Если есть нулленая Симпла и жедание ни за что не платить - ПХП, Мускуль, Смарти и ХТМЛИли ПРесташоп вам в руки))) Или Мадженто, или ОсКоммерц, они бесплатные))) Quote Link to post Share on other sites
subLane Posted June 5, 2012 Author Report Share Posted June 5, 2012 Знакомый реализовал, может рублей за 400 отдать код. Написал бы я честно дал бы бесплатно)) Quote Link to post Share on other sites
howareyou Posted June 6, 2012 Report Share Posted June 6, 2012 Это делается в шаблоне. Если на складе не 0 товаров, то отображается "цена 8000, добавить в корзину", если же 0, то отображается "нет в наличии, под заказ, предварительный заказ и т.д" Quote Link to post Share on other sites
Kasha Posted June 21, 2012 Report Share Posted June 21, 2012 kors гениально. А теперь попробуй не изобретая велосипед отправь запрос в симпле из твоего примера? Quote Link to post Share on other sites
Kasha Posted June 21, 2012 Report Share Posted June 21, 2012 Тут скорее предложение нежели вопрос. Приведите пример sql запроса применительно к simpl'е, это будет куда более полезно в данном случае. Quote Link to post Share on other sites
filth Posted June 22, 2012 Report Share Posted June 22, 2012 А вручную добавить строку в таблице не получается? Quote Link to post Share on other sites
Pavel Posted June 23, 2012 Report Share Posted June 23, 2012 запрос на создания поля в базе данных?если да, то зачем писать через запрос sql, почему просто не создать вручную? Quote Link to post Share on other sites
filth Posted June 23, 2012 Report Share Posted June 23, 2012 simpla/ProductAdmin.php после $product->featured = $this->request->post('featured'); добавь $product->sklad = $this->request->post('sklad'); Quote Link to post Share on other sites
filth Posted June 23, 2012 Report Share Posted June 23, 2012 --А может, и еще где...Та наверно этого должно хватить ))) Quote Link to post Share on other sites
filth Posted June 24, 2012 Report Share Posted June 24, 2012 Склад: {$product->sklad} добавил конкретно где? Покажи код той части. Quote Link to post Share on other sites
filth Posted June 24, 2012 Report Share Posted June 24, 2012 Danya У Меня получилось через чекбокс, стучись в личку.p.s. У Тебя не получалось, потому, что через селект не так всё просто. Quote Link to post Share on other sites
Danya Posted June 24, 2012 Report Share Posted June 24, 2012 filthкод {$product->sklad} добавил в:design\html\product.tplскинь пожалуйста аську Quote Link to post Share on other sites
SergeyKH Posted June 24, 2012 Report Share Posted June 24, 2012 Может этот вариант прощеhttp://forum.simplacms.ru/discussion/1969/yandeks-market-vygruzka-ostatkov-#Item_4 Quote Link to post Share on other sites
filth Posted June 24, 2012 Report Share Posted June 24, 2012 Может и проще. Но то что придумал Danya намного интереснее и функциональнее. Я реализовал так:В админке посредством чекбокса (аналогично "Активен и Рекомендуемый") добавил "На складе". Что в БД передаёт значение 1 или 0 для поля sklad в таблице s_products.Потом в шаблоне {if $product->sklad==0}......... {else}..........{/if} ну и от сюда можно плясать как хочешь))) Quote Link to post Share on other sites
Danya Posted June 24, 2012 Report Share Posted June 24, 2012 можно впринципе и таким макаром! а в шаблоне выводить надпись, какую хочешь! Quote Link to post Share on other sites
filth Posted June 24, 2012 Report Share Posted June 24, 2012 Danya Так чего в аську не стучишься? у Меня сейчас есть время пару минут, помогу. Quote Link to post Share on other sites
Danya Posted June 25, 2012 Report Share Posted June 25, 2012 filth, спасибо большое за помощь.Доступно рассказал и помог в реализации. Quote Link to post Share on other sites
filth Posted June 25, 2012 Report Share Posted June 25, 2012 Так что, выкладываем в паблик? Quote Link to post Share on other sites
Danya Posted June 25, 2012 Report Share Posted June 25, 2012 filthнапишешь инструкцию или мне выложить? Quote Link to post Share on other sites
filth Posted June 25, 2012 Report Share Posted June 25, 2012 Попробуй Ты, у Меня уже голова кругом за сегодня идёт. Quote Link to post Share on other sites
Danya Posted June 25, 2012 Report Share Posted June 25, 2012 РЕШЕНО1. Добавляем поле sklad в таблицу s_products в базе с парамметрами: Тип - TINYINT; Длина/значения - 1; Null - галочка ALTER TABLE `s_products` ADD `sklad` TINYINT( 1 ) NULL DEFAULT NULL AFTER `visible` 2. simpla/design/html/product.tpl <div class="checkbox"> <input name=sklad value='1' type="checkbox" id="sklad_checkbox" {if $product->sklad}checked{/if}/> <label for="sklad_checkbox">Cклад</label> </div> 3. simpla/ProductAdmin.phpв функции if($this->request->method('post') && !empty($_POST)) добавить: $product->sklad = $this->request->post('sklad'); 4. api/Products.php в 110 строке добавить: p.sklad, и эту же строчку ниже в коде5. в файле simpla/design/html/products.tplв место: <div id="list"> {foreach $products as $product} <div class="{if !$product->visible}invisible{/if} {if $product->hit}hit{/if} row"> <input type="hidden" name="positions[{$product->id}]" value="{$product->position}"> <div class="move cell"><div class="move_zone"></div></div> добавить: <div id="list"> {foreach $products as $product} <div class="{if !$product->visible}invisible{/if} {if $product->hit}hit{/if} {if $product->sklad}sklad{/if} row"> <input type="hidden" name="positions[{$product->id}]" value="{$product->position}"> <div class="move cell"><div class="move_zone"></div></div> в <div class="icons cell"> добавить: <a class="sklad" title="На складе" href="#"></a> в <span id="select"> добавить: <option value="set_sklad">Есть на складе</option> <option value="unset_sklad">Нет на складе</option> в самом низу в скриптах добавить: // Наличие $("a.sklad").click(function() { var icon = $(this); var line = icon.closest("div.row"); var id = line.find('input[type="checkbox"][name*="check"]').val(); var state = line.hasClass('sklad')?0:1; icon.addClass('loading_icon'); $.ajax({ type: 'POST', url: 'ajax/update_object.php', data: {'object': 'product', 'id': id, 'values': {'sklad': state}, 'session_id': '{/literal}{$smarty.session.id}{literal}'}, success: function(data){ icon.removeClass('loading_icon'); if(state) line.addClass('sklad'); else line.removeClass('sklad'); }, dataType: 'json' }); return false; }); 6. в файле simpla/ProductsAdmin.php добавить в 104 строке: case 'set_sklad': { $this->products->update_product($ids, array('sklad'=>1)); break; } case 'unset_sklad': { $this->products->update_product($ids, array('sklad'=>0)); break; } 7. в файле simpla/design/css .icons a.sklad { background-image: url(../images/sklad_grey.png); } #list .sklad a.sklad { background-image: url(../images/sklad.png); } Обязательно после вставки кода, проверяйте и удаляете знак \ перед " Quote Link to post Share on other sites
JustDavali Posted December 11, 2012 Report Share Posted December 11, 2012 файл api/Products.php дальше по аналогии с уже существующими фильтрами. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.