Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public function addToCart(Disc $disc)
  2. {
  3. $getCart = $this->session->get('cart');
  4.  
  5. if(isset($getCart[$disc->getId()]))
  6. {
  7. $getCart[$disc->getId()]['quantity']++;
  8. }
  9. else
  10. {
  11. $getCart[$disc->getId()] = array(
  12. 'quantity' => 1,
  13. 'title' => $disc->getTitle(),
  14. 'price' => $disc->getPrice(),
  15. 'id' => $disc->getId(),
  16. );
  17. }
  18. $this->session->set('cart', $getCart);
  19. return renderCart();
  20. }
  21.  
  22. public function renderCart()
  23. {
  24. $getCart = $this->session->get('cart');
  25. return $this->render('discs/cart.html.twig', array(
  26. 'cart' => $getCart
  27. ));
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement