Add custom fields
-
I needed besides SKU and PRICE more fields.
ATTENTION: after update the plugin the changes are gone – editing core files!
Anyone who else needs this, follow this instructions:
Open the file [PLUGIN-PATH -> wp-order-cart -> wpordercart.php]
Go to line ~89 “function add_products_metaboxes()” and duplicate a “add_meta_box” and change bold-entries:add_meta_box(‘wpordercart_products_fabrikat‘, ‘Hersteller‘, array($this, ‘wpordercart_products_fabrikat_gethtml’), ‘products’, ‘normal’, ‘high’);
Then go to line ~97 “function wpordercart_products_price_gethtml()” and duplicate the whole function – change 3 times “price” and the _e label ‘<label for=”price” >’; _e(“Preis “‘
Then go to line ~152 “$products_meta[‘price’] = $_POST[‘price’];” and duplucate this, taking ur own values (in this case change 2 times “price”)
Now, if u refresh the backend and make all correct, u see under the content ur new field. To output that field, goto [PLUNING_DIR -> Templates -> product.php] (for single view) and add:
<?php $my_value = get_post_meta($post->ID, “my-fieldname”, true); if ($my_value != “”) { echo ” <tr> <td style=’font-weight:bold;’ >Label: </td> <td colspan=’2′ >” . $my_value . “</td> </tr> “; } ?>
Feel free to ask.
- The topic ‘Add custom fields’ is closed to new replies.