Last active
August 3, 2021 12:46
-
-
Save PechenkiUA/bb52fd027c4d95b93982d4f9ed0bdce0 to your computer and use it in GitHub Desktop.
TM Extra Product Options telsender Options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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