Skip to content

Commit 96c5f77

Browse files
committed
Fix description formatting for single item orders
1 parent 93f7a02 commit 96c5f77

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

woocommerce-gateway-lightning.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ protected static function make_desc($order) {
248248
$total = $order->get_total() . ' ' .$order->get_currency();
249249
$desc = get_bloginfo('name') . ': ' . $total . ' for ';
250250
$products = $order->get_items();
251-
while (strlen($desc) < 100 && count($products)) {
251+
for ($n=0; strlen($desc) < 100 && count($products); $n++) {
252252
$product = array_shift($products);
253253
if (count($products)) $desc .= $product['name'] . ' x ' . $product['qty'] . ', ';
254-
else $desc = substr($desc, 0, -2) . ' and ' . $product['name'].' x '.$product['qty'];
254+
else $desc = ($n ? substr($desc, 0, -2) . ' and ' : $desc) . $product['name'].' x '.$product['qty'];
255255
}
256256
if (count($products)) $desc = substr($desc, 0, -2) . ' and ' . count($products) . ' more items';
257-
return str_replace('"', '', $desc); // c-lightning's json parser doesn't like these, should eventually be fixed
257+
return $desc;
258258
}
259259

260260
protected static function format_msat($msat) {

0 commit comments

Comments
 (0)