Skip to content

Instantly share code, notes, and snippets.

@PechenkiUA
Last active August 3, 2021 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PechenkiUA/bb52fd027c4d95b93982d4f9ed0bdce0 to your computer and use it in GitHub Desktop.
Save PechenkiUA/bb52fd027c4d95b93982d4f9ed0bdce0 to your computer and use it in GitHub Desktop.
TM Extra Product Options telsender Options
<?php
function meta_wc_function ($list, $order_id){
$order = wc_get_order( $order_id);
$items = $order->get_items();
$product_f = '';
$curents = get_woocommerce_currency_symbol();
foreach ( $items as $item) {
$product_item = $item->get_product();
if ($product_item) {
$meta_data = '';
foreach($item->get_meta_data() as $k => $value){
foreach($value->value as $opt){
if (($opt['name'] && $opt['value']) && $opt['name'] !=2) {
$meta_data .= sprintf('%s : %s',$opt['name'],$opt['value']);
$meta_data .= ' | ';
}
}
}
if ($meta_data) $meta_data = sprintf('( %s )', rtrim($meta_data,'| '));
$option = $product_item->get_data();
$sku = $product_item->get_sku();
$product_f .= sprintf('%s x%s %s %s %s',$item['name'],$item['quantity'],$item['total'],$curents,$meta_data).chr(10);
}
}
$list['{product_f}'] = $product_f;
return $list;
}
add_filter( 'tscf_filter_codetemplate','meta_wc_function', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment