This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

shop:onGetCustomerFieldState event

Triggered by Shop_Customer
Author LemonStand eCommerce Inc.

Event handler signature

public boolean event_onGetCustomerFieldState(string $db_name, string $field_value, Shop_Customer $customer)
$db_name string specifies the field name.
$field_value string specifies the field value.
$customer Shop_Customer specifies the customer object.
{return} boolean returns TRUE if the field is checked. Returns FALSE otherwise.
Determines whether a custom radio button or checkbox list option is checked. This event should be handled if you added custom radio-button and or checkbox list fields with shop:onExtendCustomerForm event.
public function subscribeEvents() {
  Backend::$events->addEvent('shop:onExtendCustomerModel', $this, 'extend_customer_model');
  Backend::$events->addEvent('shop:onExtendCustomerForm', $this, 'extend_customer_form');
  Backend::$events->addEvent('shop:onGetCustomerFieldState', $this, 'get_customer_field_state');
}

public function extend_customer_model($customer, $context) {
  $customer->add_relation('has_and_belongs_to_many', 'test_manufacturers',
    array('class_name'=>'Shop_Manufacturer', 'join_table'=>'test_customers_manufacturers',
      'primary_key'=>'customer_id', 'foreign_key'=>'manufacturer_id'
  ));
  $customer->define_multi_relation_column('test_manufacturers', 'test_manufacturers', 'Multiple manufacturers ', '@name');
}

public function extend_customer_form($customer, $context) {
  $customer->add_form_field('test_manufacturers')->tab('Customer')->renderAs(frm_checkboxlist);
}

public function get_customer_field_state($field, $value, $customer) {
  if ($field == 'test_manufacturers') {
    foreach ($customer->test_manufacturers as $record) {
      if ($record instanceof Db_ActiveRecord) {
        if ($record->id == $value)
          return true;
      }
      elseif ($record == $value)
        return true;
    }
   return false;
 }
}