Title: Custom variation input
Last modified: December 14, 2021

---

# Custom variation input

 *  Resolved [m3g4tr](https://wordpress.org/support/users/m3g4tr/)
 * (@m3g4tr)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/custom-variation-input/)
 * Hey everyone,
 * I made a custom quantity input (x1, x3 and x3) that looks something like this:
   [https://imgur.com/a/sVMDTMk](https://imgur.com/a/sVMDTMk)
 * I achieved this using Javascript to modify the value of the input provided below:
 * `<input type="number" id="quantity_61b90a7cab27c" class="input-text qty text"
   step="1" min="1" max="10" name="quantity" value="1" title="Količina" size="4"
   placeholder="" inputmode="numeric">`
 * When a user clicks on either x1, x3 or x3 I update the value accordingly.
 * Now I have an issue with variations. I use Javascript to append multiple variation
   inputs to the DOM but the issue is that the back-end doesn’t know how to process
   multiple variations when adding the specified quantity of products to the cart.
 * My question: How can I modify the back-end logic to actually add different variations
   of the specified quantity (e.g when a user selects x3 he can choose 2 red T-shirts
   and one blue T-shirt)
 * When I inspected the code of some other Woocommerce websites that do this I noticed
   that they generate multiple variation inputs and change value (that is sent using
   the from a single value to array, like this:
 * – Single value
    `<select id="choose-color" class="" name="attribute_choose-color"
   data-attribute_name="attribute_choose-color" data-show_option_none="yes"><option
   value="">Choose color</option><option value="Blue" class="attached enabled">Blue
   </option><option value="Red" class="attached enabled">Red</option></select>` –
   Variations `name="attribute_choose-color[1]`, `name="attribute_choose-color[2]`
   and so on.. but my endpoint is not prepared for it and I get and error
 *     ```
       Warning: preg_match() expects parameter 2 to be string, array given in /home/customer/www/megatrgovina.si/public_html/wp-includes/formatting.php on line 1586
       ```
   

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

 *  [Juan G. (woo-hc)](https://wordpress.org/support/users/judagutor/)
 * (@judagutor)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/custom-variation-input/#post-15164058)
 * Hi [@m3g4tr](https://wordpress.org/support/users/m3g4tr/)!
 * Since this requires custom coding, I am leaving this thread open for a bit to
   see if anyone can chime in to help you out.
 * For additional assistance on this topic, we recommend getting in touch with one
   of the customization experts listed on the [WooCommerce Customizations Page](https://woocommerce.com/customizations/).
 * Also, you can visit the [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the #developers channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/),
   you could find help from the community of open-source developers for WooCommerce
   that hangs in there.
 * Cheers!
 *  [Juan G. (woo-hc)](https://wordpress.org/support/users/judagutor/)
 * (@judagutor)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/custom-variation-input/#post-15192059)
 * Hi there 👋
 * We haven’t heard back from you in a while. Hopefully, you found a solution to
   your case. I am marking this thread as resolved now. If you have further questions,
   I recommend creating a new one.
 * Cheers!

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

The topic ‘Custom variation input’ 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

 * [cart](https://wordpress.org/support/topic-tag/cart/)
 * [input](https://wordpress.org/support/topic-tag/input/)
 * [quantity](https://wordpress.org/support/topic-tag/quantity/)
 * [variations](https://wordpress.org/support/topic-tag/variations/)

 * 2 replies
 * 2 participants
 * Last reply from: [Juan G. (woo-hc)](https://wordpress.org/support/users/judagutor/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/custom-variation-input/#post-15192059)
 * Status: resolved