Does anyone know if its possible to set up a rule that would compare the users core account shipping address field (not a commerce profile) to the shipping address field used on the check-out form during check-out?

I have the site configured to auto-populate the billing and shipping address fields during check-out using the core account shipping address field (which uses the "Address" module), not commerce shipping profile so that my client can control a list of registered shipping addresses for a B2B site. The customers need to be able to either use their registered shipping addresses, or enter a unique shipping address and pay $3.00.

What I need to do is determine if the user over-wrote the auto-populated shipping address value with a custom address (which implies they are attempting to drop-ship their order to a residential location, and therefore adds $3.00 to the order total) by comparing the value in the shipping address field used during check-out to the value in the core account shipping address field. And if they DO NOT match, add three dollars to the order.


You could make a custom module and add in there a custom rules condition that checks exactly what you need The tiny book of rules contains great examples how to implement custom conditions www.drupal.org/files/tiny-book-of-rules.pdf

Also you could try do the same thing with the default rules condition (e.g. entity has field and entity field has value) but i think is much more hard to get relationships this way

If you choose to go with a custom condition function I suggest you set the default argument as an order type and the use functions like this one http://www.drupalcontrib.org/api/drupal/contributions!commerce!modules!customer!commerce_customer.module/function/commerce_customer_profile_load_multiple/7 to get the shipping profile and then the address you want to compare. You may load the current user simply by using global $user; . The devel module and the dpm() function is a great help to see what is available during development in an object.

Not the answer you're looking for? Browse other questions tagged or ask your own question.