Active
Project:
Ubercart Discount Coupons
Version:
6.x-1.7
Component:
uc_coupon_register
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Sep 2011 at 13:15 UTC
Updated:
17 Dec 2012 at 11:14 UTC
Jump to comment: Most recent file
Comments
Comment #1
wodenx commentedNot currently possible, and complicated due to the nature of coupon restrictions. What information do you need to import?
Comment #2
kaido.toomingas commentedSame question. Can I import external coupong codes somehow.. Can you see some way... I thought I should write some module to import these but I havent understood jet whats going un :p
Comment #3
wodenx commentedAgain, what data do you need to import? Each coupon has a variety of settings, how would you like those to be handled?
It should be relatively easy to write an import module - just print_r a loaded coupon, recreate it from a parsed csv, and call uc_coupon_save() to save it to the db.
Comment #4
kaido.toomingas commentedThanks for a reply.. In my case there is just list of cuopong codes to use. No settings are included. Kind of similar to this one what this module output when I export csv. About settings.. No idea yet..
Comment #5
wodenx commentedSo then you have to decide what default values you'd like for all the settings (eg name, discount, expiration, product restrictions, etc.)
Comment #6
kaido.toomingas commentedScreenshot about this how do I see it..
Comment #7
kaido.toomingas commentedOr even better way to handel this.. I took a dev version and Ill try to implement this :)
Comment #8
kaido.toomingas commentedOk as I see there is one value allways stored and else is md5 genereated.. So Im not sure I can even do it ..
Comment #9
wodenx commentedI see. Unfortunately, what you'd like to do is not easy. Bulk codes are implemented by an algorithm - they cannot be specified individually - see uc_coupon_get_bulk_code().
The only way to do this would be to rewrite the handling of bulk codes throughout the module, which could be quite complex.
The alternative would be to create a new coupon for each imported code - i suppose you could use a base coupon to specify the attributes, and then clone that coupon once for each code.
Comment #10
kaido.toomingas commentedI thought this throught.. Ill make an other simple module. :)
Thank you.
Comment #11
wodenx commentedIf you think your module would be useful to others, please post it here for review - perhaps it can be included as a submodule.
Comment #12
kaido.toomingas commentedToday I got full requirements and they will be build api from other site and all the data will be checked every time over the web.. So your module doesnt work at this time for me. Still I thought this trought and I see how this could be handled.. As you said we should reuse settings.
So I see this like that. Submenu + form for bulk upload. Also there must be UI for settings wich will use your code as much as possible. After these are uploaded there should be also bulk delete option. I am not sure does it work exactly this way but there is coupon name. I see this one as identifier for this bulk uploaded cupon codes.
What I mean is I we create then there is multiple coupon names and if we would like to delete then we write query delete from where coupon name = coupon name.
And all the other stuff could work as usual..
Comment #13
wodenx commentedJust glancing through the code, I think there might be a better way. What if there were a hook_uc_coupon_find($code) which would allow custom modules to implement their own association of code with coupon?
Then your module could simply keep a table linking code to coupon-id, and implement this hook.
You could even write it such that it pulled data from an external server and modified the coupon object accordingly. Perhaps this would work for your use-case.
I haven't tested this, but it should be pretty easy to work up a patch to the module and try it out.
Comment #14
wodenx commentedHere's a patch which adds the following hook:
Hook is invoked in standard module weight order, and the last coupon found is returned. Let me know if this is of use.
Comment #15
kaido.toomingas commentedSo whats the workflow after I got this right code. :p I thought I am soo smart but coulnt do it..
I can do it just like add product as voucher easily but this seems to be hard when I first look at this.. I can do it until this place..
// now we know the right id and we can add this as arg.
function say_this_coupon_system_its_ok() {
function_name('my_right_id');
}
Comment #16
maksim24 commented+1 subscribe kaido24
Comment #17
wodenx commented@kaido24 - Sorry - I don't quite understand your question in #15. What is the context of that code snippet? Basically, you should apply the patch from #14 and then implement the hook to load and return the right coupon for the supplied code. Once the correct coupon is loaded, you don't need to do anything else.
Comment #18
danieldan commentedIs there anything to use with Groupon, Living Social, etc. that allows us to import a coupon code list (.csv) that they supply? As mentioned above being able to delete the same list once it's expired would be nice so that it doesn't clutter the coupon code list. I'm pretty sure I'm not the only person that wants to run a Groupon for my site. This thread seems to be on the right track. Does anyone have a coupon code list from Groupon or Living Social that we can use to create a template?
Comment #19
LeeWallisUK commentedThis is becoming more and more desired now that the market is full of sites like Groupon, LivingSocial, KGB Deals etc and merchants need a way to import coupons which have been provided by the Deal sites.
Is this feature ever going to happen?
It would be a fantastic feature to add!
Comment #20
wodenx commentedI have no time to implement this right now -- this thread outlines a fairly straightforward methodology for doing this with an external module, or if someone posts a patch I'll be glad to review it.
Comment #21
djg_tram commentedCould you then just commit this patch of yours (now preferably to the 7.x version, actually), so that a modification won't get overwritten with the next update? Thanks a lot.
Comment #21.0
djg_tram commentedthanks