phpcart
phpcart copied to clipboard
Missing method
I have to calculate total sum for each item $item->quantity * $item->price...
I agree on this one, it would be an easy method to create and would simplify the templates a lot.
@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
]
@anam-hossain If the total is updated at the same time the quantity is then that sure would be a great approach.
@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.
@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.