• Resolved pipoulito

    (@pipoulito)


    Hello

    i need to create a custom column with a custom value returned by a custom PHP function.
    If i pu my code in your PHP field area, will it work ?
    thanks

    function get_total_installment_to_order( $order_id ){
    $order    = wc_get_order( $order_id );
    if ( ! $order ) {
    return 0;
    }
    $payment_id = $order->get_meta( ‘_sumo_pp_payment_id’, true );
    if ( ! $payment_id ) {
    return 0;
    }
    $payment = _sumo_pp_get_payment( payment_id );
    if ( ! $payment ) {
    return 0;
    }
    return $payment->get_total_installments();
    }

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author algol.plus

    (@algolplus)

    hello

    follow to https://docs.algolplus.com/algol_order_export/fields/

    add key total_installment

    use this code

    add_filter('woe_get_order_value_total_installment',function ($value, $order,$fieldname) {
    $order = wc_get_order( $order_id );
    if ( ! $order ) {
    return 0;
    }
    $payment_id = $order->get_meta( ‘_sumo_pp_payment_id’, true );
    if ( ! $payment_id ) {
    return 0;
    }
    $payment = _sumo_pp_get_payment( payment_id );
    if ( ! $payment ) {
    return 0;
    }
    return $payment->get_total_installments();
    },10,3);

    Thread Starter pipoulito

    (@pipoulito)

    Hello,

    thanks will it work too if i export as 1 line = 1 product sold ?

    and not 1 line = 1 order ?

    thanks

    Plugin Author algol.plus

    (@algolplus)

    open Setup Fields and set “Fill order details” = All rows

    Thread Starter pipoulito

    (@pipoulito)

    i don’t undestand hw your progam knows that he have to display the PHP result in the column total_installment

    Plugin Author algol.plus

    (@algolplus)

    Thread Starter pipoulito

    (@pipoulito)

    i have executed but i have this error

    Le code que vous essayez d’enregistrer a généré une erreur fatale sur la ligne 13 :syntax error, unexpected end of file

    Plugin Author algol.plus

    (@algolplus)

    please, visit ww.wp.xz.cn and copy whole code .

    And paste code to https://onlinephp.io/ , probably you added some non-printable chars

    Thread Starter pipoulito

    (@pipoulito)

    i have added this at the end and it works !

    thanks

    ,10,3);

    Plugin Author algol.plus

    (@algolplus)

    You’re welcome

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Custom value with PHP’ is closed to new replies.