• Resolved simppa999

    (@simppa999)


    Hello,

    Please add payment gateway title for Klarna. Its currently empty and its messing with WPML, by end up empty payment method title on all documents. woocommerce_woocommerce_payments_klarna_settings should have title value.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Mahfuzur Rahman(woo-hc)

    (@mahfuzurwp)

    Hi @simppa999 ,

    Thank you for reaching out! Could you please clarify what you’re looking for regarding the Klarna payment gateway title? Are you asking to add a title for the payment method in the WooCommerce settings, or is there something specific you’d like to adjust to resolve the WPML issue you’re facing?

    Looking forward to your response!

    Thread Starter simppa999

    (@simppa999)

    If you print out the payment method gateway object the property called “title” is empty. And that cause following WPML function to return empty payment method name, so please fix it by adding the title for Klarna payment method. It could be as field on plugin settings or just static “Klarna” would do it.

    <?php

    use WPML\FP\Fns;

    class WCML_Payment_Method_Filter {
    /** @var array */
    private $payment_gateway_cache = [];

    public function add_hooks() {
    add_filter(
    'woocommerce_order_get_payment_method_title',
    Fns::withoutRecursion( Fns::identity(), [ $this, 'payment_method_string' ] ),
    10,
    2
    );
    }

    public function payment_method_string( $title, $object ) {

    if ( ! empty( $title ) && $object->get_id() ) {
    $payment_gateway = $this->get_payment_gateway( $object->get_id() );

    if ( isset( $_POST['payment_method'] ) && $payment_gateway->id !== $_POST['payment_method'] && WC()->payment_gateways() ) {
    $payment_gateways = WC()->payment_gateways()->payment_gateways();
    if ( isset( $payment_gateways[ $_POST['payment_method'] ] ) ) {
    $payment_gateway = $payment_gateways[ $_POST['payment_method'] ];
    }
    }

    if ( $payment_gateway ) {
    $settings = maybe_unserialize( get_option( 'woocommerce_' . $payment_gateway->id . '_settings' ) );

    $title = apply_filters(
    'wpml_translate_single_string',
    ! empty( $settings['title'] ) ? $settings['title'] : $payment_gateway->title,
    'admin_texts_woocommerce_gateways',
    $payment_gateway->id . '_gateway_title'
    );

    if ( $title === $payment_gateway->title ) {
    if ( 'cheque' === $payment_gateway->id && $title === $payment_gateway->title ) {
    $title = _x( $payment_gateway->title, 'Check payment method', 'woocommerce' );
    } else {
    $title = __( $payment_gateway->title, 'woocommerce' );
    }
    }
    }
    }

    return $title;
    }
    • This reply was modified 1 week, 6 days ago by simppa999.
    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello simppa999,

    Thank you for your reply.

    The code you shared appears to be related to WPML.
    For better understanding could share screenshots?
    I want to confirm which Title is empty and how WPML is affected by this.

    I also suggest contacting WPML support and asking if this is something to fix on their end.
    Once I have more information, I will be in a better position to assist you further.

    Best regards.

    Thread Starter simppa999

    (@simppa999)

    Hello, please look on this site: WooCommerce Code Reference and look property called $title. Please add value for that “title” on Klarna payment gateway. As its now empty.

    • This reply was modified 1 week, 4 days ago by simppa999.
    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @simppa999,

    Hi, it looks like your request is a feature suggestion. Please submit your request at the following link: WooCommerce Feature Requests.

    Thread Starter simppa999

    (@simppa999)

    For me it seems more like a bug as all payment’s methods should have title attribute filled.

    Plugin Support Mahfuzur Rahman(woo-hc)

    (@mahfuzurwp)

    Hi @simppa999,

    Thanks for your patience. Since all payment methods should have a title attribute, this does seem like a bug. I recommend submitting a bug report on GitHub so the developers can take a closer look:

    ?? GitHub: https://github.com/Automattic/woocommerce-payments/issues

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.