• Resolved dkray

    (@dkray)


    Ist es m?glich, dass bei den Bestellungen die effektive Bezahlmethode dargestellt wird (also Twint, Kreditkarte etc.)?

Viewing 1 replies (of 1 total)
  • Plugin Author Ivan Louis

    (@ivanlouis)

    Hallo dkray

    Danke für deine Frage. Die Zahlungsmethode wird zwar auf dem order im field “zahls_payment_method” hinterlegt, jedoch nicht standardm?ssig angezeigt.

    Unten ein Script, das zu funktionieren scheint, für functions.php. (Erstellt von chatGPT)

    Grüsse
    Ivan

    add_filter('manage_edit-shop_order_columns', 'add_zahls_payment_method_column');
    function add_zahls_payment_method_column($columns) {
    $columns['zahls_payment_method'] = __('Zahls-Zahlungsmethode', 'woocommerce');
    return $columns;
    }

    add_action('manage_shop_order_posts_custom_column', 'show_zahls_payment_method_column_content', 10, 2);
    function show_zahls_payment_method_column_content($column, $post_id) {
    if ($column === 'zahls_payment_method') {
    $payment_method = get_post_meta($post_id, 'zahls_payment_method', true);
    echo !empty($payment_method) ? esc_html($payment_method) : '-';
    }
    }

    add_filter('manage_edit-shop_order_sortable_columns', 'make_zahls_payment_method_column_sortable');
    function make_zahls_payment_method_column_sortable($columns) {
    $columns['zahls_payment_method'] = 'zahls_payment_method';
    return $columns;
    }

    add_action('pre_get_posts', 'sort_orders_by_zahls_payment_method');
    function sort_orders_by_zahls_payment_method($query) {
    if (!is_admin() || !$query->is_main_query()) {
    return;
    }

    $orderby = $query->get('orderby');
    if ($orderby === 'zahls_payment_method') {
    $query->set('meta_key', 'zahls_payment_method');
    $query->set('orderby', 'meta_value');
    }
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.