Contrib type:
ModuleStatus:
Work in progressCompatibility:
Ubercart Dev CodeWritten by Ideal Solution LLC
This allows you to define discounts to be applied during checkout. Conditions and actions are supplied by submodules. The following conditions and actions are defined:
order_total:
- condition: compare the total price to a specified amount
- action: discount the total price by a specified amount or percentage
product:
- condition: Are there $qty number of $product in the order
- action: Discount a specified amount or percentage off $qty number of $product
role:
- condition: does the user belong to a certain role
Notes:
The Discounts module has not yet been well-tested with taxes.
| Attachment | Size |
|---|---|
| uc_discounts.tar.gz | 12.19 KB |

Re: Discounts
There are now three conditions (order total, product, and role) and two actions (discount from order total, discount products). Discounts are now seen on the checkout screens and do indeed get stored as part of the order. The Discounts contribution description has been updated, and a new file attached.
Re: Re: Discounts
The file is not in gunzip , but in bunzip
Re: Re: Re: Discounts
Force of habit. Reattached in gzip now.
Re: Re: Re: Re: Discounts
thanks a lot marshal. I think I would like it.
But I get following errors after adding a new discount:
* warning: Invalid argument supplied for foreach() in {mypath}\modules\ubercart\uc_discounts\uc_discounts.module on line 1637.* warning: Invalid argument supplied for foreach() in {mypath}\modules\ubercart\uc_discounts\uc_discounts.module on line 1669.
I'm too tired for checking the reason this night. Do you have an idea what wents wrong?
thanks.
Re: Re: Re: Re: Re: Discounts
This error is because you have no conditions defined, resulting in $condition_list being NULL. I'm uploading a new version which fixes this for conditions and actions.
Great work marshal! Thank
Great work marshal!
Thank you!
Some annotation:
- It would be cool, if the discount could be displayed at the shopping card.
- Like descriped in this thread: http://www.ubercart.org/forum/development/224/strange_behavior_hook_line... there's a problem with the set_line_item() function.
- I think it's better to group all modules (main and submodules) together (Otherwise people like me wondering, why they can't define conditions
Thank you
I agree with michels, you've done a great job with this module. I get a strange problem though - but it may be a result of my previous code "tweaking" of the other modules
Problem: After sending an order (with all correctly calculated values) I go to: admin/store/orders and get this warning: Invalid argument supplied for foreach() in /modules/ubercart/uc_discounts/uc_discounts.module on line 370.
Further more total sum is incorrect there. Sth like this:
Subtotal: 755,81 zł
Shipping Cost: 0,00 zł
Rebate: -113,37 zł
Total: 755,81 zł
Can you please help? Greets from Poland
I exactly have the same problem
I just test on a new drupal/ubercart/discount installation, and when I purchase a product, and then to display the order I have the following error :
argument supplied for foreach() in /modules/ubercart/uc_discounts/uc_discounts.module on line 370.
Re: I exactly have the same problem
foreach() can handle empty arrays, so what that's saying is that $cart is not an array at all. Looking over the code for uc_cart_get_contents(), this should not be possible.
The following adds a check for a cart which is not an array or is empty, for debugging purposes. It would be helpful to see if either of the messages below display when you get the error.
--- uc_discounts.module (revision 19)
+++ uc_discounts.module (working copy)
@@ -366,6 +366,16 @@
}
$cart = uc_cart_get_contents();
+ if (!is_array($cart)) {
+ drupal_set_message('Bad cart - is not an array.');
+ return array();
+ }
+ elseif (empty($cart)) {
+ drupal_set_message('Cart is empty, no discounts will be applied');
+ // nothing in the cart? no discounts
+ return array();
+ }
+
$cart_copy = array();
foreach ($cart as $cart_item) {
$cart_copy[] = drupal_clone($cart_item);
Discounts by Groups of products
Marshall,
Is there any way to offer discounts based on a group of products. ie I would like to offer 10% off the purchase of 3 or more widgets from category X
Impossible to remove a discount.
I tried to remove a test discount I just created, and when I go to edit, and press the delete button, I just return to discount listing and the deleted discount is still here.
Am I alone to have the problem ?
zmove
alpha7c updates
this problem, as well as the one described above, are likely a result of running alpha7c code without appropriate changes to uc_discounts.module to account for the updated checkout panes for alpha7c. Here's a patch which makes uc_discounts comply with this API change:
<?php
--- trunk/5.x/projects/sites/scw/modules/ubercart/uc_discounts/uc_discounts.module (revision 443)
+++ trunk/5.x/projects/sites/scw/modules/ubercart/uc_discounts/uc_discounts.module (revision 449)
@@ -247,6 +247,5 @@
return;
}
- $pane = uc_cart_checkout_new_pane('discounts');
- $pane->fields['pane']['description'] = uc_cart_checkout_pane_description('discounts', t('The following discounts will be applied to your order:'));
+ $description = t('The following discounts will be applied to your order:');
// create discounts table
@@ -276,12 +275,10 @@
$table = theme('table', $header, $rows);
- $pane->fields['pane']['discounts'] = array(
- '#value' => $table,
- );
+ $contents['discounts'] = array('#value' => $table );
// add line item
$script = "set_line_item('discount', 'Discount', -$discount_total, 1)";
drupal_add_js("\$(document).ready( function() { ". $script ." } );", 'inline');
- return $pane;
+ return array('description' => $description, 'contents' => $contents, 'next-button' => FALSE);
case 'review':
?>
Re: alpha7c updates
Thanks for the patch, it worked great. This was top on my list of things to do today, and you just made it a whole lot easier.
Re: Re: alpha7c updates
has the original .gz file been updated with this too?
About tax support
Hi there,
I'm posting here to speak about the integration with taxe system.
In the note below the module description, it says that the module is not well tested with taxes.
So I test, and it doesn't work.
I will try to make it compatible, The best way would be to add a checkbox in the tax module to check or un check if you want to apply taxes on the discount.
Re: About tax support
I made uc_discounts module compatible with uc_taxes module.
However, when you think about how tax have to be applied, you can easily conclude that the uc_taxes module have to implement uc_discounts and not uc_discounts that have to implement uc_taxes.
Why ? because taxes is a thing that have to apply at the very end of your order. When you calculate a discount, it have to apply to an excluding tax amount and, then, tax have to be calculated on the new price without tax. That's why it's more easy to understand and to implement in the uc_taxes.module than the uc_discount.module.
So I created a patch of the Alpha 7c uc_taxes.module. This is a very little and easy to understand patch.
I only changes some lines in the uc_taxes_calculate($order) function to substract the discount amount to total before calculating taxes amount.
It could be really great if uc_taxes.module could implement the uc_discounts inrtegration in core, to not be obliged to modify it each time an update is made.
This is the patch content
<?php--- D:/Taf/Kalys/Sites/drupal/sites/all/modules/ubercart/uc_taxes/uc_taxes_original.module Thu Sep 20 10:45:32 2007
+++ D:/Taf/Kalys/Sites/drupal/sites/all/modules/ubercart/uc_taxes/uc_taxes.module Thu Sep 20 14:31:14 2007
@@ -425,15 +425,31 @@
if ((uc_taxes_match_area($rule, $order)) && eval($conditions)){
$rate = $rule->rate;
$amount = 0;
+ $total = 0;
$debug = ' (';
if (is_array($order->products)) {
foreach($order->products as $item){
$node = node_load($item->nid);
if (in_array($node->type, $rule->taxed_product_types)){
- $amount += $item->price * $item->qty * $rate;
+ $total += $item->price * $item->qty;
$debug .= ' + '. $item->price;
}
}
+ // Start of uc_discounts implementation
+ if (module_exists('uc_discounts')) {
+ $apply_discounts = uc_discounts_apply_discounts();
+
+ if (empty($apply_discounts)) {
+ return;
+ }
+ $discount_total = 0;
+ foreach ($apply_discounts as $discount) {
+ $discount_total -= $discount['amount'];
+ }
+ $total += $discount_total;
+ // End of uc_discounts implementations
+ }
+ $amount += $total * $rate;
}
$debug = substr($debug, 3);
$taxed_line_items = $rule->taxed_line_items;
@@ -461,6 +477,7 @@
$taxes[$rule->id] = array('id' => $rule->id, 'name' => $rule->name /* . $debug */, 'amount' => $amount, 'weight' => $rule->weight);
}
}
+
return $taxes;
}
?>
zmove
Re: Discounts
I get the error "Fatal error: Call to undefined function: uc_cart_checkout_new_pane() in uc_discounts.module on line 249" when checking out, any ideas?
I really need this module to work!
Re: Re: Discounts
Yes, just apply the spiderman .diff....
Re: Re: About tax support
zmove, I don't really want to make a special case for discounts in uc_taxes because it already handles line items in general.
I looked into the discounts module because I thought that they were added as line items, but I think I know why taxes aren't able to pick them up. Firstly, uc_discounts doesn't implement hook_line_item(). This prevents Übercart modules from knowing that discount-type line items exist. Secondly, the discounts are applied to the order during the 'review' step, which is after the taxes are calculated in the 'process' step.
If someone could roll up a patch to do that, I think that'd be the best solution.
Re: Re: Re: About tax support
Thanks for your answer Lyle. I will try to modify the discount module, because I don't like to hack core, and if I hacked the uc_taxes.module, it's because I thinked that there were no alternatives.
Correct me if I'm wrong, but by looking through the code, I noticed that the tax module calculate the taxes by calculating the tax rate for each product. See this code in uc_taxes_calculate() that is called by uc_line_item_tax()
<?php...
foreach($order->products as $item){
$node = node_load($item->nid);
if (in_array($node->type, $rule->taxed_product_types)){
$amount += $item->price * $item->qty * $rate;
...
?>
So even if the discount module use the hook_line_item, I don't know if the tax module could correctly calculate the tax (maybe I'm wrong, I'm far to understand all drupal and ubercart behavior so, maybe I need more explanation ^^)
For the last point, I don't understand you Lyle, you say that the discount is calculated on the review step.. what do you mean by review step ? the order review page ? Because the discount module show the discount amount on a checkout pane, so I don't understand well what do you mean by review step.
regards,
zmove
Re: Re: Re: Re: About tax support
The function that builds the checkout pane gets an $op parameter. This parameter has three valid values: 'view', 'process', and 'review'. uc_discount_checkout_pane() only uses 'view' and 'review'. What it should do is calculate the amount in 'process', and then display it in 'review'.
The tax on the discount might be off, but only for discounts on particular products. Discounts to the order in general will also discount those taxes that apply to the discount line item. However, the tax rules can't distinguish between discounts on specific products like they can distinguish between product types. Might have to make a hook to deal with that somewhere.
Hi there,
After some test and some modification. The tax is well applied after the discount but only on the order review page. the tax is not well applied on the checkout page.
Lyle, you seems to say that the discount is calculated on the order review page, so I tried to put the discount calculation on the 'process' case. But it changed nothing, I already try to put the discount in a hook_line_item but it didn't change the checkout payment pane and it add an extra discount line to the order review page.
I upload the discount.module I obtain after a day of testing... My brain has reached his limit without succes...
Re: Hi there,
After some tests, I noticed a strange thing.
the Taxe don't apply on the payment checkout pane, but, if you choose your address by selecting it in the dropdown menu (when your address is saved). The Tax is recalculated and take care of the discount amount.
very strange.
Re: Discounts
I apologize for my absence from this. Unfortunately, our sponsor had a staffing change a while back, and decided to go in a different direction. As a result, it's difficult for me to keep up with this and work on the Discounts module. We are, of course, open to other sponsors.
Re: Re: Discounts
I need working role discounts for my project now - with user friendly display on checkout page:
item1 .......... $1
item2 .......... $7
-------------------
subtotal ....... $8
discount(25%) .. $2
total........... $6
I am able pay for it some money, but I am afraid that my resources are not enough
//sorry for my english
Re: Re: Re: Discounts
I've never had Czech beer.
I need to get this going as well. I just have a couple things on my list first.
patch: product class discounts and various bugfixes
the following is a patch that may be relevant to others using this module. it "fixes" a number of things in the module (whether they are "real" bugs or not- they didn't work the way we needed them to), and adds support for discounts based on product classes, in addition to individual products.
the core infrastructure of this module seems very solid, although there were a few issues (mostly covered in zmove's helpful post, many of which are addressed in this patch. one of the basic requirements we had, however, was to be able to apply discounts to all products of a given class.
this revealed some of the limitations of the extensibility framework that marshal has begun. overall, i think this framework makes a lot of sense, but a) doesn't cover enough cases, and b) has a few inherent limitations which are hard to address with the conditions/actions approach (more on that in a moment).
so first off, we added some support to the uc_discounts.module itself to allow for non-integer-based "items" to be provided by the sub-modules. in this way, we could add a uc_discounts_product_class.module (an initial implementation of which is included in the patch) which would allow the user to choose a product class for both conditions and actions, and thereby allow multiple products from the same class to "count" toward a given discount.
the rest of the patch to uc_discounts.module itself is mainly fixing a few logic errors and implementing the full range of operators. patches to uc_discounts_product.module effectively clean up the internal logic of single product discounts to conform to the needs of our clients (again, i'm not 100% clear what the original intention was here, but it didn't work for our needs, at least). apologies for the various debug messages in here, although maybe they will help understand what is actually going on in the dark corners of this module
the one limitation i found in working with the new product_class module was that it seems tricky to provide conditions/actions that can be used independently of each other. for example, when i first went to build a per-product-class discount module, i thought i should be able to simply provide a new type of condition, and use the existing per-product action to actually apply the discount. however, in practice i found i couldn't get this to work, because the actions callbacks seem to rely on the conditions, and vice versa. it's possible this can work, but i couldn't find a way.
beyond that, one of the things we'd like to have from a discounts module that it's not immediately obvious how to achieve with the current framework is the ability to show the user applied discounts at the product level. for example, if you buy a lot of buttons, you get them at a discounted rate. at the moment, the total discount is calculated and displayed in a separate table, but it would be nice to show the customer what the discount is per-button, in the list of products on the checkout/review order pane. this way, they could see immediately how much the buttons are costing them, without having to do the math (regular price shown in list - discount shown in separate table).
as always, feedback is appreciated, and hopefully all of this is of use to somebody. i've no doubt we'll be revisiting all of this stuff in the not-too-distant future, as ubercart evolves and our requirements grow
patch: multi/cross-product discounts and price-based conditions
following on from my previous comment, this patch adds support for discounts which apply to combinations of products/classes, and also implements a new "amount" field which allows for defining an additional conditional: if the product in question's sell_price is equal to the "amount" field, then it counts towards the discount.
the first piece of this is to allow for discounts where if customers buy a certain number of either buttons or stickers, in combination, then they get a bulk discount. i accomplished this in a somewhat hackish way, by extending the "items" field in the conditions/actions table to store a serialized array of products/classes, and treat them appropriately when considering whether a given order should get a discount.
this approach seems less than ideal, and i imagine that in a perfect world we could define any number of products/classes which would match a given condition/action. these should really be stored in a separate table, so that one could say "any combination of this particular product and this class of products should receive a discount" (at the moment, you can only choose a product *or* a class).
the second thing this patch does is to provide an "amount" field on conditions, to allow for selecting products/classes with a specific price. this allowed us to restrict discounts to only "regular priced" products, and not apply them to "on sale" or package products within a given class.
this feature is mostly working, although i've had a couple reports in the last day or so that something's not quite right and discounts are sometimes being mis-applied (still trying to track down this bug).
once again, any and all feedback is greatly appreciated, and we hope this code can be useful to somebody, especially if it contributes to increasing the usefulness of this module for the community at large
alternative approach to taxes support
I've implemented a slightly different approach to the same problem as described by zmove, and though it's not ideal, i thought i'd post it here for completeness:
<?phpIndex: uc_taxes/uc_taxes.module
===================================================================
--- uc_taxes/uc_taxes.module (revision 528)
+++ uc_taxes/uc_taxes.module (revision 529)
@@ -414,6 +414,18 @@
if (empty($order->delivery_country)){
$order->delivery_country = $order->billing_country;
}
+ # apply discounts to the order
+ $discounts = db_query("SELECT * FROM {uc_order_line_items} WHERE order_id=%d AND type='discount'", $order->order_id);
+ if (empty($discounts)) {
+ return;
+ }
+ $d_amount = 0;
+
+ while ($data = db_fetch_object($discounts)) {
+ // store as negative
+ $d_amount += $data->amount;
+ }
+
$tax_rules = uc_taxes_get_rates();
$subtotal = 0;
$taxes = array();
@@ -430,10 +442,13 @@
foreach($order->products as $item){
$node = node_load($item->nid);
if (in_array($node->type, $rule->taxed_product_types)){
- $amount += $item->price * $item->qty * $rate;
+ $amount += $item->price * $item->qty; # * $rate;
$debug .= ' + '. $item->price;
}
}
+ $amount -= $d_amount;
+ if ($amount < 0) { $amount = 0; }
+ $amount = $amount * $rate;
}
$debug = substr($debug, 3);
$taxed_line_items = $rule->taxed_line_items;
?>
Importantly, this approach avoids calling uc_discounts_apply_discounts, which seems to do strange things when called more than once on a given order.
As suggested by Lyle, I think this is probably better accomplished by having uc_discounts properly implement hook_line_item, so that taxes can (optionally) apply before/after the discount amount is considered.
This is brilliant!
This is exactly what I needed to make this module work, thank you.
final
Is it possible to post final version of discount module file, with all those revisions applied? I would really appreciate, because I badly need this working, but I don't know how to apply all these diff files. Thank you very much.
Re: final
Hey guys - anyone have the complete module? I tried applying the patches and I keep getting Hunk failed, malformed patch, missing header, etc etc. Nothing seems to be quite right.
If someone can post the complete tarball I'd be much obliged
Re: Re: final
I too would greatly appreaciate a working tarball. I went through and tried to apply the various patches. None of them apply cleanly, and based on the two hours of bug hunting I've already done, it appears that those that did run, often applied themselves into the wrong place. If I do manage to get it working, I'll gladly post what I have to this thread.
Re: Re: Re: final
Here's what I have. Not sure it's 100% functional, but I got it to a point where it's not generating parsing errors anymore.
Re: Re: Re: Re: final
Thank you for your repackaging surge_martin.
I tested your files and noticed several errors :
So, in fact, I have no error now, but nothing works.... I'm on alpha 8, maybe it need an integration with workflow... don't know.
Humm,
Humm,
Just testing this for a future project:
For me anything post the year 2037, flags the error 'End date can not be before the start date'?
Also, maybe 'Setting the end date in the past is pointless.' should be changed to read better to clients...
sorry to be a stick in the mud!
Not as good as the message on the tax module though - 'Misusing this field can really mess up your site. DO NOT BE STUPID.' - genius!
Anyway, back to my actual point; I too have the errors listed in the post above as well as the end_date error I have mentioned.
Is this to do with the repackaged file by surge_martin, or do I need to apply any patches for 7e?
Many thanks
Paul
Re: Humm,
I sent spiderman a PM asking for a most recent module, but haven't heard back yet. I'm hoping someone has the most recent / complete module that we can take and continue developing from.
Re: Re: Re: Re: Re: final
Same problem, on alpha8, discounts gets never applied even with the most large condition possible.
I'm thinking of getting back to alpha 7e because I NEED working role discounts.
Re: Re: Re: Re: Re: Re: final
I'm looking at getting a discount system going that uses Workflow-ng. So far it's looking like the discounts will be applied as items are added to the cart. This means that the product pages won't show the discount, but they'll see the difference in the shopping cart. Advertising the discounts in the product body or in blocks around the site should encourage customers to take advantage of them.
Re: Re: Re: Re: Re: Re: Re: final
Sweet! What's your status on that? Right now we're using a Product Kit to allow discounts on products, but some people are confused in thinking that, if they add the components one at a time, they'll still get the discount (which obviously is not the case at this point). So a discount system that allows for this type of functionality is wholly welcome.
Re: Re: Re: Re: Re: Re: Re: final
I agree with Lyle, we have to don't forget that the discount is a marketing tool, so the customer have to see them in product node discounted body, not only on the cart or checkout.
Re: Re: Re: Re: Re: Re: Re: final
What's the status of the module? I would be willing to help pay to have this module working with some new features ASAP. Anyone up for some paid programing?
Re: Re: Re: Re: Re: Re: Re: final
Hi
I got the role based discounts working. I'm using alpha8, and the uc_discounts.zip posted by surge_martin..
Since I just picked this package up, I don't want to mess up the code conduct or anything like it..
Just thought I'd post my discoveries, and see what Lyle or any other maintainer says. Also has to be said that I only need role based discounts, so none other tested.
1. The uc_discounts_condition_form_validate in uc_discounts.module, first lines is a numeric check on form value prop, this is not valid for the role condition, which doesn't have a value.
2. uc_discounts_apply_discounts() in uc_discounts.module, there is a foreach loop that checks operators. Now this thing kills the role condition: if ($c == 0) { $condition_groups[$i] = FALSE; } It does so, because role discount doesn't include a count_check. That leads to this test never passing: if (array_search(TRUE, $condition_groups) !== FALSE) {
Now after fixing those problems, the condition kicks inn, but discounts pane is never added to the checkout.
I fixed that by adding a separate products based action with a apply_callback to the role discount..But that is probably not the way it was intended. I'll look into that some more.
Edit:
Looked into it..
It looks like the sql statement in uc_discounts_product_apply function in uc_discounts_product.module doesn't fit the role discount need. The products are actions if it is a role condition, so that statement makes the condition_list empty, and the function returns 0, hence no pane.
If anyone is interested in diffs, lemme know(need to remove debug statements).
Anyways thanks for an uberproduct!!
thanks!
cool, working fine. What I'm missing is a module that grants discount on how many articles purchased.
Re: Re: Re: Re: Re: Re: Re: Re: final
Can you post a patch with your changes? Thanks!
uc_discounts update
I've tried to leave this code somewhat better than how I found it ...
Here are my changes since surge_martin's version:
This version installs and runs on a site with Ubercart alpha 8.
Admin options not showing up
Not sure why, but the only options that appear after install are to set user permissions. There is an empty bullet that appears in the Customer admin section. I'm guessing this is where the admin options would be, if they appeared.
Any ideas?
Thanks.
Re: Admin options not showing up
Thank you detour, I will try your discount improvement on a sandbox and I will give you feedback.
Hi,
Hi,
I'm having similar issues with the Admin options.
The link shows it pointing to http://localhost/shop/admin/store/discounts/valuehtml
but I can only get to it by going to http://localhost/shop/admin/store/discounts/value
Here is a picture.
http://img253.imageshack.us/img253/4350/discountsyw4.jpg
(The discounts menu item there is one I made manually)
Other than the link/menu stuff, it works great!
Fix for menu and other issues
Thanks for the reports back.
I'm attaching an updated version of uc_discounts that fixes the store administration path issues. The valuehtml path seems to be from a deprecated/incomplete feature. I've removed it and made one other small improvement to the menu code.
Also, I've corrected two lines of code that relate to showing the discounted price on the product's page.
Let me know if this resolves the issue, and if anything else comes up.
Re: Fix for menu and other issues
Thanks for all your work on this, detour.
The admin options for the Discounts module now appear. Thanks.
Still not having success with applying discounts.
I'm trying to set up roll based discounts. I have...
- set up new roll via rolls (called 10 Percent Discount)
- created a new discount (set to active, expiry date in 1 year, end processing and exclusive not selected, max discounts 0)
- set up condition (property: user roll, condition group: 1, CO: =, role: 10 Percent Discount)
- action (property: discount all prods of a type, product type: product general [a custom product class], quantity: 1, amount: 10%)
Modules: discounts, product, product type, role.
Results:
- discount not applied
- discount not showing up in product views or cart
Thanks.
Re: Re: Fix for menu and other issues
Hi
The role discount doesn't have its own apply_callback. It uses the action from the product discount.
The SQL statement in that function rules out any actions that doesn't belong to a product role.
In uc_discounts_product.module look for the uc_discounts_product_apply function around line 136.
Change:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";$sql .= "AND property='product' AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
To:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";//$sql .= "AND property='product' AND item_id='%s' ";
//$sql .= "AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
I've just commented it out for the time beeing.
Try that, and let me know how it works. I've changed some other things too, and can't remember if they were related to that problem. I'm working on sorting out the nodeapi hook to display discounted prices around the shop. It doesn't work for me atleast.
Discounts won't work
I installed discounts and configured one to work for a role. It doesn't work - when logged in as a user with that role, the product is not discounted.
I went back to the discount configuration, and changed the dates to see what would happen. There seems to be something wrong with the dates aspect of this:
I set the start date to 1/1/2007 and the end date to 12/31/2050 and when i try to save it I get an error message saying the end date can't be before the start date. I moved the end date back a few times, and it still gave me the same message. I moved it to December of 2008 and then it let me save it.
But, the discount still isn't working. It seems like there must something else wrong with the dates, and the system is treating this discount like it doesn't apply to the current date.
We have a bunch of students for our training program who need to receive this discount or they're going to get mad and confused. I hope someone can help us soon.
Thanks/
Re: Discounts won't work
Hi
Check the post above yours..
You need to get detours latest compilation, the tar.gz posted the 10th.
Then fix the stuff mentioned in the post above yours.
Another thing I've found is that when viewing your orders in /admin/store/orders..
And got my juice back, which I lost editing my posts..
The line items are correct. Like subtotal+shipping-discount and so on..But the calculation of the total, and thereby setting the payment/balance is actually based on the discount of the products currently in your cart.
Probably should've put that in a separate post
Working on that now. The order 'bug' that is..
role based discount is not working plz need your help
what i have tried is
1) installed this module into my drupal with ubbercart
2) applied role based disocunt.
3) created condition and action in discount configuaration
condition for : item1 10%
role: member (created by me means userdefined)
action:- in amount i have entered 20%
and when i do the transaction i cant see any discount / not in cart/nowhere plz
help me ....
thanx in advance...
Re: Re: Discounts won't work
Thanks for your reply; I'm sorry I didn't see those items before you pointed them out to me.
However, unfortunately, I tried both things you told me -- installed the newer version of the module and modified those lines of code, and the discount still doesn't show up - on the product detail, in the cart, or during checkout.
Any other idea? I really appreciate your help.
Re: Re: Re: Discounts won't work
Hi
Well, I reverted some changes and made a patch file..
There shouldn't be any other changes needed.
When you upgraded the uc_discounts module, did you get the drupal module upgrade notification?
Did you run the db upgrade?
After upgrading the module, you should've seen that all actions in your previous discount lost their titles.
What I did was to delete all conditions and actions in the discount.
Make sure it is still active.
Recreate the rolebased condition.
Recreate the discount actions.
And as I mentioned the nodeapi hook doesn't work. So the discount is only seen on the checkout pane. If it still isn't working, try to uncomment some of the drupal messages, and see where it fails.
Re: Re: Re: Re: Discounts won't work
I did upgrade the db after upgrading the module.
Can anyone tell me how to patch a module? I've been using Drupal in depth for about 2 years, but I've only upgraded modules -- I've never patched one, and I haven't been able to find any guidance on how to do that.
Re: Re: Re: Re: Re: Discounts won't work
Sorry for complicating stuff..
The patch isn't really needed. It was just to show that other than the SQL statement change, you shouldn't need to change anything else to get rolebased discounts to work.
So, if you made that change.
Try to uncomment some if the drupal_set_message's laying around in the code.
And see where it stops.
Re: Discounts
discount seen in drupal but when it is on sandbox discount disappears der and it shows the total without discount plz plz help me.........
thanx in advance
Roll Based Discounts
Hi. Just to summarize how to get roll based discounts working...
1. Install the latest version of the module (posted Dec 10th)
2. In the uc_discounts_product.module, change:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";
$sql .= "AND property='product' AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
To:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";
//$sql .= "AND property='product' AND item_id='%s' ";
//$sql .= "AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
3. Make sure the DB has been updated if a earlier version of the module was installed.
* The patch posted on Dec 17th is not needed.
** The discount will only show up on the checkout page at this point.
It is still not working for me. No discount function seems to run at all when I go to the checkout page. Any ideas? Thanks.
Re: Roll Based Discounts
I tried uninstalling and reinstalling the module once again, and it works for me now. Thanks.
A Patch for Multi Products
Using the latest .tar.gz (from Dec. 10th) I found two bugs that were causing the multi product module not to work. 1.) The actions data type seems to have changed so no discounts were being applied. 2.) There was no support for percentage based discounts. The attached patch fixes both of these problems. With the patch applied role based discounts are working fine for me with ubercart alpha8.
One other caveat to note, when creating an Action there is a field called Qty. It will apply the specified discount X number of times. Which means that you should at least put "1" for Qty or no discount will be applied.
Re: Discounts
is it possible to show the discount price on the product page at all? I haven't looked at the code yet but wanted to see if it was something that was in progress or not.
Re: Re: Discounts
Need to show the discount on product on the product page too. To have the original price in < strike> tag and the new price in a span, so custom the display.
And it could be great to have a new package to download instead of the original file + 1000 patches
Re: Re: Re: Discounts
+1 for a new package file
Update for uc_discounts
Attached is an updated version of uc_discounts. I've applied the fixes provided by kiruva and jrust, and added more support for discounting prices before checkout.
This version introduces a new administrative option regarding whether to apply discounts at checkout (the default in previous versions) or when a product is added to the cart. By selecting the latter option, discounts are not displayed as line items on the checkout screen, but are applied directly to the product's price when it is added to the cart. This does not work with every discount condition, as some are applicable only to an entire order.
I've had success using the product, role, and site conditions with the 'discount amount from order total' action. I have not tested the other conditions and actions extensively.
Re: Update for uc_discounts
Thank you for your package, I will test that on a sandbox and will give you feedback
Ok after some tests,
First thanks for taking time to provide us a release containing all patch and improvements done.
I tested the last package and I have some comments, bug report.
About conditions
About actions
<?php# user warning: Table 'SANDBOX.uc_discounts_conditions' doesn't exist query: uc_discounts_multi_product_apply SELECT id FROM (uc_discounts_conditions) WHERE discount_id=8 AND property='product_multi' ORDER BY condition_group, weight in /includes/database.mysqli.inc on line 151.
# warning: in_array() [function.in-array]: Wrong datatype for second argument in /sites/all/modules/ubercart/contrib/uc_discounts/discounts/uc_discounts_multi_product.module on line 130.
?>
The problems seems to come from missing {} in SQL declaration because I have prefix to my tables and my uc_discounts_conditions table equivalent id dp_uc_discounts_conditions. So by writing {uc_discounts_conditions} in your code instead of uc_discounts_conditions, drupal will automatically add table prefix.
Most of conditions seems to work, just need a little work. But the actions need a real rework because pratically nothing work (or maybe I made something wrong, can others testers confirm or infirm if it works or not ?).
Another remark, the discount system don't use the hook_line_item to add the discount in checkout pane. It should, because ATM it is not compatible with taxe module, so this part of the module should be rewritted by using the ubercart hook.
Re: Ok after some tests,
zmove, what version of ubercart are you using? I have only tested it with alpha 8...
Yet another update for uc_discounts
Attached is an updated version of uc_discounts. As zmove notes, recent versions of uc_discounts do not save discounts as line items, and therefore are not compatible with uc_taxes. In this version, I've changed how discounts are saved from a simple modification of the order total (via hook_order) to an order line item. I've also fixed the table name problem that zmove reported, and changed uc_discounts_role to allow discounts based on the 'authenticated user' role.
@zmove, Thanks for your thorough status report on the discount conditions and actions. Can you verify that role based discounts aren't working? They work on my site (and are the primary condition that I've been testing). I'm using a role condition with a 'discount amount from order total' action.
Re: Yet another update for uc_discounts
Many thanks detour, I will try your modification as soon as possible.
I don't know if you are agree, but, by regarding all the great work you make for this module, it could be good you take the module maintain role.
I will give you feedback when I will test the module. Actually I'm updating my ubercart installation to beta.
Re: Yet another update for uc_discounts
After doing a fresh install of the above module, I've had luck viewing the discount as a line item. Granted, I'm not using the taxes module so I cannot comment there. I'll probably have to throw together a sandbox to check out role based conditions. Has anyone done this already?
"End date can not be before the start date" error seen
I'm using Ubercart-beta2 with the uc_discounts-2008010