Have upgraded 2.1, but unable to get the rules working. Worked brilliantly previously in 1.3 with the original Compare product amount condition. Tested the dev version a few weeks back, but saw that was still buggy with the notices appearing, so reverted back and waited, and this new version isn't working for me still.

I’m trying to create a series of rules for flat rate shipping for orders that contain a particular product type (Order contains products of particular product types) and between total order value ranges of those product types (Total amount of selected products comparison) e.g. under £5, between £5.01 - £20.00 and so on etc to set the shipping rate to the total value amount in order of product type.

Rules are still evaluating to false in debug, and getting ‘no shipping rates found for your order’, and also getting the notice when using Total amount of selected products comparison condition

“Warning: trim() expects parameter 1 to be string, array given in commerce_rules_extra_compare_product() (line 80 of … commerce_rules_extra/includes/conditions/commerce_rules_extra_compare_product_quantity.inc).”

(I did full upgrade as per instructions on upgrade.txt too, and rebuilt all my rule components from scratch that use this module). I’ve tested with adding Term Reference etc in the Total amount of selected products comparison condition and no joy there either (If I add term reference I get the following message above still and also more which mentions line 91 of that file.) but presume that as not using Terms for this condition, I wouldn't need to add those anyhow.

Quantity rule is fine btw as tested with that, no errors appearing, but that’s not the one I need to be using as it’s the value amount not quantity of products; and have looked through some of the issues here re the notices on the earlier dev versions too.

Any ideas or suggestions?

CommentFileSizeAuthor
#21 2395421-product-amount-calculation-func-params-21.patch1.13 KBAnonymous (not verified)
#19 2395421-product-amount-calculation-func-params-19.patch989 bytesAnonymous (not verified)
#18 Screen Shot 2015-01-28 at 12.04.50 PM.png46.39 KBAnonymous (not verified)
#3 2395421-product-amount-calculation-func-params-3.patch2.58 KBAnonymous (not verified)

Comments

blackroom’s picture

I've also found that I wasn't getting the predicted result with this same condition – 'Total amount of selected products comparison'. I've just come fresh to this module as I was looking to trigger an action when a product of a certain type had a value amount of more than 1. Uninstalling this and installing 1.3 using 'Total product of type amount value comparison' (which I'm guessing is the equivalent?) with the same operator/amount gave me the result I expected.

perignon’s picture

Assigned: Unassigned » perignon

I'll review the issue as soon as I can!

Anonymous’s picture

I believe I've fixed the issue. It looks like the parameters got mixed up. Things appear to be working as they should be here (I'm able to use the conditions without error now).

Anonymous’s picture

Status: Active » Needs review
perignon’s picture

Hopefully some other people can get this patch tested that is using that rule. I myself don't have the rule being used in a production site.

lswhitehead’s picture

I'll be able to test this in the coming week, and will let you know. Thanks!

blackroom’s picture

I'll check this one too over the next couple of days and report back

perignon’s picture

Thanks everyone!

blackroom’s picture

I've applied the patch successfully and re-created the rule using the new version of the module. I've created a rule with the condition 'Total amount of selected products comparison' that should be true if the cart contains products of type 'product' with a combined value of zero. However, if I checkout a product of that type that's worth 0.00 it's still returning false in the debug. I've attached an export of the rule incase I'm missing something when creating the comparable rule based on the slightly altered options in the newer version. The total quantity options work fine.

{ "rules_product_has_no_shipping" : {
    "LABEL" : "Product has no shipping",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_rules_extra" ],
    "ON" : [ "commerce_rules_extra_process_checkout_pane" ],
    "IF" : [
      { "commerce_rules_extra_compare_product_amount" : {
          "order" : [ "commerce-order" ],
          "product_type" : { "value" : { "product" : "product" } },
          "exclude" : 0,
          "operator" : "=",
          "value" : "0",
          "term_id" : { "value" : [] },
          "product_display" : 0,
          "term_operator" : "IOO"
        }
      }
    ],
    "DO" : [
      { "commerce_rules_extra_change_pane" : {
          "pane_id" : "commerce_shipping",
          "page_id" : "\u003Csame\u003E",
          "enabled" : 0
        }
      }
    ]
  }
}
perignon’s picture

Thanks for the feedback. I will take a look at it sometime this weekend.

FYI, when you paste code into the comments it is helpful to use the code text format, makes spacing work right for readability.

blackroom’s picture

Sorry about that (updated above)

lswhitehead’s picture

I've given it a test, not getting the notice now, but still false in debug and 'no shipping rates found for your order'.

perignon’s picture

Sorry for taking so long to look into this. The patch doesn't actually do anything submitted above, but just rearrange the function calls. No logic is changed.

Anonymous’s picture

Right, this only really affects the trim() error that was occurring due to miss-ordered parameters.

I'll boot up a commerce install and try out each of them to make sure they're working as advertised.

perignon’s picture

I got to look into this more but at the moment I just started a new project and my dev environment is hosed writing new custom fields and content types...

perignon’s picture

@mhazy, that's the thing. I double checked the order and it was right.

perignon’s picture

Just did a triple check. The order is correct.

Anonymous’s picture

StatusFileSize
new46.39 KB

The order of parameters is not correct in commerce_rules_extra_compare_product_amount() for the "Total amount of selected product comparison" condition.

Product type and vocabulary are switched. The other methods that I changed in the original patch were superfluous. I'll re-create it with the pertinent bits.

/**
 * Callback function for Compare Product Amount condition.
 */
function commerce_rules_extra_compare_product_amount($order, $voc_name, $term_ids, $product_display, $require_all, $product_type, $exclude, $operator, $value) {
  return commerce_rules_extra_compare_product($order, $voc_name, $term_ids, $product_display, $require_all, $product_type, $exclude, $operator, $value, "amount");
}

Compared to commerce_rules_extra_compare_product_quantity(), where the product type is the second argument.

/**
 * Callback function for Compare Product Quantity.
 *
 * Calculates the quantity of products in an order that have the term $term_id
 * and compares it to a given value.
 */
function commerce_rules_extra_compare_product_quantity($order, $product_type, $exclude, $operator, $value, $voc_name, $term_id, $product_display, $term_operator) {
  return commerce_rules_extra_compare_product($order, $voc_name, $term_id, $product_display, $term_operator, $product_type, $exclude, $operator, $value, 'quantity');
}

Anonymous’s picture

StatusFileSize
new989 bytes

Updated patch

Anonymous’s picture

Jumped the gun a bit, it actually looks like the two groups of parameters are switched.

Based on how the parameters are defined in commerce_rules_extra_compare_product_quantity_condition_info() the order of arguments for commerce_rules_extra_compare_product_amount() should be:

  1. $order
  2. $product_type
  3. $exclude
  4. $operator
  5. $value
  6. $voc_name
  7. $term_ids
  8. $product_display
  9. $operator
Anonymous’s picture

This patch sorts out the function arguments.

  • Perignon committed e2842ed on 7.x-2.x authored by mhazy
    Issue #2395421 by mhazy: Total amount of selected products comparison...
perignon’s picture

I just added that patch to the dev branch. Still got to check the logic.

lswhitehead’s picture

Just to say the dev version is working perfectly, thank you all!

blackroom’s picture

Also just retested with dev version and working great. Thanks!

perignon’s picture

Thanks for the feedback!

perignon’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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