php - I want to retrieve array data and post it in order while I am inside a loop -


i have checkout runs on woocommerce / wordpress, need able output contents of basket 3 input form fields on checkout review page.

i have loop gets product names, creates input box , enters product name input field.

    foreach (wc()->cart->get_cart() $cart_item_key => $cart_item) {         $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);         if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key)) {             ?>             <?php $productname = $_product->get_title(); ?>             <input type="text" id=" " name="" value="<?php echo $productname; ?>" maxlength="100"/>         <?php }     } 

i need these input fields created have specific id's, ever allowed order no more 3 products through site have 3 id's assigned these fields. have created array id's

$inputid = array ("powf_9c859612fda4e61180eb5065f38aea21", "powf_b496ed1efda4e61180eb5065f38aea21", "powf_1625303afda4e61180eb5065f38aea21"); 

what struggling here getting id's outputted html input fields. when created markup should this:

<input type="text" id="powf_9c859612fda4e61180eb5065f38aea21" name="" value="product name 1" maxlength="100"/>  <input type="text" id="powf_b496ed1efda4e61180eb5065f38aea21" name="" value="product name 2" maxlength="100"/>  <input type="text" id="powf_1625303afda4e61180eb5065f38aea21" name="" value="product name 3" maxlength="100"/> 

obviously if has 1 or 2 items in basket should still create necessary fields.

any great thanks, i've been stuck on far long!

i managed working approaching in different way.

rather having array handle form id's , loop handling product names, removed original id array , use loop create array , add product array every loop.

then have input fields echo out array results 0,1 , 2.

like this:

foreach (wc()->cart->get_cart() $cart_item_key => $cart_item) {                 $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);                 if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key)) {                     ?>                     <?php $productname = $_product->get_title(); ?>                     <?php $array[] = $productname; ?>                 <?php }             }  <input type="text" id="powf_9c859612fda4e61180eb5065f38aea21" name="powf_9c859612fda4e61180eb5065f38aea21" value="<?php echo $array[0]; ?>" maxlength="100" /> 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -