Closed (fixed)
Project:
Ubercart Discounts (Alternative)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Jan 2011 at 15:23 UTC
Updated:
28 May 2014 at 14:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jrust commentedIf someone builds it there will be one sooner than later, but at this point there is no development in that direction since Ubercart 3 hasn't been released.
Comment #2
RikiB commentedI am also very looking forward to a D7 version.
Comment #3
OldAccount commentedI'd also be very interested in a D7 version.
Comment #4
jerry commentedSo would I; subscribing.
Comment #5
mattm007 commentedsubscribing, this is really needed
Comment #6
jpdaut commentedI need it too. Subscribing
Comment #7
jens peter commentedI would be interested in a Drupal 7 + Ubercart 2 version.
Do anyone plan on making this version any time soon? I am planning a new shop and would like to go from Drupal 6 to 7 and this is the only module (or a similar discount module) I am missing to be able to do so.
Comment #8
strep commentedWill continue development of the module? Need for Drupal 7 discount. Will the patch at least in the near future?
Comment #9
landylan commentedSince I like this module very much and need it to be on D7, I tried to make some modification with the help of Corer module.
Here's the modified code...
BTW, I've modified some code which I think there're bugs. I'm not so sure, maybe need some discuss later....
Comment #10
landylan commentedI didn't use "'UC discount Coupon" module before, but I guess that the "'UC discount Coupon" module could almost be replaced by "UC discounts alt" module. Is it right?
Comment #11
jrust commentedI've never used the coupon module, but I have to imagine it could be given how robust the coded discount feature is in discounts alt.
Please let us know what the bugs are that you fixed. I would rather those be posted as seperate issues if possible so that 6.x and 7.x can be kept as in sync as possible and so that we know exactly what is changing. This module, is unfortunately so complex that small changes can easily affect certain types of discounts.
Comment #12
jrust commentedComment #13
landylan commentedI'm working on an urgent case, so I'll leave message here and hope it helps.... ^_^
uc_discounts_alt.module:
That's it.
Comment #14
landylan commentedOh, there's a bug in uc_discounts_alt.admin.inc:
BTW, I use 6.x-2.x-dev as my reference.
And here are some question....
1. get_role_ids_for_discount() was not used in get_product_ids_for_discount_object(). Is there any concern?
2. In order to avoid "discounts more than 100%" for each product, could we add a variable $order_product_id_total_discount_amount_map in the begining of function get_discount_for_order(), to record the total discount amount of each product and check later if there's product got discount more than 100%? $total_discount_amount do the simular jobs. I know that some discounts was for entire order, but we can take the average and put it into each product...
I did not look through all the open issue of this module. Sorry if I mention some duplicated issue...
Comment #15
jrust commentedThanks for the updates.
1. I'm not sure about the get_role_ids_for_discount() without testing -- but if it's working without it then I imagine it's fine to remove.
2. That is a longstanding issue (#502212: Don't Allow Negative Balances), so if you find a good solution that works for all the discount types all the better.
Comment #16
landylan commentedI'll put my opinions to that post. Thanks.
Comment #17
strep commentedI tried this package for Drupal 7 from #9. I need to set a percent discount customer group, which is deducted from the total purchase. Unfortunately, after setting the discount does not apply.
My settings:
1. Is active
2. CONDITIONS OF QUALIFICATION -> Qualification type -> Minimum Quantity; Minimum qualification amount -> 1; Qualification by Role(s) and I have choose role.
3. REQUIRED PRODUCTS -> Filter Type -> Filter By Products; I have choos all products.
4.DISCOUNT APPLICATION -> Discount type -> Percentage off; Discount amount -> 0.2; DISCOUNTED PRODUCTS -> Filter By Products -> All Products
5. I have choose Add "Discounted products" to cart. Maximum applications -> 0. Max uses -> 0. Max uses per user -> 0. Max uses per code ->0.
Thanks for your help!
Comment #18
RKS commented@ladylan
Can you provide more context for your post in #14. Trying to make the change but L768 isn't the line you've posted and there are a few instances of the drupal_write_record near to that line. So if you could post what is before and after the line where we are to add the unset it would be helpful.
Thanks.
Comment #19
landylan commentedI've checked and there's no mistake. It's L768 of "uc_discounts_alt.admin.inc" for both 6.x-2.x-dev and 6.x-2.4.
Comment #20
RKS commentedOk. I was going off the module you posted in #9. So are we talking bugs in general in this thread (i.e. bugs against the 6x branch or are we testing and talking bugs from the port to 7 you posted in #9?)
Also, I'm trying to figure out what my site is doing as the admin UI doesn't exist after I enable the module. amin/store/uc_discounts doesn't appear and neither does the other paths listed in admin.inc. The database appears to have added the tables needed for the module, but nothing in errors.
Comment #21
strep commentedFor my test (# 17) ... After switching on the module will block the last step in the checkout. URL / cart / checkout / complete writes an error and can not complete the purchase. After switching off the module checkout works again. Sorry for my bad English. Perhaps I mean the developers in the mistakes, which I write ...
At what stage is the development of the module now?
thank you
Comment #22
landylan commentedSince Ubercart3 namespace has changed, I modified the related hook. Here's the code...
Comment #23
landylan commentedI've modified some bugs....
1. use isset(variable) to check before use it.
2. don't use uc_price()
3. change db name from taxonomy_term_node to taxonomy_index
And there're still some bugs...
1. discounts doesn't be chosen and shown correctly during cart/checkout/review/complete stage.
2. Cart block shows nothing during checkout stage.
In a word, the code is still not workable....
Comment #24
RKS commented"Not workable" is two words...jk.
The first bug I don't know but the cart block problem you're having is due to the way UC handles the cart. There is a (load) an (update) and a (save) and you're probably having the discount inserted before the update and after load. That doesn't work because update will discard and then save will just save the update. So you have to insert the discount or line item that you want included AFTER the update. That way the save will get it in there correctly.
I could be wrong and have it confused because it might be AFTER the save and not after the update. But I think it's the first way and if it doesn't work you can try after the save instead and see if that works.
I spent the first three weeks of this past October trying to get a discount module working with UC.
As for namespace, I also ran into that issue. If I would have saw this when you first posted i could have told you that but all functions like hook_cart or hook_order etc are all changed to hook_uc_cart and hook_uc_order. Those are actually all relatively easy to fix since many of the functions haven't changed at all.
The real challenge you're facing is getting the discount to appear and save and that is something that is difficult.
Comment #25
landylan commentedI guess I found the problem.
Problem:
1. discounts doesn't be chosen and shown correctly during cart/checkout/review/complete stage.
2. Cart block shows nothing during checkout stage.
Solution:
I just modified some query string and theme-related code, then the discounts "were chosen" correctly. But the discounts will not "be shown" until order is created. That's why it is not shown at cart page and checkout page(if you press ctrl+F5 at checkout page, you'll see the discounts). I guess it is problem about javascript (the original idea seems use javascript to show something before the order is created).
By the way, I also find a little bug at uc_discounts.module:L1904 ==> The variable $time_string seems useless and it is not defined. Undefined variable seems not allowed by Drupal7, so I remark this line.
Here's the code...
Comment #26
landylan commentedThe javascript problem is cleared. I think it's workable now.... ^_^
Comment #27
landylan commentedHere's the code.
Comment #28
mr.BF commentedThanks for your code. But I have a troubles:
1. when I add product in a cart:
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT sku FROM {uc_discounts_skus} WHERE discount_id = :discount_id AND grouping = :grouping AND sku <> ":sku"; Array ( [:discount_id] => 1 [:grouping] => 2 [:sku] => ) в функции get_skus_for_discount() (line 1108 in file Z:\home\ortotop.loc\www\sites\all\modules\custom\uc_discounts\uc_discounts.module).
2. The 'uc_discounts_classes' table 'class' field contains value 'Array' - it's wrong, isn't it?
Can you help me? Thank you.
P.S. sorry for my english
Comment #29
landylan commentedTo: mr.BF,
Thanks for your testing. I've update for problem1, and here's the updated code...
I don't really understand the problem #2. Would you please tell me more details...
Comment #30
mr.BF commentedSee attached file please. (Table "uc_discounts_classes").
I think the trouble in a line 838 (file uc_discounts.admin.inc).
Comment #31
landylan commentedTo mr.BF:
Thanks for your testing. You are right, that should not be an array. I also check all the 'class' assignment of whole module, and I find the same bugs appear in L838 and L939 (it become L839 & L940 since I modified another bugs.). Those error are all fixed. Thank you very much!!
To jrust:
As I said above, I found a bug in the original Drupal6 code. It's L719 of uc_discounts_alt.admin.inc:
it was also fixed in my new attached file(L826 & L827).
that's it. ^_^
Comment #32
tazir1 commentedThanks all,
Is it workable now = could I use this code for D7 + UC3?
If so, could you put the module on the project page (at least as dev ver.)?
I'm also need such module.
Comment #33
tazir1 commentedI just packed landylan module (comment: 9, 29 & 31)
Comment #34
dominik__w commentedDrupal 7 version
Comment #35
jens peter commentedIt might only be me but why is this one uploaded?
I don't seem to find any reference for "product price alterer field" in this issue.
I ask because I am using the module on a live site.
Comment #36
dominik__w commentedPacked tazir1 + taxonomy term support + product_price_alterer_field
Comment #37
christelle41 commentedJust after the install, I had the following error :
Notice : Undefined index: desc dans uc_order_field_extra_fields() (line 587 in /serverpath/sites/all/modules/ubercart/uc_order/uc_order.module).
Comment #38
bartolomae commentedYou have to add the 'desc' index in the uc_discounts_uc_order_pane function.
I have another problem. The discount is not showing as a line item and I get following error on cart review:
Undefined property: UcOrder::$uc_discounts_line_items_need_updating in uc_discounts_uc_order() (Line 255 of /serverpath/sites/all/modules/uc_discounts/uc_discounts.module)
Any idea how to fix it?
Comment #39
christelle41 commentedWhen clicking on "modify" in the order list, I have the following error :
Fatal error: Cannot use object of type stdClass as array in serverpath/sites/all/modules/uc_discounts_alt/uc_discounts.module on line 405
Comment #40
tazir1 commentedThe line is:
Probably need to change to:
Also in lines 412 & 413 (Similar to line 592).
Could somebody confirm this?
Comment #41
christelle41 commentedIt's worse than before. I have the following fatal error :
Fatal error: Only variables can be passed by reference in serverpath/sites/all/modules/uc_discounts_alt/uc_discounts.module on line 406
Comment #42
enrikito commentedError in: example.com/cart
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.prefix_' doesn't exist: SELECT DISTINCT tid FROM { taxonomy_index} WHERE nid IN(:nid); Array ( [:nid] => 120 ) en get_discounts_for_order() (línea 1314 de modules/uc_discounts_alt/uc_discounts.module).
Comment #43
omnius commentedGreat to see work is being done on porting to D7. Seems to work fine for me, so far, after adding
'desc' index in the uc_discounts_uc_order_pane function.Would it be possible to integrate with Rules in the future to make it even more super powerful? I suppose that is very complicated, just asking....very humbly (and fittingly prostrating myself while humbly asking).
Comment #44
josebrito commentedFor the #42 comment .
That's easy.
Just remove the space on line 1312.
Instead of: FROM { tanonomy index}
Should be: FROM {taxonomy index}
Comment #45
patoshi commentedim on the latest D7 and Ubercart. I just want to be able to do volume discounts. have anyone tried it on this already?
Comment #46
geoffAuthor commentedThis seems to add the discount to the price on cart & panel on the top of the check out, but doesn't do anything to the final total. It also shows following alert on Check out:
Notice: Undefined property: stdClass::$uc_discounts_line_items_need_updating in uc_discounts_uc_order() (line 255 of /sites/all/modules/uc_discounts_alt/uc_discounts.module).
I added #38 'desc' index to the zip file from #36.
Am I doing something wrong, or do I still need to apply some patches to the code?
Comment #47
geoffAuthor commentedOmnius (#43) - which zip on this thread you used? Just doing that 'desc' index doesn't seem to do the trick for me.
Comment #48
mr.BF commentedHi! I try to add a product with the discount to the cart and have:
Notice: Undefined property: stdClass::$uc_discounts_is_fully_discounted в функции get_discounts_for_order() (lime 1726 в in uc_discounts.module.
Help, please!
Comment #49
occucopy commentedIs there any way to get a roll/port of the patch here: http://drupal.org/node/900010#comment-5135344 for the D7 port in progress? Would be awesome to get a fix for the bug where the discounts don't apply to any attribute options.
Comment #50
aacraig commented#40, I can confirm this, but your fix is only 98% correct.
Comment #51
sslam commentedWill be Uc_3 support?
Comment #52
philpro commentedThis may already be known, emails and the order review pages do not show discounts. A summary of discounts applied to orders appears in the log.
This path, admin/store/orders/#/edit, displays:
Fatal error: Cannot use object of type stdClass as array in .../public_html/sites/all/modules/uc_discounts_alt/uc_discounts.module on line 405
Comment #53
a.knutson commentedany updates on an official UC3 D7 port?
Comment #54
jawi commentedThe ported version"uc_discounts_alt.zip" doesn't work at our drupal 7 installation
Comment #55
stecrv commentedI'm interested in D7 version
Comment #56
hockey2112 commentedI'm also very interested in the D7/U3 version. Is it forthcoming?
Comment #57
sustainablesolutions.co.nz commentedAny progress?
I've tried the ported versions and get errors or they simply don't work. A proper D7/U3 version seems to be the only option.
Comment #58
blacklabel_tom commentedWould the maintainer(s) be interested in porting the module to D7 people chipped in a few quid each? Looking at the number of people interested I'm sure they could get a good amount of money.
Just an idea.
Cheers
Tom
Comment #59
Andreyy commentedHi
We are going to port this module to D7. Can anybody join and help? It may be more quickly.
Andrey.
Comment #60
blacklabel_tom commentedI'll be happy to help where I can, let me know when you start!
Comment #61
piyuesh23 commentedHi,
I have ported a pretty stable version of this module for drupal-7. The patches provided above are using js files for handling stuffs on admin form which can be controlled in drupal 7 via for states api. Also, ubercart 3.x uses rules instead of conditional actions( module provides two conditional actions useful while caculating shipping quotes i.e., calculate shipping cost on the discounted price and check if a discount has been applied to a product or no). These have also been ported to use rules.
Attaching a zip file for the ported module. Feel free to check it out and lemme know your reviews..:)
Comment #62
Andreyy commentedWow! Cool! Thank you very much. We will test it soon.
Comment #63
Slacky08 commentedHey piyuesh23,
Thanks for the hard work and submitting the D7 version. I have downloaded it and I can report the following:
1) I can add the discount and set it up as I like which works great
2) When I visited my cart after adding the discount to my products, I received an error which I traced to line 1314 of "uc_discounts.module" where it was "FROM { taxonomy_index}" and I changed to "FROM {taxonomy_index}" which fixed the problem (removed the leading space, not sure if it is do with this particular Drupal installation being in a subfolder). The cart is now accessible, and the discount is correctly applied.
3) Then, when I visit the checkout page I get another error:
"Notice: Undefined property: stdClass::$uc_discounts_line_items_need_updating in uc_discounts_uc_order() (line 255 of /sites/all/modules/uc_discounts/uc_discounts.module)" and it lists at the top that the discount has been applied and gives a new subtotal. However, further down in the Payment Method section where it gives the final price, it does not include the discount - can you help?
4) Feature Request: I would like to be able to limit the discount to apply to products with particular attribute options - is that possible?
Thanks again, and let me know if you want me to test anything further.
UPDATE: Just noticed on item (3) that when I choose a different shipping method and therefore the price gets updated, it now adds the discount at the "Payment Method" part of the Checkout page and so correctly calculates the final price. Obviously something isn't quite right as that error still appears and the discount isn't applied correctly on first load of the Checkout page.
Thanks,
Rich
Comment #64
jrust commentedThanks for you work on this piyuesh23. I've pushed up your changes as an alpha 7.x release (along with the #2 fix from Rich). New issues on 7.x can be posted as new issues.
Comment #66
mauro_ptt commentedHere's a quick one FOR DRUPAL 7 VERSION, for getting the discounts in the checkout page (table and totals):
Go to uc_discounts_uc_order function (make sure $arg not beeing called by reference, this version of the hook has no referenced arguments) and add this case into switch ($op):
This regenerates the order info with the current discounts and gets rid of the error in line 255: "Notice: Undefined property: stdClass::$uc_discounts_line_items_need_updating in uc_discounts_uc_order() (line 255 of /sites/all/modules/uc_discounts/uc_discounts.module)", because the else is telling if there are no discounts, uc_discounts_line_items_need_updating is false.
Hope this fix is useful for you
thanks
Comment #67
hockey2112 commentedThe fix in #66 worked for my particular issue. Thanks!
Comment #68
nvidian commentedfix in #66 also worked for me, it now show the discount at checkout total (Payment pane). Thanks.
Comment #69
neorg commentedFirst of all: Thanks for porting this module to D7U3
Great work!
Using the module from #61 (also tried module from #33)
My problem:
I use the module to apply quantity discount if a customer buys a full box. Not all product have the same number of items in a full box. Terms are used for the number of items in a full box for each product. A customer get 8% discount on a full box of that single SKU. Discount is only granted on SKU's if they order a full box ore more.
Product X: has 27 pieces in a box
Product Y: has 18 pieces in a box
Discount 1 box of one SKU -> 8%
Discount 2 boxes of one SKU -> 10%
Sample order:
SKU X 27 pieces = 8% discount on this SKU only
SKU Y 36 pieces = 10% discount on this SKU only
This works fine if I place one of the SKU's in the cart. (screenshot 1 & 2) If I add the second SKU Only one discount is used (Screenshot 3)
These are my discount setting ( [x]= checked, [ ]= not checked ):
[x] Is active
[x] Can be combined with other discounts
[ ] Discount activates
[ ] Discount expires
Weight = 0
Qualification type = Minimum quantity
Minimum qualification amount = 27
[x] Has max qualifying amount
Maximum qualifying amount = 53
[ ] Require code to activate discount.
[ ] Qualification by Role(s)
[x] Require single product SKU to qualify.
[ ] Use only Discounted Products to determine if 'Minimum qualification amount' is met.
Required products
Filter by Terms -> 27 pieces
Discount Application
Discount type -> Percentage off per qualifying item
Discount amount -> 0.08
Discounted products
Filter Type -> Filter By Terms -> 27 pieces
[ ] Add "Discounted products" to cart.
Maximum applications -> 0
[ ] Further limit maximum applications to number of Required Products in cart.
Max uses -> 0
Max uses per user -> 0
Max uses per code -> 0
I have "Can be combined with other discounts" checked, but only one discount is used in cart.
When I change the "Discounted products -> Filter By Terms -> 27 pieces" to a filter not using Terms like "Discounted products -> Filter By Products -> " (Screenshot 4) than I get two Discount lines but than the discount is calculated twice on all products (like the config says). So it looks like there is a bug in the "Discounted products -> Filter By Terms" part.
Am I using a wrong config for what I want? Or is it a bug?
Can someone give me a hint where to look for a solution please?
I really need this feature. I will appreciate every help you can give me.
Tnx!