Skip to content
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

Missing method #4

Open
projct1 opened this issue Sep 2, 2015 · 5 comments
Open

Missing method #4

projct1 opened this issue Sep 2, 2015 · 5 comments

Comments

@projct1
Copy link

projct1 commented Sep 2, 2015

I have to calculate total sum for each item $item->quantity * $item->price...

@fhusquinet
Copy link

I agree on this one, it would be an easy method to create and would simplify the templates a lot.

@anam-hossain
Copy link
Owner

@fhusquinet, @rorc is this a good approach to add the total in each item. For example:

use Anam\Phpcart\Cart;

$cart = new Cart();

$cart->add([
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 2,
    'price'    => 90
]);

$cart->get(1001);
// This will return item with total
[
   'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 2,
    'price'    => 90,
    'total' => 180
]

@fhusquinet
Copy link

@anam-hossain If the total is updated at the same time the quantity is then that sure would be a great approach.

@anam-hossain
Copy link
Owner

@fhusquinet Total will be updated during adding and updating an item.

Do you think this will conflict with user content? i mean they can not add total to their own.

@fhusquinet
Copy link

@anam-hossain I hadn't considered that...
A simple $item->getTotal() since the user currently sets every value of an item himself. Although I wouldn't mind it myself, this might indeed throw of some users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants