Order discounts work beautifully with this module, but when I select Total is greater than or equal or Total is greater than the discount doesn't show up.

Comments

jantoine’s picture

Status: Active » Postponed (maintainer needs more info)

I am unable to reproduce this. I tested using the following settings:
- Trigger: Calculate order discounts
- Condition: Check the order total
- Order total value: 100
- Order total comparison type: I tested both greater than or equal to and great than
- Action: Apply a discount
- Operation: Add
- Amount: -10
- Discount type: Order total

My order had a product costing $199 with a shipping charge of $10.60. A $10 discount was applied to the order testing both conditions. Please provide us with more information on your particular issue.

Cheers,

Antoine

tjjacobsen’s picture

Hi Antoine,

Im seeing the exact same problem as the original poster.

Maybe this will help the diagnosis: For my Products, I have Attributes set to display checkboxes, which allow users to select multiple Attributes, each with a price adjustment. (I am also using the uc_node_checkout module).

All other Discounts seem to work well. It is only the "Check Order Total" which seems to be having trouble.

I'd love to get this working asap, and am willing to help in any way.

Thanks

-Todd

tjjacobsen’s picture

A few more details:

I am using ubercart-6.x-2.0-rc5, uc_discount-6.x-1.x-dev, and drupal-6.13.

I can confirm discounts on Order Total ARE being calculated for "less than" and "less than or equal".

But, they are NOT being calculated on "equals", "greater than", or "greater than or equal".

In addition, the "NEGATE" does not seem to be working, either.

Checking other Discount types (Number of Products, Orders can be shipped, etc) seem to be working correctly.

Scenario:
I need to apply a 10% discount when an order is between $175 and $315 (inclusive). I should be able to use two conditions:

1. >=$175
2. <=$315.

Since neither > nor >= seem to be working, I tried to use:

1. <=$315 (works as expected)
2. NEGATE <=$175 (should return "TRUE" for a value such as $200, correct?)

Again, Im happy to help in any way I can.

Thanks.

-Todd

scott m. sanders’s picture

RC6 is out, if that makes any difference.

tjjacobsen’s picture

Thanks, Scott...I'll check.

A bit more info I just discovered:

The problem seems to be in the file ubercart > uc_order > uc_order.ca.inc. Specifically the function:

function uc_order_condition_total($order, $settings) {
switch ($settings['order_total_comparison']) {
case 'less':
return $order->order_total < $settings['order_total_value'];
case 'less_equal':
return $order->order_total <= $settings['order_total_value'];
case 'equal':
return $order->order_total == $settings['order_total_value'];
case 'greater_equal':
return $order->order_total >= $settings['order_total_value'];
case 'greater':
return $order->order_total > $settings['order_total_value'];
}
}

It seems the "==", ">=" and ">" cases are not working. Could it be because certain versions of PHP do not recognize those operators properly? (I am using PHP v5.2.6 on MediaTemple gs)

To test, I changed the 'greater' case to read "<", and it worked as a "is less than".

Any thoughts?

Thanks.

-t

tjjacobsen’s picture

Code looks the same in RC6.

Terko’s picture

I have the same problem, and I can't resolve it :(

Terko’s picture

The module works fine when I say: If there is more than one product, apply discount. But if I want to apply discount when the price is higher than X, this don't work. Searched everywhere, in the ubercart forum too, but without success. Maybe it's something minor, but I can't find the bug. Or maybe the bug is in the uc_order module?

franklca’s picture

I was having the same problem as well. With help from The Worx Company, we discovered was that even though conditional actions has the order total available as a condition - the variable is not set. Using a print_r($order) on the checkout page we found that the order object does not has an 'order total' variable.

We resolved this by removing the "check order total" condition and adding a condition of "execute custom php code" with the following snippet.

$total = 0;
foreach ($order->products as $product) {
    $price = $product->qty * $product->price;
    $total = $total + $price;
}

//look for a total between $13.00 and $49.99
if ($total >= 13 && $total < 50) {
  return TRUE;
}

This loops through each item in the cart, multiplying the qty by the price and tallying the total price. After looping through each item in the cart, it is then compared to our desired values and returns a true or false back to the conditional action which can then apply the appropriate discount. This code snippet was copied and pasted into each required condition - only changing the amount of the total that is required for each.

giorgosk’s picture

Status: Postponed (maintainer needs more info) » Active

for the conditions reported in #1
the "check the order total" does not appear to work

using the php snippet above solves the problem

junedkazi’s picture

the better way to calculate the total amount would be to use the inbuilt ubercart function uc_order_get_total($order, $products_only = FALSE)