问题
I've added a custom field, and I want the label text to start on a new line. At the moment it starts between to price fields.
Can I style it? or cant I change the priority to move it to another line?
I am using: WooCommerce: Get custom field from product variations and display it as a suffix to variation prices
回答1:
You could add a wrapper class 'wrapper_class' => 'form-row-full',
For the wrapper_class
are the other possibilities:
form-row-first
- 50% of the width, leftform-row-last
- 50% of the width, rightform-row-full
- 100% of the width, full
// 1. Add custom field input @ Product Data > Variations > Single Variation
add_action( 'woocommerce_variation_options_pricing', 'Add_bulk_price_to_variations', 10, 3 );
function Add_bulk_price_to_variations( $loop, $variation_data, $variation ) {
woocommerce_wp_text_input( array(
'id' => 'bulk_price[' . $loop . ']',
'desc_tip' => 'true',
'description' => __( 'Enter the Bulk price here.', 'woocommerce' ),
'label' => __( 'Custom Field', 'woocommerce' ),
'wrapper_class' => 'form-row-full',
'value' => get_post_meta( $variation->ID, 'bulk_price', true )
));
}
来源:https://stackoverflow.com/questions/62001523/styling-custom-fields-added-in-the-backend-in-woocommerce