The idea here is that instead of just a textfield with a default price, it would be sweet to be able to specify a list of prices that are turned into options for a radio select. It would be good, too, to have an option for "specify your own price" that would still allow the customer to enter any price using the textfield.
Not in the original scope of the module, but a worthy feature for the future.
Comments
Comment #1
Garrett Albright commentedHas anyone started working on this? It looks like a client is going to need this, so I was going to go ahead and work on it, but duplicating effort is no good.
Comment #2
rszrama commentedNope, this isn't in development at all. If you can put a good patch together, that'd be awesome!
Comment #3
Garrett Albright commentedWell, "good patch" is relative, isn't it? :)
Here we go. Store admins can allow values to be selected from a list (either radio buttons or a drop-down menu), arbitrarily (customers enter a value in a text field - as it is now), or both. In the case of both, the last option in the drop-down menu/radio buttons will be "Other…", which, when selected, causes the arbitrary value field to appear. (I created a new JavaScript file for this because I'm not sure on the best practices with regards to putting admin-only JavaScript code in the same file with customer-facing code…) I had to add more fields to {uc_varprice_products}, so there's a new hook_update_N() in the .install file and you'll want to run update.php after patching.
This patch also includes the patch in #471858: Missing FAPI validation for min/max prices when adding a varprice item to your cart (but not #478796: Add to cart title not being used.), and also fixes an issue I noticed with rows not being deleted from {uc_varprice_products} not being deleted when their associated node is deleted.
We're gonna have to clear some space in here, because our client is going to be doing backflips.
Comment #4
Garrett Albright commentedI kept telling myself not to forget to change the status before saving the post. But of course I forgot it anyway.
Comment #5
Garrett Albright commentedMinor bug fix, plus hook_uninstall() cleans up after itself a little better.
Comment #6
geocalleo commentedGarrett, I just want to say that you're an amazing human being! Thank you very much for doing this. I would imagine that there is a lot of demand for this type of feature. I sure can use this across multiple sites. Well, once again, thank you very much!
Comment #7
johnhanley commentedGarrett, I second geocalleo. This patch suited my client's requirement exactly. Props to you for assembling it. This should definitely be rolled into the next release.
Comment #8
johnhanley commentedUnfortunately I spoke too soon.
I'm using Drupal 6.15 and Ubercart 6.x-2.2.
I successfully applied the patch in #5 to 6.x-1.0-rc3 of uc_varprice.module and the selectable price fieldset and form elements appear on the Product Features page as expected.
I then proceed to do the following:
1) Tick the "Enable selectable variable prices" checkbox
2) Select "Radio buttons" and input my options:
5
10
25
50
100
250
500
3) Tick the "Enable arbitrary variable prices" checkbox w/o Minimum/Maximum price amounts.
4) "Add to cart form element titles" checkboxes unticked.
Upon clicking "Save feature" the following error occurs:
The criteria in description for type "Variable price" is correct:
Customers can specify a price for this product.
Default price: $0.00
Customers may select a price from a list.
Selectable prices: $5.00, $10.00, $25.00, $50.00, $100.00, $250.00, $500.00
Prices are selected with radio buttons.
Customers may enter an arbitrary price.
However when editing the Product Features page all the form fields are blank EXCEPT for "Default price". (Sidebar: I actually want the default value to be 0, but I entered a different value for testing purposes.)
On a related note, the donation form fields do not show up on the product page (presumably for the same reason, but no runtime error is shown.)
Comment #9
scotwith1tI had the same issue and, unfortunately can't remember what I did to fix it...but this module with the patch is a God-send for donation applications. Thanks again Garrett!!!
Comment #10
abaddon commentedvery easy actually, you need to run your update.php :-))
spoken too soon, anyway, ive also edited uc_varprice/uc_varprice.module
line 381 should be like this
(notice the && $data->sel_options)
Comment #11
abaddon commentedive also run into an issue with products not having varprice enabled
i got an error like "You must specify a price." when adding a product to cart
the patch below is a diff of my fix and the _original_ uc_varprice.module, you just need to add that IF in the mix..
Comment #12
patcon commentedIf you're having problems overwriting "Add to cart" button text, check this out:
http://drupal.org/node/478796
Diff is relative to original, so the change is around line 107 with the patch in #5
Comment #13
capellicWORKS GREAT!
1. I applied the patch to the 6.x-1.0-rc3
2. I ran update.php
3. I then altered the code per #10
, though I didn't see a need to apply #11.4. I then altered the code per #11.
THANKS!
Comment #14
scotwith1tman, i love this community. this just saved me hours of pulling my hair out. thanks abaddon and garrett for these patches, i can't thank you enough...one day i will grab hold of all this php stuff and begin to give back, i swear it!
Comment #15
devkinetic commentedI went ahead and aggregated all of the fixes in this thread into a definitive patch. Tested and confirmed working.
Comment #16
devkinetic commentedI would like to point out that having the ability to add a description for each donation amount. In the settings this could be entered like so:
25|Food for 1 Week
50|Food for 2 Weeks
100|Food for 3 Weeks
I started looking at the code for adding this functionality and it seems feasible. The code would have to be modified to accept an associative array in validation and also to print it out in the node.
Comment #17
artatac commentedgetting the following error after applying patch and enabling the module for the first time. > created a new product > Features > variable pricing > add prices 10, 20, 50 then save, resulted in
Comment #18
artatac commentedI did not have the module installed so did not think I would need to run update.php. When I DId run it I got the message
and it now works - hope this may help others
Comment #19
kvvnn commentedCheers cheers cheers !
Comment #20
IFL Todd commentedIt works; but, no matter how I apply the patch, I get characters like: Ķ in the patch. I'm on Mac OS X using terminal to patch.
Comment #21
IFL Todd commentedHere's add_to_cart_btn.patch & uc_varprice_radios.patch rolled into one patch.
NOTE: Still need to run update.php after applying the patch, regardless of whether you're updating the existing installed module with the patch, or you're installing the patched module as a new install.
Comment #22
sheldon rampton commentedI've updated the patch to support customizing the display text for each donation amount, along the lines suggested in comment #16 above by devkinetic. You would enter the settings like so:
25|Food for 1 Week ($25)
50|Food for 2 Weeks ($50)
100|Food for 3 Weeks ($100)
Thanks to everyone for working on this. It's saved me a ton of time. I hope this patch gets committed. It really enhances the module's functionality.
Comment #23
sheldon rampton commentedI've done a further update to the patch, because I've encountered a need to actually display separate options for the same price. The above syntax still works, but with this new patch it is now also possible to add a colon, followed by a "uniqueness key," after the price and before the pipe character. You can therefore do something like this:
100:Newsletter silver|Silver newsletter sponsorship ($100)
250:Newsletter gold|Gold newsletter sponsorship ($250)
500:Newsletter platinum|Platinum newsletter sponsorhip ($500)
100:Annual fund drive silver|Silver annual fund drive sponsorship ($100)
250:Annual fund drive gold|Gold annual fund drive sponsorship ($250)
500:Annual fund drive platinum|Platinum annual fund drive sponsorhip ($500)
This will produce six radio buttons that let donors choose not only different prices but different purposes for their donation.
Comment #24
irk commentedThis is rather minor, but after I ran the patch I found lines 54 and 88 in uc_varprice.module have a special character (…) instead of ellipses (in fact, the character seems to be prevalent in comments too, but that shouldn't matter). In Firefox when I view the page it displays a question mark instead of ellipses. So I went into .module and removed the character, then ran update.php. This is the only way I've found to customize the "Other" input text.
In any case, the special ellipses character should probably be three separate periods instead.
(I don't really code modules or anything so I can't make many further suggestions. Thank you for the patch! The functionality is exactly what my current site needed. )
Comment #25
Garrett Albright commentedThree periods for an ellipsis?! irk, such disregard for proper typography!
The HTML entity to generate an ellipsis is
…. May I suggest using that instead?Comment #27
johnhanley commented@Sheldon Rampton,
Thanks for consolidating all the various fixes and enhancements into one patch. It's nice to see this module getting a little love after months of neglect.
Everything works as described EXCEPT for one thing. According to the helper text, "If the value entered in the “Default price” field above matches one of these values, that option will be the default value of the price selection widget." I have been unable able to get this to work as described. I entered a default price of "25.00", which exactly matches one of my "Selectable Prices" amounts. However, the default radio button is still "Other...".
I haven't looked at the code (short on time and budget). Any suggestions?
Thanks,
John
Comment #28
scotwith1ta couple questions:
- is this going to be committed to a dev release or to a new 2.x branch at some point? or even as a new module (uc_arbprice or something)? it would make it a lot easier to submit issues about this particular version of varprice than this issue being strung along indefinitely...besides, I'm sure there are many folks who'd find this incredibly helpful
- is there anything that makes this incompatible with uc_recurring? i'm particularly interested in this for recurring donations of a user-specified amount for non-profits and churches, so i'd like to know about that. i've got a fresh install of D6.20, UC 2.4 and uc_recurring-2.0-alpha5 (tried their dev too) with nothing enabled that's not required and it doesn't seem to work...strange thing is that i've used the 2 in conjunction before.
Thanks!
Comment #29
IFL Todd commentedWhat is to become of these proposed patches?
I noticed that the latest release, uc_varprice-6.x-1.0, doesn't contain the patches proposed here.
Please advise & thank you,
Todd
Comment #30
kthullsubscribing
Comment #31
sheldon rampton commentedI've re-rolled the patch as a git patch against version 6.x-1.0. (The previous patch was made against 6.x-1.0-rc3.)
Comment #32
jrust commentedThanks for all the good work on this one. Pushed the patch.
Comment #33
jrust commentedIf someone wants to port this to 7.x I'll happily put it in, but otherwise it could be awhile before this makes it to 7.x. You can see the conflicts that need to be resolved via:
Comment #35
sk2013 commentedIs there any port to 7.X
Thanks