• celestapp

    (@celestapp)


    I’m trying to combine the following shipping details: address 1, house number, house number suffix, postcode, city:

    add_filter(‘woe_get_order_value_custom_address’,function ($value, $order,$fieldname) {
    $value =
    $order->get_shipping_address_1()
    . ‘, ‘ .
    $order->get_shipping_house_number()
    . ‘, ‘ .
    $order->get_shipping_house_number_suffix()
    . ‘, ‘ .
    $order->get_shipping_postcode()
    . ‘, ‘ .
    $order->get_shipping_city();

    return $value;
    },10,3);

    I get an error, while it’s working when I only have:

    add_filter(‘woe_get_order_value_custom_address’,function ($value, $order,$fieldname) {
    $value =
    $order->get_shipping_address_1()
    . ‘, ‘ .

    $order->get_shipping_postcode()
    . ‘, ‘ .
    $order->get_shipping_city();

    return $value;
    },10,3);

    What is going wrong?

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

    (@algolplus)

    Hello

    $order is https://woocommerce.github.io/code-reference/classes/WC-Order.html

    So you should use $order->get_meta("shipping_house_number") and $order->get_meta("shipping_house_number_suffix") to read custom fields.

    thanks, Alex

    Thread Starter celestapp

    (@celestapp)

    I’m not sure what the code should look then. At least it’s not working for me (replacing: . ‘, ‘ . with ‘and’ is not working either)

    add_filter(‘woe_get_order_value_custom_address’,function ($value, $order,$fieldname) {
    
    $value =
    
    $order->get_shipping_address_1()
    
    . ‘, ‘ .
    
    $order->get_meta("shipping_house_number")
    
    . ‘, ‘ . 
    
    $order->get_meta("shipping_house_number_suffix")
    
    . ‘, ‘ .
    
    $order->get_shipping_postcode()
    
    . ‘, ‘ .
    
    $order->get_shipping_city();
    
    return $value;
    
    },10,3);
    Plugin Author algol.plus

    (@algolplus)

    shipping_house_number and shipping_house_number_suffix was example keys, I don’t know exact values.

    run phpMyAdmin , review records in table “wp_postmeta” and find necessary “meta_key”

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘combined shipping address error custom php’ is closed to new replies.