mister Posted March 21, 2014 Report Share Posted March 21, 2014 Здравствуйте!Подскажите пожалуйста, как на странице подтверждения заказа (example.com/order) получить категорию товара для каждого из элементов заказа, чтобы использовать конструкцию вида: {foreach $purchases as $key => $purchase} {$purchase->category|escape} {/foreach} Прикручиваю электронную торговлю Аналитикс, все данные передаются кроме категории. Т.к. один и тот же товар может принадлежать разным категориям, то нужно получать только первую.Спасибо! Quote Link to post Share on other sites
Solution Виталий Анатольевич Posted March 22, 2014 Solution Report Share Posted March 22, 2014 в файл OrderView.php добавить код foreach($products as &$product){ $product->categories = $this->categories->get_categories(array('product_id'=>$product->id)); $product->category = reset($product->categories); } перед foreach($purchases as &$purchase) { это примерно 95 строка Quote Link to post Share on other sites
Виталий Анатольевич Posted March 22, 2014 Report Share Posted March 22, 2014 а в шаблоне {$purchase->product->category->name} category - обычный объект категории где есть name, id, url, path и т д Quote Link to post Share on other sites
mister Posted March 22, 2014 Author Report Share Posted March 22, 2014 Все прекрасно работает! Спасибо! Quote Link to post Share on other sites
дима Posted August 7, 2014 Report Share Posted August 7, 2014 (edited) На странице корзины можно вывести категорию товара добавив foreach($products as &$product){ $product->categories = $this->categories->get_categories(array('product_id'=>$product->id)); $product->category = reset($product->categories); } код в api/Cart.php перед foreach($items as $variant_id=>$item) { Edited August 8, 2014 by дима 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.