sergeevizh Posted July 17, 2019 Report Share Posted July 17, 2019 Привет! Подскажите как сделать, чтобы комментировать могли только те, кто купил этот товар. То есть, если заказ клиента ( авторизованного ) перешел в статус "Выполнен", то на странице купленного товара происходит проверка, что такой товар он приобрел и ему будет доступна форма комментариев, а гости могли только читать. Quote Link to post Share on other sites
Solution chocolate_moles Posted July 17, 2019 Solution Report Share Posted July 17, 2019 (edited) Привет! Ну например это в view/ProductView.php if($this->user) { $query = $this->db->placehold(" SELECT COUNT(p.product_id) as count FROM __purchases p LEFT JOIN __orders o ON o.id = p.order_id WHERE o.status = 2 AND o.user_id = ? AND p.product_id = ? ", $this->user->id, $product->id); $this->db->query($query); $this->design->assign('can_comment', $this->db->result('count')); } И в файле шаблона сделать проверку {if $can_comment} форма для комментария {/if} Edited July 17, 2019 by chocolate_moles Quote Link to post Share on other sites
sergeevizh Posted July 17, 2019 Author Report Share Posted July 17, 2019 Ну например это в view/ProductView.php if($this->user) { $query = $this->db->placehold(" SELECT COUNT(p.product_id) as count FROM __purchases p LEFT JOIN __orders o ON o.id = p.order_id WHERE o.status = 2 AND o.user_id = ? AND p.product_id = ? ", $this->user->id, $product->id); $this->db->query($query); $this->design->assign('can_comment', $this->db->result('count')); } И в файле шаблона сделать проверку {if $can_comment} форма для комментария {/if} Спасибо! Куда кинуть на кофе? Quote Link to post Share on other sites
chocolate_moles Posted July 17, 2019 Report Share Posted July 17, 2019 (edited) Спасибо! Куда кинуть на кофе? https://money.yandex.ru/to/41001619273768https://www.paypal.me/chocolatemoles Edited July 17, 2019 by chocolate_moles 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.