Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\Emails\Schema
EmailsSettingsSchema::get_values
Get flat key-value mapping of all setting values.
Method of the class: EmailsSettingsSchema{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_values( $email ): array;
- $email(WC_Email) (required)
- Email instance.
EmailsSettingsSchema::get_values() EmailsSettingsSchema::get values code WC 10.9.1
private function get_values( WC_Email $email ): array {
$values = array();
$form_fields = $email->get_form_fields();
if ( ! is_array( $form_fields ) ) {
return $values;
}
// Create a dummy order object, as some of the getter methods require one.
$email->object = new \WC_Order();
foreach ( $form_fields as $id => $field ) {
$field_type = $field['type'] ?? 'text';
// Skip non-data fields.
if ( in_array( $field_type, array( 'title', 'sectionend' ), true ) ) {
continue;
}
// Get saved value an fallback to default.
$default = $this->get_field_default_value( $email, $id, $field );
$value = $email->get_option( $id, $default );
// Unwrap personalization tags if the field supports them.
if ( in_array( $id, self::FIELDS_SUPPORTING_PERSONALIZATION_TAGS, true ) ) {
$value = $this->unwrap_woocommerce_tags( $value );
}
// Convert checkbox to boolean for API.
if ( 'checkbox' === $field_type ) {
$value = ( 'yes' === $value );
}
$values[ $id ] = $value;
// Handle customer_refunded_order email type because it has two different subjects.
if ( 'customer_refunded_order' === $email->id && 'subject_full' === $id ) {
if ( ! isset( $values['subject'] ) ) {
$values['subject'] = $value;
}
}
if ( 'customer_partially_refunded_order' === $email->id && 'subject_partial' === $id ) {
if ( ! isset( $values['subject'] ) ) {
$values['subject'] = $value;
}
}
}
return $values;
}