'', 'default' => '', ]; } /** * List of keys of the default fields we want to display on the builder. * * @since 2.0.0 * @return array */ public function default_fields() { return [ 'name', 'placeholder', 'tooltip', ]; } /** * If you want to force a particular attribute to a value, declare it here. * * @since 2.0.0 * @return array */ public function force_attributes() { return [ 'id' => 'discount_code', ]; } /** * Returns the list of additional fields specific to this type. * * @since 2.0.0 * @return array */ public function get_fields() { return []; } /** * Returns the field/element actual field array to be used on the checkout form. * * @since 2.0.0 * * @param array $attributes Attributes saved on the editor form. * @return array An array of fields, not the field itself. */ public function to_fields_array($attributes) { $checkout_fields = []; $checkout_fields['discount_code_checkbox'] = [ 'id' => 'discount_code', 'type' => 'toggle', 'name' => __('Have a coupon code?', 'wp-multisite-waas'), 'class' => 'wu-w-auto', 'html_attr' => [ 'v-model' => 'toggle_discount_code', ], ]; $checkout_fields['discount_code'] = [ 'type' => 'text', 'id' => 'discount_code', 'name' => $attributes['name'], 'placeholder' => $attributes['placeholder'], 'tooltip' => $attributes['tooltip'], 'default' => $attributes['default'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'wrapper_html_attr' => [ 'v-show' => 'toggle_discount_code', 'style' => $this->calculate_style_attr(), ], 'html_attr' => [ 'v-model.lazy' => 'discount_code', 'v-init:discount_code' => "'{$this->get_value()}'", 'v-init:toggle_discount_code' => ! empty($this->get_value()), ], ]; return $checkout_fields; } }