Title: Dynamically Adding Custom Product
Last modified: August 31, 2016

---

# Dynamically Adding Custom Product

 *  [mightymouse3062](https://wordpress.org/support/users/mightymouse3062/)
 * (@mightymouse3062)
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/)
 * I have been trying to search the internet for an answer and I have yet to find
   one. I am also fairly new to WooCommerce development.
 * I have a site that is trying to implement WooCommerce with a 3rd party company
   for t-shirt designs (similar to CustomInk). The product list, options (colors,
   sizes, etc), thumbnail image, price, and quantity is already available through
   the 3rd party.
 * I would like to be able to dynamically add all of the custom items (from an array)
   for a user to a cart and be able to go through the checkout process. How do I
   do that?
 * Thank you.
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

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

 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412417)
 * Will the products be on your store or 100% custom?
 * You can use WC()->cart->add_to_cart() directly and add custom details, but you
   may need a dummy product for these to link to. Price can be set on the cart item.
   This will require PHP knowledge to implement.
 *  Thread Starter [mightymouse3062](https://wordpress.org/support/users/mightymouse3062/)
 * (@mightymouse3062)
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412579)
 * All of the products in the store will be custom.
 * How should I setup the dummy product?
 * I have PHP knowledge to do this.
 *  [jessepearson](https://wordpress.org/support/users/jessepearson/)
 * (@jessepearson)
 * Automattic Happiness Engineer
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412581)
 * The function that Mike was referring to is documented here: [https://docs.woothemes.com/wc-apidocs/class-WC_Cart.html#_add_to_cart](https://docs.woothemes.com/wc-apidocs/class-WC_Cart.html#_add_to_cart)
 * And I believe what he meant by a dummy product was creating a product through
   the admin area that you’re able to pass all of the data to. The product just 
   needs to exist so you can pass it’s ID to the function.
 *  Thread Starter [mightymouse3062](https://wordpress.org/support/users/mightymouse3062/)
 * (@mightymouse3062)
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412609)
 * I see in the admin area that you can create different “types” of products, “Simple
   product”, “Grouped product”, “External/Affiliate product”, “Variable product”.
   I would assume that the dummy product I need to create is going to be an “External/
   Affiliate” product.
 * I see the `add_to_cart()` method has `variation` and `cart_item_data` attributes
   that will accept an array.
 * Looking at `cart_item_data`, I believe this is the array I would like to populate.
   I am just not sure what the indexes need to be for adding the data? Is that documented
   somewhere?
 * Thank you very much.
 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412611)
 * The dummy product would be simple so it is purchasable. Once added to cart, you
   can adjust it’s price and set meta data on the cart item. Basic example of adding
   data [https://github.com/mikejolley/woocommerce-product-gift-wrap/blob/master/woocommerce-product-gift-wrap.php#L76-L81](https://github.com/mikejolley/woocommerce-product-gift-wrap/blob/master/woocommerce-product-gift-wrap.php#L76-L81)

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

The topic ‘Dynamically Adding Custom Product’ 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/)

## Tags

 * [custom product](https://wordpress.org/support/topic-tag/custom-product/)

 * 5 replies
 * 3 participants
 * Last reply from: [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/dynamically-adding-custom-product/#post-7412611)
 * Status: not resolved