Created
April 9, 2013 23:23
-
-
Save ChromeOrange/5350273 to your computer and use it in GitHub Desktop.
Create a cost price field for simple products, add this to functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_product_options_pricing','custom_cost_price'); | |
function custom_cost_price() { | |
woocommerce_wp_text_input( array( 'id' => '_cost_price', 'class' => 'wc_input_price short', 'label' => __( 'Cost Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'type' => 'number', 'custom_attributes' => array( | |
'step' => 'any', | |
'min' => '0' | |
) ) ); | |
} | |
add_action('woocommerce_process_product_meta_simple', 'save_custom_cost_price'); | |
function save_custom_cost_price($post_id) { | |
global $wpdb, $woocommerce, $woocommerce_errors; | |
update_post_meta( $post_id, '_cost_price', stripslashes( $_POST['_cost_price'] ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I was looking for a solution like this one to display a price in MXN Pesos and a price in USD.
How did you displayed the custom price in the frontend? Does it affect the cart price?