Skip to content

Instantly share code, notes, and snippets.

@PechenkiUA
Last active February 25, 2021 12:50
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/d7411443425b7e0aa17c8b71809afb8c to your computer and use it in GitHub Desktop.
Save PechenkiUA/d7411443425b7e0aa17c8b71809afb8c to your computer and use it in GitHub Desktop.
add fiter shortcode telsender wc
<?php
/* Telsender add action*/
function meta_wc_function ($list, $order_id){
$order = wc_get_order( $order_id);
$items = $order->get_items();
$product_f = '';
foreach ( $items as $item) {
$product_item = $item->get_product();
if ($product_item) {
$meta_data = '';
foreach($item->get_meta_data() as $k=>$value){
$meta_data .= $value->key .': '.$value->value.' ' ;
}
$option = $product_item->get_data();
$sku = $product_item->get_sku();
$product_f .= $item['name'].' x'.$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