Hello Everyone,

Does anyone know how to make the condition in rules checking whether a customer profile is the default one WITHOUT using the PHP code filter? I'm thinking of coding or implementing a rule condition that does that where the parameter is an address/customer profile and then it returns whether the given customer profile is the default one.

Comments

akosipax’s picture

Here's the code anyway just in case we would like to add it in some submodule somewhere or other people would need it....

/**
 * Implement hook_rules_condition_info()
 */
function iflc_customizations_rules_condition_info() {
  return array(
  	'rules_condition_is_customer_profile_default' => array(
  	  'label' => t('Customer profile is the default'),
  	  'parameter' => array(
  		  'customer_profile' => array('label' => t('Customer Profile'), 'type' => 'commerce_customer_profile'),
    	),
    	'group' => t('Commerce Addressbook'),

    ),
  );
}

/**
 * Rules Condition Implementation Callback
 *
 *  Checks whether the customer profile is the default customer profile
 */
function rules_condition_is_customer_profile_default($customer_profile) {
  return commerce_addressbook_get_default_profile_id($customer_profile->uid,$customer_profile->type) == $customer_profile->profile_id;
}
mglaman’s picture

Category: Support request » Feature request
Issue summary: View changes
Status: Active » Fixed

Condition added to module.

  • mglaman committed 643a072 on 7.x-2.x
    Issue #2104963: Rules Condition: If Address is the Default Address
    

Status: Fixed » Closed (fixed)

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