-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to extend the CartItem class #124
Comments
You could add a custom Macro within a service provider, since the Macro trait was added to the Cart class. This is what I use for example:
Hope this helps |
Hi @johnthart, Yes, you are right. But this has the same effect than using an extended class for Cart. What I see complicated is modifying the CartItem class. |
Sorry, you're right. Didn't read far enough. |
Hi @johnthart , No problem. But I think, if possible in a next expansion, it would be fine to change the variable $discount and $taxRate to protected. So we could use functions like total() in an extended Cart class. I would also appreciate if extending the CartItem class were possible. |
Why the close? I think this is a valid issue :) If you can, please reopen so we can keep track of it 👍 |
OK! @bumbummen99 😊 |
I have successfully extended the Cart class by adding a new service provider and binding the default class to my custom class:
|
To extend class CartItem I have repeated the same process but the result has not been satisfactory. I have not gotten Laravel to read the new class
This is not working for me. Does anyone figure out why? |
Hi,
The package seems very powerful to me, congrats.
I understand that you cannot satisfy everyone by adding new functions, each e-shop is different and many require almost unique solutions. I mean, an example is a function to calculate the price of the cart + shipping. Each one needs to do it in a different way. I managed to extend the Cart class to add it but I also have other needs such as doing calculations on each product which are not included in the original package. This requires extending the CartItem class and it is not that simple, at least I have not succeeded (it is also true that I am quite noob). Maybe in the same way one can customize the default calculator?
That is why I think it would be interesting to open the possibility of extending the classes in a simple way, to avoid rewriting the package and adapting it to each e-shop. Actually, in my case it would be necessary to include just two functions, the package is very complete.
The text was updated successfully, but these errors were encountered: