This topic is: Not Resolved
-
In ProgressPosted in: Extra Checkout Options – addon
-
macaronjoshPurchasedJanuary 10, 2023 at 11:03 pm #114900
Hi,
I use following code provided in a other forum topic to add al the meta data of the order to the order list.
Is it also possible to add the data from the extra checkout option addon?Kind regards and best wishes for the new year!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212// add listable checkout add-on column titles to the orders list tableadd_filter( 'manage_edit-shop_order_columns', 'my_render_column_titles', 15 );// add listable checkout add-on column content to the orders list tableadd_action( 'manage_shop_order_posts_custom_column', 'my_render_column_content', 5 );function my_render_column_titles( $columns ) {$new_columns = array();foreach ( $columns as $name => $value ) {if ($name=='order_status'){$new_columns['order_meta'] = __( 'Meta', 'woocommerce' );}$new_columns[$name] = $value;}return $new_columns;}function my_render_column_content( $column ) {if ($column!="order_meta"){return;}global $post, $woocommerce, $the_order;if ( empty( $the_order ) || $the_order->get_id() != $post->ID ) {$the_order = wc_get_order( $post->ID );}$order=$the_order;$order_currency = $order->get_currency();$mt_prefix = $order_currency;foreach ( $the_order->get_items() as $item_id => $item ) {$product = apply_filters( 'woocommerce_order_item_product', $the_order->get_product_from_item( $item ), $item );$item_meta = function_exists( 'wc_get_order_item_meta' ) ? wc_get_order_item_meta( $item_id, '', FALSE ) : $order->get_item_meta( $item_id );$html = '';$has_epo = is_array($item_meta)&& isset($item_meta)&& isset($item_meta['_tmcartepo_data'])&& isset($item_meta['_tmcartepo_data'][0])&& isset($item_meta['_tm_epo']);$has_fee = is_array($item_meta)&& isset($item_meta)&& isset($item_meta['_tmcartfee_data'])&& isset($item_meta['_tmcartfee_data'][0]);if ($has_epo || $has_fee){$current_product_id=$item['product_id'];$original_product_id = floatval(TM_EPO_WPML()->get_original_id( $current_product_id,'product' ));if (TM_EPO_WPML()->get_lang()==TM_EPO_WPML()->get_default_lang() && $original_product_id!=$current_product_id){$current_product_id = $original_product_id;}$wpml_translation_by_id=TM_EPO_WPML()->get_wpml_translation_by_id( $current_product_id );}if ($has_epo){$epos = maybe_unserialize($item_meta['_tmcartepo_data'][0]);if ($epos && is_array($epos) ){$html_toadd='';$hasit=false;$html_epo='';foreach ($epos as $key => $epo) {if ($epo && is_array($epo)){$new_currency = false;if (isset($epo['price_per_currency'])){$_current_currency_prices = $epo['price_per_currency'];if ($mt_prefix!==''&& $_current_currency_prices!==''&& is_array($_current_currency_prices)&& isset($_current_currency_prices[$mt_prefix])&& $_current_currency_prices[$mt_prefix]!=''){$new_currency = true;$epo['price'] = $_current_currency_prices[$mt_prefix];}}if(!$new_currency){$type="";if (isset($epo['element']) && isset($epo['element']["_"]) &&isset($epo['element']["_"]['price_type'])){$type=$epo['element']["_"]['price_type'];}$epo['price'] = apply_filters('wc_epo_get_current_currency_price',$epo['price'],$type);}$hasit=true;if(!isset($epo['quantity'])){$epo['quantity'] = 1;}if(isset($wpml_translation_by_id[$epo['section']])){$epo['name'] = $wpml_translation_by_id[$epo['section']];}// local modeif ( !isset($epo['price_per_currency']) && taxonomy_exists( $epo['name'] ) ) {$epo['name'] = wc_attribute_label( $epo['name'] );}if(isset($wpml_translation_by_id["options_".$epo['section']])&& is_array($wpml_translation_by_id["options_".$epo['section']])&& !empty($epo['multiple'])&& !empty($epo['key'])){$pos = strrpos($epo['key'], '_');if($pos!==false) {$av=array_values( $wpml_translation_by_id["options_".$epo['section']] );if (isset($av[substr($epo['key'], $pos+1)])){$epo['value'] = $av[substr($epo['key'], $pos+1)];}}}$display_value = $epo['value'];if (is_array($epo['value'])){$display_value = array_map('html_entity_decode', $display_value, version_compare(phpversion(), '5.4', '<') ? ENT_COMPAT : (ENT_COMPAT | ENT_HTML401) ,'UTF-8');}else{$display_value = html_entity_decode($display_value, version_compare(phpversion(), '5.4', '<') ? ENT_COMPAT : (ENT_COMPAT | ENT_HTML401) ,'UTF-8');}if (!empty($epo['use_images']) && !empty($epo['images']) && $epo['use_images']=="images"){$display_value ='<div class="cpf-img-on-cart"><img alt="" class="attachment-shop_thumbnail wp-post-image epo-option-image" src="'.apply_filters("tm_image_url",$epo['images']).'" /></div>'.esc_attr($display_value);}$html_epo .= '<div class="tm-50">'.apply_filters('tm_translate',$epo['name']).'</div>';// value$display_value = apply_filters('tm_translate',$display_value);if (isset($epo["element"]) && isset($epo["element"]['type']) && $epo["element"]['type'] == "upload"){$check = wp_check_filetype( $epo['value'] );if ( !empty( $check['ext'] ) ) {$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );if ( in_array( $check['ext'], $image_exts ) ){$display_value ='<a target="_blank" href="'.$display_value.'"><span class="cpf-img-on-cart"><img alt="" class="attachment-shop_thumbnail wp-post-image epo-option-image epo-upload-image" src="'.apply_filters("tm_image_url",$epo['value']).'" /></span></a>';}}}if (!empty($epo['multiple_values'])){$display_value_array=explode($epo['multiple_values'],$display_value);$display_value="";foreach ($display_value_array as $d => $dv) {$display_value .='<span class="cpf-data-on-cart">'.$dv.'</span>';}}$html_epo .= '<div class="view"><div class="tm-50">'.make_clickable( $display_value ).'</div></div>';}}if ($hasit){$html .= $html_toadd.$html_epo;}}}if ($has_fee){$epos = maybe_unserialize($item_meta['_tmcartfee_data'][0]);if (isset($epos[0])){$epos = $epos[0];}else{$epos = false;}if ($epos && is_array($epos) && !empty($epos[0])){foreach ($epos as $key => $epo) {if ($epo && is_array($epo)){if(!isset($epo['quantity'])){$epo['quantity'] = 1;}if(isset($wpml_translation_by_id[$epo['section']])){$epo['name'] = $wpml_translation_by_id[$epo['section']];}if(isset($wpml_translation_by_id["options_".$epo['section']]) && is_array($wpml_translation_by_id["options_".$epo['section']]) && !empty($epo['multiple']) && !empty($epo['key'])){$pos = strrpos($epo['key'], '_');if($pos!==false) {$av=array_values( $wpml_translation_by_id["options_".$epo['section']] );if (isset($av[substr($epo['key'], $pos+1)])){$epo['value'] = $av[substr($epo['key'], $pos+1)];if (!empty($epo['use_images']) && !empty($epo['images']) && $epo['use_images']=="images"){$epo['value'] ='<div class="cpf-img-on-cart"><img alt="" class="attachment-shop_thumbnail wp-post-image epo-option-image" src="'.apply_filters("tm_image_url",$epo['images']).'" /></div>'.$epo['value'];}}}}$html .= '<div class="view"><div class="tm-50">'.apply_filters('tm_translate',$epo['name']).'</div><div class="tm-50">'.apply_filters('tm_translate',$epo['value']).'</div></div>';}}}}echo $html;}}ThemeCompleteSite AdminJanuary 11, 2023 at 1:03 am #114901You must be logged in to see this reply. -
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
No access!
You do not have permission to post to this forum.