/** * @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'] ); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter