moltin / laravel-cart

Laravel Facade and Service Provider for Moltin\Cart
276 stars 87 forks source link

Sorting cart items #9

Closed pveyes closed 10 years ago

pveyes commented 10 years ago

Is there any way to sort cart items based on item property? In the current implementation, sorting is based on insert time (identifier). Is there any way I could change this behavior?

chrisnharvey commented 10 years ago

Hi,

You could use a custom implementation of the storage driver and inject that into the Cary object. Then sort your items in there and return that to the Cart object.

Take a look at the data method in bye storage drivers.

Sent from my iPhone

On 31 Dec 2013, at 04:10 pm, Fatih Kalifa notifications@github.com wrote:

Is there any way to sort cart items based on item property? In the current implementation, sorting is based on insert time (identifier). Is there any way I could change this behavior?

— Reply to this email directly or view it on GitHubhttps://github.com/moltin/laravel-cart/issues/9 .

pveyes commented 10 years ago

Hi,

Thanks for the tips. I'm from CI and in CI to extend a function I just create Extended Class and it will automatically overwrite the old function

As in Laravel, this is implemented using Service Provider. So should I just create my custom Service Provider implementing new Storage driver and then give them alias in app/config/app.php or is there better way I could implement this?

chrisnharvey commented 10 years ago

The service provider approach is probably the best approach for this. Just use your own service provider and implement your own storage driver.

P.S: Sorry for the late response.

chrisnharvey commented 10 years ago

I'm going to close this for now. I'll reopen it if we decide to implement sorting in the future.