How do I add Cost to Product backend

I am trying to add a Cost field to the Product Details section.

So, it would go: SKU, Cost, Price, etc.

I can add the Cost via CustomPress -- but it really needs to be in with the SKU/Price area for usability.

Is there a function I can add to my functions.php file that could add something like this? I would hate to break into the core code and disable all future updates.

  • Ash

    Hello there

    I hope you are well today and thanks for asking the question.

    Add this line in line 2163 of /plugins/marketpress/marketpress.php

    <th scope="col" class="mp_price_col"><?php _e('Cost', 'mp') ?></th>

    Line 2183:
    <td class="mp_cost_col"><?php echo $this->format_currency(); ?><input style="width: 80px;" type="text" name="mp_cost[]" value="<?php echo isset($meta["mp_cost"][$key]) ? $this->display_currency($meta["mp_cost"][$key]) : '0.00'; ?>" /></td>

    Line 2213:
    <td class="mp_sku_col"><?php echo $this->format_currency(); ?><input type="text" name="mp_cost[]" value="0.00" style="width: 80px" /></td>

    Line 2068:
    update_post_meta($post_id, 'mp_cost', $_POST['mp_cost']);

    Please let me know if it is helpful and feel free to ask more question if you have.


  • Spectrum

    Thanks for the very quick reply -- and on a weekend no less!

    It worked great, but I will miss the future updates to the plugin :slight_smile:

    Maybe this could be an option in future versions, as I would imagine it would be very important info for merchants to price their products.

    It could also be used in future profitability reports (which would be another very good thing to have).

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.