Title: Adding custom parameters to an order programmatically
Last modified: August 24, 2016

---

# Adding custom parameters to an order programmatically

 *  [xmartens](https://wordpress.org/support/users/xmartens/)
 * (@xmartens)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/adding-custom-parameters-to-an-order-programmatically/)
 * Hi
 * We have two types of products in our website – “normal” product and special products.
   For the special products in our application to which we would like to add custom
   information. Information is unique for each one of that type of product. For 
   example, some parameters like this:
    a=100 b=200 c=300 etc.
 * There is an PHP page from where we would like to add product to cart programmatically
   and add these custom parameters with its values.
 * What is the best way to achieve this?
 * Thanks.
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Kharis Sulistiyono](https://wordpress.org/support/users/kharisblank/)
 * (@kharisblank)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/adding-custom-parameters-to-an-order-programmatically/#post-6162681)
 * As far as I know. First you have to create custom product meta field to hold 
   some extra data.
 * To display extra data use `get_post_meta($product_id, 'your_product_meta_key',
   true);`. Go [here](https://codex.wordpress.org/Function_Reference/get_post_meta)
   for more information.
 * To display those data in cart page, go overriding `templates/cart/cart.php` file
   into your theme. Then find `foreach` loop which displaying added product to cart.
 *     ```
       foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
       // Loop
       }
       ```
   
 * Then display your custom data inside that loop.
 * Let me know how it helps for you.
 *  Thread Starter [xmartens](https://wordpress.org/support/users/xmartens/)
 * (@xmartens)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/adding-custom-parameters-to-an-order-programmatically/#post-6162991)
 * Shouldn’t I add fields to the order rather than to the product?
    I am new to 
   WordPress, I may not be correct in it’s terms.
 *  [Kharis Sulistiyono](https://wordpress.org/support/users/kharisblank/)
 * (@kharisblank)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/adding-custom-parameters-to-an-order-programmatically/#post-6162993)
 * Based on your initial question, you have to add fields in product.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding custom parameters to an order programmatically’ is closed to new
replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kharis Sulistiyono](https://wordpress.org/support/users/kharisblank/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/adding-custom-parameters-to-an-order-programmatically/#post-6162993)
 * Status: not resolved