'', '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 array( '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 array( 'id' => 'discount_code', ); } /** * Returns the list of additional fields specific to this type. * * @since 2.0.0 * @return array */ public function get_fields() { return array(); } /** * 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 = array(); $checkout_fields['discount_code_checkbox'] = array( 'id' => 'discount_code', 'type' => 'toggle', 'name' => __('Have a coupon code?', 'wp-ultimo'), 'class' => 'wu-w-auto', 'html_attr' => array( 'v-model' => 'toggle_discount_code', ), ); $checkout_fields['discount_code'] = array( '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' => array( 'v-show' => 'toggle_discount_code', 'style' => $this->calculate_style_attr(), ), 'html_attr' => array( 'v-model.lazy' => 'discount_code', 'v-init:discount_code' => "'{$this->get_value()}'", 'v-init:toggle_discount_code' => ! empty($this->get_value()), ), ); return $checkout_fields; } }