Build Shopping Cart with OOP | PHP OOP Project

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 33

  • @sliceem88
    @sliceem88 4 ปีที่แล้ว +5

    I've realy waited, after all lessons , oop project.
    And here it is, nice!!

  • @corvandooren2248
    @corvandooren2248 4 ปีที่แล้ว +9

    Great tutorial!
    tip: It would be helpfull if you set View->Appearance->Description of Actions: ON, so we can see the shortcut keys you use.

  • @mmelimahlobo7656
    @mmelimahlobo7656 ปีที่แล้ว +1

    Hie Sir would you kindly do an ecommerce store with php OOP,but keeping it as simple as possible and well explained for beginners like me😊
    Thank you

  • @groovebird812
    @groovebird812 2 ปีที่แล้ว +2

    Hi, why do we need 2 different methods for storing products in the cart? We have cart->addProduct() and product->addToCart(). Wouldn't it be better if there was only one method to do that?

  • @mulletboi00
    @mulletboi00 2 ปีที่แล้ว

    The tutorial is extremely informative and great, thank you!
    I have several questions though:
    1. In CartItem class, increaseQuantity method, at 14:22 in the video, why aren't we using simply $this->getQuantity() instead of $this->getProduct()->getAvailableQuantity() ?
    2. In Cart class, removeProduct method, at 32:50 in the video, why not use just $item->getProduct() instead of using id of a product?
    3. I can't really understand how does php match items[$productId] to relevant array element. What is happening when we switch to associative array and how do we actually do that? Would be great if you could advise any resource to understand this point.

    • @TheCodeholic
      @TheCodeholic  2 ปีที่แล้ว +2

      1. $this->getQuantity() returns what is the quantity of the item into the cart. However $this->getProduct()->getAvailableQuantity() is what is the available quantity of this product. It total quantity of the product is 5 and initially you added the item with 4 quantity into the cart and then trying to increase the quantity with 2, it will not work because the available quantity is 1.
      2. Even though the IDs might be the same the object references might not be the same. That's why comparing IDs is more safe than comparing objects.
      3. I think you should read about associative arrays. This might help. th-cam.com/video/yXzWfZ4N4xU/w-d-xo.html

  • @flaapu_
    @flaapu_ 4 ปีที่แล้ว +3

    How can I do, if i want to do this and connect it with my data base?

  • @ankitsuthar526
    @ankitsuthar526 4 ปีที่แล้ว +3

    Keep it going sir, you are doing and adding good stuff.
    may god will increase subscribe and the like

  • @MuhammadBilal-ld1fi
    @MuhammadBilal-ld1fi 3 ปีที่แล้ว +2

    You need to show us a demo at the start of video so we understand code easily

  • @eugengeringer2746
    @eugengeringer2746 4 ปีที่แล้ว +1

    Well done!!! I'ld be happy to see more PHP Projects.

  • @corvandooren2248
    @corvandooren2248 4 ปีที่แล้ว +1

    Question: wouldn't it be more correct if the quantity is decreased to 0, to remove the product from the cart instead of throwing an exception?

    • @TheCodeholic
      @TheCodeholic  4 ปีที่แล้ว +1

      Thanks good point. Yes, maybe

  • @emekatimothyiloba699
    @emekatimothyiloba699 ปีที่แล้ว

    Thanks for Creating this Video

  • @NZ006
    @NZ006 4 ปีที่แล้ว +2

    if decreaseQuantity is < 1 it should remove from cart.

  • @Matex__
    @Matex__ ปีที่แล้ว

    Whats the difference between addPorduct and addToCart methods?

    • @TheCodeholic
      @TheCodeholic  ปีที่แล้ว

      They do the same thing, but addProduct is a method of cart class and addToCart is a method of Product class.

  • @raadkasem
    @raadkasem 2 ปีที่แล้ว

    Thank you, Great content.
    Q: how can i do Buy 1 get 1 Free in my cart?

  • @shogaita
    @shogaita 2 ปีที่แล้ว

    Hi let me know the name of extension which you used at 6:08.

  • @rajabhishek4973
    @rajabhishek4973 4 ปีที่แล้ว +1

    Awosem .can make video how to creat slot type booking in php means aapointmmet system

  • @kacperkepinski4990
    @kacperkepinski4990 2 ปีที่แล้ว

    How to generate code?

  • @calmyourmind5617
    @calmyourmind5617 3 ปีที่แล้ว

    Where is the website ?

    • @tomkaidl
      @tomkaidl 2 ปีที่แล้ว

      It that teminal :-)

  • @Raezon_
    @Raezon_ 4 ปีที่แล้ว +2

    awsome

  • @pasizdobrekuce
    @pasizdobrekuce 4 ปีที่แล้ว +2

    Thanks man. 👍👍👍

  • @kalcas33
    @kalcas33 4 ปีที่แล้ว

    Can someone explain me how does it work :
    $cartItem2->increaseQuantity();
    $cartItem2->increaseQuantity();
    I see $cartItem2 is variable which is not an object, right? So how it's possible that we can use here method increaseQuantity() and it works?
    I have an error when it comes to those lines:
    Fatal error: Uncaught Error: Call to a member function increaseQuantity() on null in C:\xampp\htdocs\dashboard\serwer\PHPCartOOP-master\index.php:30 Stack trace: #0 {main} thrown in C:\xampp\htdocs\dashboard\serwer\PHPCartOOP-master\index.php on line 30

    • @johndoe-rv3to
      @johndoe-rv3to 4 ปีที่แล้ว

      Didn't watch the video but it could work because he wrote it like this:
      $cartItem2 = new CartItem();
      this will give access to the protected and public methods of the class CartItem in $cartItem2. So he can then write $cartItem2->increaseQuantity()

    • @OnlyJavascript
      @OnlyJavascript 3 ปีที่แล้ว

      cartItem2 is an instance of Product class which has access to addToCart() function. Function accepts two attributes. Cart object and quantity. now it can have access to increaseQuantity(). That way it works. OOPs is way complicated than we thnk. lol. correct me if I am wrong.

  • @mmelimahlobo7656
    @mmelimahlobo7656 ปีที่แล้ว

    We would really appreciate if you could explain your code sir,you are just coding and some if cannot follow😢

  • @Kodeispoetry
    @Kodeispoetry 3 ปีที่แล้ว

    Please provide code sir.

    • @TheCodeholic
      @TheCodeholic  3 ปีที่แล้ว +2

      I just updated the description with source code links.

  • @Yusuf-yt3sf
    @Yusuf-yt3sf 3 ปีที่แล้ว

    ♥♥♥