I can get Order ID using the expression {order_id} like the screenshot below.
Is there any expression by which I can get the product name just like Order Id. This is a payment gateway plugin so editing the plugin files would be the last thing I want to do. Thanks.
Some intellectuals have down voted my question without giving any glimpse of their knowledge base. But for some poors like me, Here's what i found :
file: plugins/telr/class-wc-gateway-telr-checkout-handler.php
method: private function generate_request($order)
find:
$cart_desc = trim(wc_gateway_telr()->settings->__get('cart_desc'));
if (empty($cart_desc)) {
$cart_desc ='Order {order_id}';
}
$cart_desc = preg_replace('/{order_id}/i', $order_id, $cart_desc);
add_post_meta($order_id, '_telr_cartdesc', $cart_desc);
replace with:
$cart_desc = trim(wc_gateway_telr()->settings->__get('cart_desc'));
if (empty($cart_desc)) {
$cart_desc ='Order {order_id}';
}
$order_items = $order->get_items();
$productNames = array();
foreach ($order_items as $product_data) {
$productInfo = $product_data->get_data();
$productNames[] = $productInfo['name'];
}
$cartProducts = implode(", ", $productNames);
$cart_desc = preg_replace('/{order_id}/i', $order_id, $cart_desc);
$cart_desc = preg_replace('/{product_names}/i', $cartProducts, $cart_desc);
$cart_desc = substr($cart_desc, 0, 63);
add_post_meta($order_id, '_telr_cartdesc', $cart_desc);
after this, {product_names} will be replaced by ',' separated product names & final description string will be trimmed until 63 characters (as that is the length that a description can have)