public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value) { if ($field instanceof Interspire_EmailIntegration_Field_NumberInterface) { // anything here supports a ToNumber conversion return $field->valueToNumber($value); } if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) { // anything else that can boil down to a string should be sent as is; mailchimp will handle conversion and rounding return $field->valueToString($value); } // other complex fields that won't map return ''; }
public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value) { if ($field instanceof Interspire_EmailIntegration_Field_Date) { // for dates, the value /should/ be convertable to a timestamp, so we can date() it and send it through as mailchimp requires // note: if I sent a date formatted using isc_date_tz to mailchimp, they would convert it to local time (so 2010-04-28 became 2010-04-27) *even if the mailchimp account was set to +10* - so, I'm sending it through without a tz indicator and it seems to make more sense -ge return isc_date('Y-m-d H:i:s', $field->valueToNumber($value)); } if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) { // for other string-compatible fields, try sending that through and let mailchimp sort it out return $field->valueToString($value); } // other field types that won't map return ''; }
public function fromSubscriptionToProvider (Interspire_EmailIntegration_Field $field, $value) { if ($field instanceof Interspire_EmailIntegration_Field_Date) { $timestamp = $field->valueToNumber($value); // the d/m/y order is defined in the Key returned by IEM when querying custom fields $format = 'j/n/Y'; // default/fallback if (isset($this->_settings['Key']) && count($this->_settings['Key']) >= 3) { // basic validation $key = $this->_settings['Key']; $format = $this->dateSettingToFormat($key[0]) . '/' . $this->dateSettingToFormat($key[1]) . '/' . $this->dateSettingToFormat($key[2]); } return date($format, $timestamp); } if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) { // for other string-compatible fields, try sending that through and let IEM sort it out return $field->valueToString($value); } // other field types that won't map return ''; }