Styling custom fields added in the backend in WooCommerce

让人想犯罪 __ 提交于 2020-07-31 04:27:05

问题


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, left
  • form-row-last - 50% of the width, right
  • form-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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!