Hi,

I am trying to set up free shipping for all orders over $50. I have everything configured correctly in Rules and it is working. Although I am also using UC Coupon module and when customer uses a discount on order and his total after discount is <50 he still gets free shipping. In D6 this was easily fixed using order grand total token. How should I approach this in D7?

Thanks for help!

Comments

longwave’s picture

Title: Data comparision in Rules - order grand total? » Data comparision in Rules - order subtotal
Category: support » feature

The order grand total should technically include any discount, so what you need here is the subtotal of all products instead, which would ignore any discount (or indeed, any currently applied shipping quote). This is available as a token, but not as a an order property in Rules, so this is a feature request.

tinker’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.81 KB

Attached patch provides rules conditions to compare order total and subtotal to a specified value.

  • Added total comparison because stock rules data comparison does not provide >= and <= operators and it make life easier for rules noobs.
  • Added generic function uc_order_condition_value_operator_comparision() to compliment uc_order_condition_value_operator_options().
  • uc_order_condition_value_operator_comparision() can be used to further optimize code in uc_order_condition_count_products() and uc_order_condition_products_weight() by replacing switch ($op) {...
tinker’s picture

StatusFileSize
new3.92 KB

Updated patch - accidentally overwrote $value in foreach().

hanoii’s picture

StatusFileSize
new3.8 KB
new569 bytes

It's strange. I have used this patch before, but for some reason I was having the following error on a site:

Notice: Undefined property: stdClass::$total in uc_order_condition_total() (line 943 of /home/nubie/public_html/dev7/sites/all/modules/ubercart/uc_order/uc_order.rules.inc).

Only to find out that ->total is not actually a valid properly but rather order_total is.

Attached is a patch correcting this.

hanoii’s picture

StatusFileSize
new569 bytes

Uploading the interdiff with txt extension

hanoii’s picture

Status: Needs review » Needs work

The last submitted patch, 4: interdiff-1931076-3-4.diff, failed testing.

hanoii’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: interdiff-1931076-3-4.diff, failed testing.

tr’s picture

Looks good to me, but "comparision" should be "comparison"

Since the patch adds a new function uc_order_condition_value_operator_comparision(), I think that function should also be used to replace the switch statements in uc_order_condition_products_weight() and uc_order_condition_count_products().

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new4.81 KB

Can someone test this? It's the same as #4 but with my comments from #10 included.

tr’s picture

StatusFileSize
new4.82 KB

And one more, this time with the rule labels changed slightly for consistency with our other rules.

hanoii’s picture

StatusFileSize
new3.86 KB

Just providing an interdiff between 12 and 4.

Patch looks good!

tr’s picture

Title: Data comparision in Rules - order subtotal » Data comparison in Rules - order subtotal
Version: 7.x-3.x-dev » 8.x-4.x-dev
Status: Needs review » Fixed

Committed! Thanks all...

  • TR committed 1587fa1 on 7.x-3.x
    Issue #1931076 by hanoii, TR, tinker: Data comparison in Rules - order...
tr’s picture

Status: Fixed » Patch (to be ported)

Moving to 8.x-4.x so we remember to forward port this ...

longwave’s picture

Status: Patch (to be ported) » Fixed

Cherry-picked it straight into the 8.x-4.x codebase, even if all the Rules conditions still need conversion at least it's in there.

  • longwave committed 1ceb246 on 8.x-4.x authored by TR
    Issue #1931076 by hanoii, TR, tinker: Data comparison in Rules - order...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.