-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use a custom table instead of user metas #22
Comments
I prepared a lookup table implementation https://gist.github.com/mircobabini/c694770e217e483b249be9941eb07ff3 Todo: update lookup table's row when a code is claimed. |
In #18 , there is a proposal to save the gift code that is purchased during a checkout in order meta. If we go with that approach, the process to find the order with a given order meta and then find the purchaser for that order should not be too bad. |
This is good. Since I have a production website with 500+ gifts generated, which heavily relies on this feature (implemented with the additional lookup table), I think I can work on this one and provide a PR. I will change the current logic to use order metas (🎉 first implementation using order metas afaik!) so we already have a live website to make tests. To be defined:
|
We would have 3 order metas:
|
I think the only order meta that we really need is the Once that meta is in place, you can get the giver's user ID by finding the order associated with a gift and getting the
The order meta table has been out for around 9 months now, so hopefully there aren't too many sites without this functionality. I don't think it's worth building out new functionality only for people who haven't updated PMPro in the last 9 months since not associating gift codes with orders is how the plugin currently woks anyways. We should just check that the PMPro version > 2.5 before running the order meta code.
I don't think that there's a great way to tie old gift codes to their respective orders. In order to find the order that was likely used to purchase a gift code, we would need to:
This process can run into issues if multiple gift codes were purchased on the same day or if the start date of the code or the order date is changed. Perhaps a quicker solution would be to add a field to the "Edit Order" page for admins to manually link a gift code to the order, though this would not be sufficient for larger sites. Happy to keep discussing if you have other ideas. |
Is your feature request related to a problem? Please describe.
There's no way to check who generated a gift. The
pmprogl_gift_codes_purchased
is serialized so no lightweight reverse lookup. This is not a good approach on high traffic websites with thousands of users/orders.Describe the solution you'd like
I would implement a
pmpro_gifts
table with at list:discount_id | giver_user_id | receiver_user_id (to be set when claimed)
The text was updated successfully, but these errors were encountered: