Skip to content

Instantly share code, notes, and snippets.

@PechenkiUA
Created November 30, 2021 09:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PechenkiUA/08cbbf0c47446da7e9b501c9b2e6357e to your computer and use it in GitHub Desktop.
Save PechenkiUA/08cbbf0c47446da7e9b501c9b2e6357e to your computer and use it in GitHub Desktop.
Telsender image products
<?php
/* Telsender image product */
function meta_wc_function_image($list, $order_id)
{
$order = wc_get_order($order_id);
$items = $order->get_items();
$curents = get_woocommerce_currency_symbol();
$product = '';
$product_v3 = '';
$product_v2 = '';
foreach ($items as $item) {
$metaProduct = $item->get_formatted_meta_data();
$metaText = '';
foreach ($metaProduct as $key => $value) {
$metaText .= $value->display_key . ' : ' . $value->value . chr(10);
}
$product_item = $item->get_product();
if ($product_item) {
$sku = $product_item->get_sku();
$product .= '<a href="'.wp_get_attachment_url($product_item->get_image_id() ).'">🖼</a> '.$item['name'] . ' x' . $item['quantity'] . ' ' . $item['total'] . $curents . chr(10);
$product_v2 .= '<a href="'.wp_get_attachment_url($product_item->get_image_id() ).'">🖼</a> '.$item['name'] . ' x' . $item['quantity'] . ' ' . $item['total'] . $curents . ' sku(' . $sku . ')' . chr(10);
$product_v3 .= '<a href="'.wp_get_attachment_url($product_item->get_image_id() ).'">🖼</a> '.$item['name'] . ' x' . $item['quantity'] . ' ' . $item['total'] . $curents . ' ' . $metaText . chr(10);
}
}
$list['{product_img_3}'] = $product_v3;
$list['{product_img_2}'] = $product_v2;
$list['{product_img}'] = $product;
return $list;
}
add_filter('tscf_filter_codetemplate', 'meta_wc_function_image', 20, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment