Open Alys opened 6 years ago
The user should still be able to view the details modal of the item, but the Buy Now button should be disabled with a small bit of text that the item is unavailable. Here's a screenshot:
This bug also occurs for pinned seasonal greeting cards as reported by @ravenlune (9272ab2c-4b66-4b74-aebd-799725885d1c):
"I believe the Valentine's Day event is over now, right? The Valentine's card is still pinned to my Rewards... on the website, I was able to successfully send it to a party member."
The fix should be the same as Tressley describes above. I'm about to edit this issue's title to include cards
Hi, I'd like to try my hand at investigating this issue
@somersjw I'm sorry it's taken us so long to reply! I've marked this as in progress for you but if you've found something else to do in the meantime, tell us and we'll set it back to help wanted.
If you have any questions or run into trouble, post here and we'll try to reply faster!
@somersjw Hi there! Are you still interested in working on this? I'll mark this as help wanted again in about a week if we don't hear back. :)
@somersjw I'm marking this as help wanted again, but if you'd like to pick it back up, please just let us know!
I can take a look at this.
Are seasonal items the only items that have an 'event' object?
Thanks.
@qrdean Thanks! I've marked this as in progress for you.
Are seasonal items the only items that have an 'event' object?
Not exactly. A git grep
through the content for "event" (with a couple of normal greps to narrow it down to just content data) shows that there's a few others:
git grep event | grep content | grep -v /locales/
website/common/script/content/gear/sets/special/index.js:151: event: EVENTS.birthday,
website/common/script/content/gear/sets/special/index.js:443: event: EVENTS.gaymerx,
website/common/script/content/gear/sets/special/index.js:1607: event: EVENTS.nye,
website/common/script/content/gear/sets/special/index.js:1946: event: EVENTS.gaymerx,
If that causes any problems for the solution you develop and you're not sure how to deal with it, post here (also post if you have any other questions).
Thanks for that! Yeah I think that throws my original idea of just checking the event out the window.
I'm looking at exposing the value returned from the canBuy function that appears on some item structures. This will allow the front end to use the canBuy function that seasonal items and specialty items already have to tell us if that item is purchasable. The front end can then respond with a disabled button and text that tells the user that the item isn't available.
Is there a reason some items do not have this function on their structure? Is it assumed those items can be bought? Also, it looks like the default return value for canBuy() on Gear is false. So for all gear that does not have the canBuy function I would add it and allow the canOwn() function to verify it.
@Alys just to be sure, this is a client side only issue, right?
I'm not sure. I didn't get a chance to test through the API today but I'll try to tomorrow!
My testing will have to slip to tomorrow, sorry. I have an early start at work so I need to get to bed early. I'll have an early finish though so I'll definitely have time to test this bug with the API tomorrow.
@paglias I guess you can say it happens with the API as well, although that's not as significant a problem.
Steps I took to test the API's behaviour:
pinnedItems
array: { "path": "hatchingPotions.Fairy", "type": "hatchingPotions" }
"locked":false
implies that it can be bought.
{"key":"Golden","text":"Golden Potion","notes":"Pour this on an egg, and it will hatch as a Golden pet.","class":"Pet_HatchingPotion_Golden","value":5,"locked":false,"currency":"gems","purchaseType":"hatchingPotions","path":"hatchingPotions.Golden","pinType":"hatchingPotions","isSuggested":false,"pinned":true},
{"key":"Fairy", "text":"Fairy Potion", "notes":"Pour this on an egg, and it will hatch as a Fairy pet.", "class":"Pet_HatchingPotion_Fairy", "value":2,"locked":false,"currency":"gems","purchaseType":"hatchingPotions","path":"hatchingPotions.Fairy", "pinType":"hatchingPotions","isSuggested":false,"pinned":true},
I.e., if you use the API's route to show you your pinned items, it looks as if you can buy the off-season Hatching Potion, just as it does on the website. I don't know if we want to fix that? I guess we'd need to have a new parameter in the data for off-season potions to indicate that they can't be bought. Unless we can use the locked
value for that.
I think having some sort of data in the API showing if an item can be bought or not would be very useful especially for the mobile apps and also to avoid having to calculate the availability on the various client sides. Not sure if locked
is the best option here or would be confusing, we seem to have several properties that could be used including canBuy
@qrdean Hi! Are you still working on this issue? If not, or if we don't hear from you within seven days, I'll mark this as help wanted again. :)
I've set this back to "help wanted" since we didn't get a reply!
Related to #9899 and likely will require close handling.
I think this has been addressed with recent Gala event code overhauls. @Alys does something remain to be addressed re this ticket?
I've just tested by pinning a Polka Dot Potion using a database command to update my pinnedItems array. It does look purchasable. Below are screenshots from my Rewards column.
Also occurs for pinned Quest Bundles so I've added them to the title.
(The countdown is wrong too but that's reported at https://github.com/HabitRPG/habitica/issues/13318)
If you pin a Magic Hatching Potion to your Rewards list, when that potion is no longer available for purchase, the pinned item acts as if you can still purchase it. You can click on it, select the number to be bought, and then confirm the purchase. You see a message saying that you've bought the Potion(s).
However the Potions are not actually added to your Inventory and the Gems are not subtracted. This part is correct (outside the approved time for the Potions, you are not meant to be able to buy them).
The desired behaviour is something like one of these:
That behaviour should be automatic as soon as the approved time for the Potion has ended so the code should read that date from Habitica's config for the Potion.
Regardless of how this fix is implemented, the user should always be able to unpin the item when they choose to (or leave it pinned permanently if they prefer that).