הוספת שדה מחיר ספק לדף העריכה

PHOTO EMBED

Thu Jun 03 2021 10:08:17 GMT+0000 (UTC)

Saved by @Shesek

/**

 * @snippet       Display supplier @ WooCommerce Single Product Page

 * @how-to        Get CustomizeWoo.com FREE

 * @author        Rodolfo Melogli

 * @compatible    WC 4.
6
 * @donate $     https://businessbloomer.com/bloomer-armada/

 */

  
9
// -----------------------------------------

// 1. Add supplier field input @ product edit page

  

add_action( 'woocommerce_product_options_pricing', 'bbloomer_add_supplier_to_products' );      

  

function bbloomer_add_supplier_to_products() {          

    woocommerce_wp_text_input( array( 

        'id' => 'supplier', 

        'class' => 'short wc_input_price', 

        'label' => __( 'מחיר ספק', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',

        'data_type' => 'price', 

    ));      

}

  

// -----------------------------------------

// 2. Save supplier field via custom field

  

add_action( 'save_post_product', 'bbloomer_save_supplier' );

  

function bbloomer_save_supplier( $product_id ) {

    global $pagenow, $typenow;

    if ( 'post.php' !== $pagenow || 'product' !== $typenow ) return;

    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;

    if ( isset( $_POST['supplier'] ) ) {

        update_post_meta( $product_id, 'supplier', $_POST['supplier'] );

    }

}
content_copyCOPY