lexx790 Posted October 24, 2017 Report Share Posted October 24, 2017 Добрый день. Лазин в админке, где-то цвет текста по поменял идт. Теперь не добавляется товар к корзину. Подскажите где капать? Я не программист, сложно самому найти в коде. Хотел на кворке найти человека никто не берется. Quote Link to post Share on other sites
jonny008 Posted October 24, 2017 Report Share Posted October 24, 2017 Добрый день. Лазин в админке, где-то цвет текста по поменял идт. Теперь не добавляется товар к корзину. Подскажите где капать? Я не программист, сложно самому найти в коде. Хотел на кворке найти человека никто не берется. Ссылку можно? Quote Link to post Share on other sites
lexx790 Posted October 24, 2017 Author Report Share Posted October 24, 2017 (edited) Ссылку можно? robot-transformer.ru Edited October 24, 2017 by lexx790 Quote Link to post Share on other sites
Noxter Posted October 24, 2017 Report Share Posted October 24, 2017 Ссылку можно? robot-transformer.ruНе добавляет потому что в форме (там где кнопка в корзину) нет скрытого поля с ID вариантом, т.е. в корзину не передается ID варианта товара. Возможно моя статья вам поможет. Quote Link to post Share on other sites
mishanya Posted October 24, 2017 Report Share Posted October 24, 2017 Не добавляет потому что в форме (там где кнопка в корзину) нет скрытого поля с ID вариантом, т.е. в корзину не передается ID варианта товара.Возможно моя статья вам поможет. все там есть и все передается, дело в чем-то другомhttps://yadi.sk/i/-eMb-kyD3P4EGwhttps://yadi.sk/i/pnpeqK8u3P4EUL Quote Link to post Share on other sites
Noxter Posted October 24, 2017 Report Share Posted October 24, 2017 все там есть и все передается, дело в чем-то другом https://yadi.sk/i/-eMb-kyD3P4EGw https://yadi.sk/i/pnpeqK8u3P4EULНе там смотришь, страница категории. Не там смотришь, страница категории.Хотя нет, вижу в скрытом диве. Quote Link to post Share on other sites
mishanya Posted October 24, 2017 Report Share Posted October 24, 2017 Не там смотришь, страница категории. Хотя нет, вижу в скрытом диве. для особо одаренных страница категории - https://yadi.sk/i/oXUmtjU83P4Ef3 и запросhttps://yadi.sk/i/a5s64d4Q3P4Eie все там есть. ниоткуда не добавляет Quote Link to post Share on other sites
Noxter Posted October 24, 2017 Report Share Posted October 24, 2017 .htaccess тоже не срабатывает http://robot-transformer.ru/cart?variant=74 Нужно смотреть. Дайте доступ к фтп. для особо одаренных страница категории - https://yadi.sk/i/oXUmtjU83P4Ef3 и запрос https://yadi.sk/i/a5s64d4Q3P4Eie все там есть. ниоткуда не добавляетА вот грубить не нужно, не заметил сразу и поправил свой пост. Quote Link to post Share on other sites
yr4ik Posted October 24, 2017 Report Share Posted October 24, 2017 нужно смотреть ajax/cart.php и api/Cart.php Какие то изменения в них делали? Quote Link to post Share on other sites
lexx790 Posted October 24, 2017 Author Report Share Posted October 24, 2017 Нет. Только в админке лазил. cart.tpl и другие tpl Quote Link to post Share on other sites
shooroop Posted October 24, 2017 Report Share Posted October 24, 2017 Нет. Только в админке лазил. cart.tpl и другие tpl выложите файл cart_informer.tpl Quote Link to post Share on other sites
yr4ik Posted October 24, 2017 Report Share Posted October 24, 2017 он тут не причем. Нет добавления в сессию Quote Link to post Share on other sites
mishanya Posted October 24, 2017 Report Share Posted October 24, 2017 (edited) выложите файл cart_informer.tpl а он при чем если не добавляет даже по прямой ссылке /cart?variant=209 он тут не причем. Нет добавления в сессию видимо только сессия корзины не работает, т.к. авторизация работает. или еще что-то сломалось Edited October 24, 2017 by mishanya Quote Link to post Share on other sites
yr4ik Posted October 24, 2017 Report Share Posted October 24, 2017 думаю нужно смотреть api cart Quote Link to post Share on other sites
lexx790 Posted October 24, 2017 Author Report Share Posted October 24, 2017 (edited) cart.tpl {* Информера корзины (отдаётся аяксом) *} {if $cart->total_products>0} <div class="heading"> <h4>Корзина покупок</h4> <a><span id="cart-total">{$cart->total_products} {$cart->total_products|plural:'робот':'роботов':'робота'} - {$cart->total_price|convert} {$currency->sign|escape}</span></a> </div> <div class="content"> <div class="mini-cart-info"> <table> <tbody> {foreach from=$cart->purchases item=purchase} <tr> <td class="image"> {$image = $purchase->product->images|first} {if $image} <a href="products/{$purchase->product->url}"><img src="{$image->filename|resize:50:50}" alt="{$product->name|escape}"></a> {/if} </td> <td class="name"><a href="products/{$purchase->product->url}">{$purchase->product->name|escape}</a></td> <td class="quantity">x {$purchase->amount}</td> <td class="total">{($purchase->variant->price)|convert} {$currency->sign}.</td> <td class="remove"><a href="cart/remove/{$purchase->variant->id}"><img src="design/{$settings->theme|escape}/images/close.png" alt="Удалить" title="Удалить"></a></td> </tr> {/foreach} </tbody> </table> </div> <div class="mini-cart-total"> <table> <tbody> <tr> <td class="right"><b>Итого:</b></td> <td class="right">{$cart->total_price|convert} {$currency->sign|escape}</td> </tr> </tbody> </table> </div> <div class="checkout"><a href="/cart">Оформить заказ</a></div> </div> {else} <div class="heading"> <h4>Корзина покупок</h4> <a><span id="cart-total">{$cart->total_products} {$cart->total_products|plural:'товар':'товаров':'товара'} - {$cart->total_price|convert} {$currency->sign|escape}</span></a> </div> <div class="content"> <div class="empty">Корзина пуста</div> </div> {/if} ajax/cart.php <?php session_start(); require_once('../api/Simpla.php'); $simpla = new Simpla(); $simpla->cart->add_item($simpla->request->get('variant', 'integer'), $simpla->request->get('amount', 'integer')); $cart = $simpla->cart->get_cart(); $simpla->design->assign('cart', $cart); $currencies = $simpla->money->get_currencies(array('enabled'=>1)); if(isset($_SESSION['currency_id'])) $currency = $simpla->money->get_currency($_SESSION['currency_id']); else $currency = reset($currencies); $simpla->design->assign('currency', $currency); $result = $simpla->design->fetch('cart_informer.tpl'); header("Content-type: application/json; charset=UTF-8"); header("Cache-Control: must-revalidate"); header("Pragma: no-cache"); header("Expires: -1"); print json_encode($result); <?php /** * Simpla CMS * * @copyright 2011 Denis Pikusov * @link http://simplacms.ru * @author Denis Pikusov * */ require_once('Simpla.php'); class Cart extends Simpla { /* * * Функция возвращает корзину * */ public function get_cart() { $cart = new stdClass(); $cart->purchases = array(); $cart->total_price = 0; $cart->total_products = 0; $cart->coupon = null; $cart->discount = 0; $cart->coupon_discount = 0; // Берем из сессии список variant_id=>amount if(!empty($_SESSION['shopping_cart'])) { $session_items = $_SESSION['shopping_cart']; $variants = $this->variants->get_variants(array('id'=>array_keys($session_items))); if(!empty($variants)) { foreach($variants as $variant) { $items[$variant->id] = new stdClass(); $items[$variant->id]->variant = $variant; $items[$variant->id]->amount = $session_items[$variant->id]; $products_ids[] = $variant->product_id; } $products = array(); foreach($this->products->get_products(array('id'=>$products_ids, 'limit' => count($products_ids))) as $p) $products[$p->id]=$p; $images = $this->products->get_images(array('product_id'=>$products_ids)); foreach($images as $image) $products[$image->product_id]->images[$image->id] = $image; foreach($items as $variant_id=>$item) { $purchase = null; if(!empty($products[$item->variant->product_id])) { $purchase = new stdClass(); $purchase->product = $products[$item->variant->product_id]; $purchase->variant = $item->variant; $purchase->amount = $item->amount; $cart->purchases[] = $purchase; $cart->total_price += $item->variant->price*$item->amount; $cart->total_products += $item->amount; } } // Пользовательская скидка $cart->discount = 0; if(isset($_SESSION['user_id']) && $user = $this->users->get_user(intval($_SESSION['user_id']))) $cart->discount = $user->discount; $cart->total_price *= (100-$cart->discount)/100; // Скидка по купону if(isset($_SESSION['coupon_code'])) { $cart->coupon = $this->coupons->get_coupon($_SESSION['coupon_code']); if($cart->coupon && $cart->coupon->valid && $cart->total_price>=$cart->coupon->min_order_price) { if($cart->coupon->type=='absolute') { // Абсолютная скидка не более суммы заказа $cart->coupon_discount = $cart->total_price>$cart->coupon->value?$cart->coupon->value:$cart->total_price; $cart->total_price = max(0, $cart->total_price-$cart->coupon->value); } else { $cart->coupon_discount = $cart->total_price * ($cart->coupon->value)/100; $cart->total_price = $cart->total_price-$cart->coupon_discount; } } else { unset($_SESSION['coupon_code']); } } } } return $cart; } /* * * Добавление варианта товара в корзину * */ public function add_item($variant_id, $amount = 1) { $amount = max(1, $amount); if(isset($_SESSION['shopping_cart'][$variant_id])) $amount = max(1, $amount+$_SESSION['shopping_cart'][$variant_id]); // Выберем товар из базы, заодно убедившись в его существовании $variant = $this->variants->get_variant($variant_id); // Если товар существует, добавим его в корзину if(!empty($variant) && ($variant->stock>0) ) { // Не дадим больше чем на складе $amount = min($amount, $variant->stock); $_SESSION['shopping_cart'][$variant_id] = intval($amount); } } /* * * Обновление количества товара * */ public function update_item($variant_id, $amount = 1) { $amount = max(1, $amount); // Выберем товар из базы, заодно убедившись в его существовании $variant = $this->variants->get_variant($variant_id); // Если товар существует, добавим его в корзину if(!empty($variant) && $variant->stock>0) { // Не дадим больше чем на складе $amount = min($amount, $variant->stock); $_SESSION['shopping_cart'][$variant_id] = intval($amount); } } /* * * Удаление товара из корзины * */ public function delete_item($variant_id) { unset($_SESSION['shopping_cart'][$variant_id]); } /* * * Очистка корзины * */ public function empty_cart() { unset($_SESSION['shopping_cart']); unset($_SESSION['coupon_code']); } /* * * Применить купон * */ public function apply_coupon($coupon_code) { $coupon = $this->coupons->get_coupon((string)$coupon_code); if($coupon && $coupon->valid) { $_SESSION['coupon_code'] = $coupon->code; } else { unset($_SESSION['coupon_code']); } } } Edited October 24, 2017 by lexx790 Quote Link to post Share on other sites
yr4ik Posted October 24, 2017 Report Share Posted October 24, 2017 наличие у товара проставлено? Если да то похоже нужно искать проблему индивидуально. Если хотите обращайтесь в личку Quote Link to post Share on other sites
lexx790 Posted October 25, 2017 Author Report Share Posted October 25, 2017 При восстановлении бэкапа из админки, корзина работает. Пробовал сохранить tpl файлы из старого бэкапа и в вставить в последний вариант. Не помогло. Quote Link to post Share on other sites
lexx790 Posted October 25, 2017 Author Report Share Posted October 25, 2017 Всем спасибо. Каким то образом база данных полетела, откатили. Quote Link to post Share on other sites
crfxtr123 Posted September 14, 2019 Report Share Posted September 14, 2019 кто подскажет ?как настроить отправку в корзину для турбо яндексhttps://yandex.ru/dev/turbo/doc/yml/add-to-cart-docpage/#add-to-cart Quote Link to post Share on other sites
shooroop Posted September 14, 2019 Report Share Posted September 14, 2019 кто подскажет ?как настроить отправку в корзину для турбо яндексhttps://yandex.ru/dev/turbo/doc/yml/add-to-cart-docpage/#add-to-cart В Яндекс.Вебмастере перейдите на страницу Турбо-страницы → Настройки → Оформление заказа. Включите опцию Добавить в корзину. Выберите из списка пункт Другая. Сформируйте URL для добавления товара в корзину. В ссылке используйте адрес сайта и переменную {offer_id}. В переменную будет передаваться значение атрибута id (элемент offer) из YML-файла. Например, https://mysite.com/cart?id={offer_id}. Вам потребуется доработать сайт: На сайт придёт GET-запрос с ID товара. Вам нужно добавить этот товар в корзину и показать её. Укажите ссылку на обработчик. В ссылке используйте переменную {offer_id}, она заменится на ID товара (offer id в YML). Нажмите кнопку Сохранить и проверьте работу кнопки в примере Турбо-страницы. При нажатии на кнопку Добавить в корзину должна открываться корзина вашего сайта с товаром внутри. Если корзина не открывается, настройте редирект на страницу корзины со страницы, на которую ведет кнопка. Quote Link to post Share on other sites
tifoluf Posted September 15, 2019 Report Share Posted September 15, 2019 В Яндекс.Вебмастере перейдите на страницу Турбо-страницы → Настройки → Оформление заказа. Включите опцию Добавить в корзину. Выберите из списка пункт Другая. Сформируйте URL для добавления товара в корзину. В ссылке используйте адрес сайта и переменную {offer_id}. В переменную будет передаваться значение атрибута id (элемент offer) из YML-файла. Например, https://mysite.com/cart?id={offer_id}. Вам потребуется доработать сайт: На сайт придёт GET-запрос с ID товара. Вам нужно добавить этот товар в корзину и показать её. Укажите ссылку на обработчик. В ссылке используйте переменную {offer_id}, она заменится на ID товара (offer id в YML). Нажмите кнопку Сохранить и проверьте работу кнопки в примере Турбо-страницы. При нажатии на кнопку Добавить в корзину должна открываться корзина вашего сайта с товаром внутри. Если корзина не открывается, настройте редирект на страницу корзины со страницы, на которую ведет кнопка. Посмотрите как это было сделано вот здесь https://okay-cms.com/article/vyshla-okaycms-230 и сделайте по аналогии:Пункт. 4.1. 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.