webrobert's avatar

Buy Later Feature

Wondering how you might go about implementing this feature. It’s for my shopping list app…

A user can “check off” an item for the current shopping trip and it will be there next time they go to shop unchecked.

My first thought is to add a datetime column to the item. Something like shop_for_after and just hide the item until after x time has passed.

Looking for alternatives in case I’m overlooking something more elegant.

Ideas?

0 likes
13 replies
MohamedTammam's avatar

Just to be more clear, are you talking about implementing cart feature?

webrobert's avatar

@MohamedTammam it’s not a cart. Think todo list except it’s items on a shopping list. It’s my personal shopping list app. The feature came about because sometimes you know you need an item but you don’t want to buy it until the next time. Not the current time. But you still want to check it off to clear the current list.

MohamedTammam's avatar

@webrobert In that case I would add a date column for checking it after.

Or link it to an action "When I have money" for example 😅

1 like
CamKem's avatar

I would add a new migration, model & controller called WishList or Favourites and have the fields as the following:

id
user_id
product_id
+ timestamps.

That is all you would need to do it.

Alternatively, you could consider using a package that handles these types of resources. A good one is Markable

Sinnbeck's avatar

The idea seems fine but I just want to understand the feature. If I buy milk, it will automatically appear after a week? But what if I go shopping 30 minutes before last week. Is it still hidden then?

webrobert's avatar

@Sinnbeck

Think todo list where you check the item and it disappears from view. Super simple nothing complicated.

Then as we need an item during the week we just search the item and un check it which essentially adds it back on our list of thinks to buy.

Then when we go to the store to do our shopping we walk the store checking items off as we add them to our basket.

What we found is there are times when we aren’t quite ready to buy the item. “We’ll get the milk next time, we still have some”

In this case I don’t want to actually check it off. I just want it to clear it from my current shopping trip.

So it’s more like, I am shopping and milk is on the list but I don’t want to buy it today. I want to “check it off” for this current visit BUT I actually still need milk. So I want it to be on the list for next time. I just want it out of the way for today.

And the Ui is super clean. So I am still working on an easy way to implement it from the user prospective. I’m considering a longpress when checking which triggers a method to add a day or some number of hours to that column. Which just removed the item. But by the time we shop again. (Think anytime that’s not now in the future) the item will be back on this list because it’s not actually been checked off and the time has passed

Wha I don’t like about this idea is it feels like I have a lot of empty date columns. Maybe I’m being overly concerned. I guess it just doesn’t feel as clean as it could be.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@webrobert ah yes I can relate to that. Then I think a date column would be a good idea. No need for an index I think. And I would just have a cron job to re add it to the list the next day

1 like
webrobert's avatar

@Sinnbeck, so that could work too, and then it doesn't have to be a date column, I could just add a second boolean buy_later which the cron clears everyday.

I wrote this app in a weekend, but it turns out we use it a lot, so im doing some new features and refactoring some of the code to clean it up. Spin it up if you want. its here...

https://github.com/webrobert/pantry

the two big requests from my wife are this one buy_later and to add a buy_at_(x)_store_next_time. I actually am just about to finish the buy_at_next_time feature.

Sinnbeck's avatar

@webrobert it's a great idea! We use Google keep but maybe we should try out yours at some point 👍

webrobert's avatar

@Sinnbeck, or contribute ;) ha.

Yeah I tried a bunch of them, google keep and so on, MOST apps id have to maintain a list for each store I shopped at. But for things we could get anywhere, milk for example, where does it go? So the lists end up out of sync. or there is a second list of items that we could get anywhere. I hated that. For Panty when I check off milk it clears it for however many stores I have included it on.

Sinnbeck's avatar

@webrobert yeah I will read the code later. Maybe I can add a bit :) how about web sockets to update all clients?

webrobert's avatar

@Sinnbeck ha! good catch, our current -sort-of-workaround- is only one of us checks items as we shop.

Sinnbeck's avatar

@webrobert yeah we do the same as keep is slow to update. Maybe a poll could do as a standin for now. But I have worked with websockets before if you need help

Please or to participate in this conversation.