Home Forums WoodMart support forum Custom my account page tab with HTML Block Reply To: Custom my account page tab with HTML Block

#271969

JanDaDa
Participant

Aizan,

Could you maybe remove the following code from my guide? I pasted also a code to add custom column to the orders page. Maybe also usefull for ppl but not needed for the guide.. 😉

Code which can be removed:

/**
     * Adds a new column to the "My Orders" table in the account.
     *
     * @param string[] $columns the columns in the orders table
     * @return string[] updated columns
     */
    function th_wc_add_my_account_orders_column( $columns ) {

        $new_columns = array();

        foreach ( $columns as $key => $name ) {

            $new_columns[ $key ] = $name;

            // add referentienummer after order status column
            if ( 'order-status' === $key ) {
                $new_columns['referentie_nummer'] = __( 'Referentienummer', 'textdomain' );
            }
        }

        return $new_columns;
    }
    add_filter( 'woocommerce_my_account_my_orders_columns', 'th_wc_add_my_account_orders_column' );

    /**
     * Adds data to the custom "new-data" column in "My Account > Orders".
     *
     * @param \WC_Order $order the order object for the row
     */
    function th_wc_my_orders_new_data_column( $order ) {

        $new_data = get_post_meta( $order->get_id(), 'referentie_nummer', true ); // Get custom order meta
        echo ! empty( $new_data ) ? $new_data : '–';
        
    }
    add_action( 'woocommerce_my_account_my_orders_column_referentie_nummer', 'th_wc_my_orders_new_data_column' );

Thanks in advance!