add_shortcode( 'storno_grund', function( $atts ) { $atts = shortcode_atts( array( 'order_id' => '', ), $atts ); if ( empty( $atts['order_id'] ) ) { return ''; } $order = wc_get_order( absint( $atts['order_id'] ) ); if ( ! $order ) { return ''; } $refunds = $order->get_refunds(); if ( empty( $refunds ) ) { return ''; } $reasons = array(); foreach ( $refunds as $refund ) { $reason = $refund->get_reason(); if ( ! empty( $reason ) ) { $reasons[] = $reason; } } if ( empty( $reasons ) ) { return ''; } return esc_html( implode( ', ', array_unique( $reasons ) ) ); });
Skip to content