Filter no longer working
-
I’ve inherited a new client has been using this filter successfully for a long time, but recently it stopped working. The filter would change the transaction name so that it shows in the Stripe dashboard in this format:
Order: #123456 – Payment for Cool ProductThis strikes me as odd, because I can’t find any reference to this filer online except for a couple of places having the same issue. Even older versions of the plugin as far back as 9.5 have no reference to it in the source. Yet I have seen with my own eyes, their Stripe dashboard showing the modified transaction descriptions (up until it stopped working).
My question: Is it at all still possible to modify it?Here’s the filter in question (from functions.php):
add_filter(‘wc_stripe_payment_description’, function($description, $order){
$items = $order->get_items();
$product_names = [];
foreach ($items as $item) {
$product = wc_get_product($item[‘product_id’]);
if ($product) {
$product_names[] = $product->get_title();
}
}
if (!empty($product_names)) {
return sprintf(‘Order: #%s – Payment for %s’, $order->get_order_number(), implode(‘, ‘, $product_names));
}
return $description; // Fallback
}, 10, 2);
You must be logged in to reply to this topic.