• Resolved fredriktver

    (@fredriktver)


    Hi,

    We have added a custom checkbox to Klarna checkout:

    function add_omnisend_kco_checkbox( $additional_checkboxes ) {
    $additional_checkboxes[] = array(
    'id' => 'omnisend_kco_checkbox',
    'text' => 'Hold meg oppdatert p? nyheter og tilbud.',
    'checked' => false,
    'required' => false,
    );
    return $additional_checkboxes;
    }
    add_filter( 'kco_additional_checkboxes', 'add_omnisend_kco_checkbox' );

    Using this callback function:

    function kco_process_checkboxes( $order_id ) {
    $klarna_order_id = get_post_meta( $order_id, '_transaction_id', true );
    $klarna_order = KCO_WC()->api->get_klarna_order( $klarna_order_id );

    if ( isset( $klarna_order['merchant_requested']['additional_checkboxes'] ) ) {
    foreach ( $klarna_order['merchant_requested']['additional_checkboxes'] as $checkbox ) {
    error_log(json_encode($checkbox));
    }
    }
    }
    add_action( 'kco_wc_payment_complete', 'kco_process_checkboxes' );

    The problem is that checked is always false:

    [15-Aug-2024 12:36:39 UTC] {"id":"omnisend_kco_checkbox","checked":false}

    The only way we made it work was by changing ‘checked’ => true, in add_omnisend_kco_checkbox. How can we fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support louisekrokedil

    (@louisekrokedil)

    Hi,

    If you want to change so the checkbox is checked by default it is correct to change?‘checked’ => true. Our snippet has false by default but you can just change it if you would like it to be checked. Or do you have other issues with the snippet?

    Plugin Support louisekrokedil

    (@louisekrokedil)

    Hi,

    I am setting this ticket to resolved since we have not heard back from you, if you are still experiencing issues please get back to us.

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