Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author jesusangel.delpozo

    (@jesusangeldelpozo)

    Hi,

    I’m sorry. WordPress doesn’t notify new supports threads and I check this site from time to time. I hadn’t seen your message.

    I think your sugestion is feasible, although it will take some time to implement it.

    Kind regards,

    Thread Starter Art Project Group

    (@artprojectgroup)

    Don’t worry Jesús, sometimes I have the same problem with my plugins 😉

    Kind regards.

    Plugin Author jesusangel.delpozo

    (@jesusangeldelpozo)

    Solved in version 1.0.10. Thanks to @enbata

    por petición de algunos clientes necesitamos que en la pasarela aparezcan las IDs que utilizan en su aplicación de facturación (para temas de contabilidad).

    Para conseguir esto hemos añadido dos filtros para que se pueda regenerar la ID que se manda a la pasarela:

    wc_myredsys_merchant_order_encode: Para generar la Ds_Order que se mandara a la pasarela.
    wc_myredsys_merchant_order_decode: Volver a conseguir la ID de la compra a partir del Ds_Order devuelto por la pasarela.

    Un ejemplo de implementación seria (extrapolada de una implementación real):

    <?php

    function uniqueOrderIdEncode( $unique_order_id, $order_id ){
    $order_id = MyCustomClass::createOrder( $order_id ); // Llamada a la aplicación de facturación para conseguir la ID que se guarda en el metadato ‘_my_order_id’
    if ( $order_id ):
    $my_order_id = get_post_meta( $order_id, “_my_order_id”, TRUE );
    $unique_order_id = str_pad( $my_order_id . date( ‘is’ ), 12, ‘0’, STR_PAD_LEFT );
    endif;

    return $unique_order_id;
    }

    function uniqueOrderIdDecode( $unique_order_id ){
    global $wpdb;

    $my_order_id = substr( $unique_order_id, 1, 7 );
    $results = $wpdb->get_results( “select post_id, meta_key from ” . $wpdb->postmeta . ” where meta_key = ‘_my_order_id’ and meta_value = ‘” . $my_order_id . “‘”);
    if ( ! empty($results) ):
    $result = array_pop($results);
    $unique_order_id = $result->post_id;
    endif;

    return $unique_order_id;
    }

    Thread Starter Art Project Group

    (@artprojectgroup)

    Thanks Jesús and @enbata.

    I’ll check it and I’ll make some test with this two new filters.

    Kind regards.

    Hi,

    the two filters takes two arguments each one. So the second filter example posted by Jesús must be:

    <?php
    
    function uniqueOrderIdDecode( $order_id, $ds_order ){
        global $wpdb;
    
        $my_order_id = substr( $ds_order, 1, 7 );
        $results = $wpdb->get_results( "select post_id, meta_key from " . $wpdb->postmeta . " where meta_key = '_my_order_id' and meta_value = '" . $my_order_id . "'");
        if ( ! empty($results) ):
            $result = array_pop($results);
            $order_id = $result->post_id;
        endif;
    
        return $order_id;
    }
    
    // Conseguir la ID de compra de la Ds_Order
    add_filter("wc_myredsys_merchant_order_decode", 'uniqueOrderIdDecode', 1, 2);

    The first one is correct.

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Order ID’ is closed to new replies.