WooCommerce: Zusätzliche Formularfeldattribute zu WC Vendors Pro hinzufügen

Lesezeit: 1 Minute

Benutzer-Avatar
fdeross

Entschuldigung, wenn ich in meiner Frage einige der falschen Begriffe verwende. Ich bin Autodidakt und lerne noch. Der folgende Code ist Teil einer Formularvorlage. Ich möchte dem Array einige zusätzliche Attribute hinzufügen.

Ich frage mich, wie ich das tun kann, ohne die vorhandenen Attribute der Vorlage zu löschen.

Ich möchte die zusätzlichen Attribute in der Datei functions.php meines Child-Themes beibehalten.

Hier ist die zugehörige Plugin-Funktion, die ich ändern möchte:

/**
 *  Output product title
 *
 * @since    1.0.0
 *
 * @param     int $post_id post_id for this meta if any
 */
public static function title( $post_id, $product_title ) {

    WCVendors_Pro_Form_Helper::input(
        apply_filters(
            'wcv_product_title',
            array(
                'post_id'           => $post_id,
                'id'                => 'post_title',
                'label'             => __( 'Product name', 'wcvendors-pro' ),
                'value'             => $product_title,
                'custom_attributes' => array(
                    'required'                   => '',
                    'data-parsley-maxlength'     => '100',
                    'data-parsley-error-message' => __( 'Product name is required or too long.', 'wcvendors-pro' ),
                ),
            )
        )
    );
}

Hier ist, was ich hinzufügen möchte:

'placeholder' => __( 'Here is some placeholder text', 'wcvendors-pro' ),
'desc_tip'    => 'true',
'description' => __( 'Here is some description text.', 'wcvendors-pro' ),

Versuchen Sie Folgendes, da es einen Filter-Hook gibt:

add_filter( 'wcv_product_title', 'customize_wcv_form_field' );
function customize_wcv_form_field( $args ) {
    $more_args = array(
        'placeholder' => __( 'Here is some placeholder text', 'wcvendors-pro' ),
        'desc_tip'    => 'true',
        'description' => __( 'Here is some description text.', 'wcvendors-pro' ),
    );
    return array_merge( $args, $more_args);
}

Der Code wird in die Datei functions.php des aktiven untergeordneten Designs (oder aktiven Designs) eingefügt. Es sollte funktionieren.

  • Das hat funktioniert! Danke danke danke!!! Ich habe dir gerade ein paar $$$ über PayPal geschickt.

    – fdeross

    18. Februar 2021 um 19:01 Uhr

1080590cookie-checkWooCommerce: Zusätzliche Formularfeldattribute zu WC Vendors Pro hinzufügen

This website is using cookies to improve the user-friendliness. You agree by using the website further.

Privacy policy