get products titles or COD/SKU instead of ID’s on submitted email
-
Hi Tessa,
thank you for your job, i do really appreciate it
my question:
we use this shortcode on a cf7 form for user to ask for one or more of our programs[dynamic_checkbox inputname use_label_element "au_dtx_demo_get_viaggi_di_gruppo_checkbox_options"]
/** * Contact Form 7 - richiesta programma viaggio di gruppo * Get WordPress Product Options for DTX Select Field * Get Woo Product Options for DTX checkbox Field * @return string JSON encoded checkbox options of key/value pairs to represent value/label pairs. */ function au_dtx_demo_get_viaggi_di_gruppo_checkbox_options() { $options = array(); $products = get_posts(array( 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'ignore_sticky_posts' => false, // move sticky posts to the start of the set 'tax_query' => array(array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'viaggi-di-gruppo', 'include_children' => true, 'operator' => 'IN' )) )); if (is_array($products) && count($products)) { foreach ($products as $product_id) { $options[$product_id] = get_the_title($product_id); } } return json_encode($options); } add_shortcode('au_dtx_demo_get_viaggi_di_gruppo_checkbox_options', 'au_dtx_demo_get_viaggi_di_gruppo_checkbox_options'); //-----------------------------------------------
it is working fine as it should, and it is correctly retrieving the titles of the products with checkboxes on the form, but in the email we receice only the ID’s of the products, but we would need the title or the SKU instead of ID.
Tried to change fields value “ids” with “names” but everything was messed up….
Can you help please?
thank you in advance for your time
Mario
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get products titles or COD/SKU instead of ID’s on submitted email’ is closed to new replies.