• Resolved mrblade

    (@mrblade)


    On the order list page I want to change the order number with the product title.
    This file located in /dokan-lite/templates/orders/listing.php and the instruction are $the_order->get_order_number()
    I believe that i should call the class:
    $product_item = new WC_Order_Item( $item->get_name );

    But how i can do?

    thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @mrblade,

    The listing.php is a template file. So you can easily override the template and change the code as you need. I think your code is correct because this is the correct way to get product title inside an order but please make sure that when there are multiple products in a single order, you have the option to manage.

    We can only help you with the file location and function reference but if you need us to do the entire code then it won’t possible for now.

    Let me know if you need further assistance ??

    Cheers!

    • This reply was modified 5 years, 3 months ago by Nazmul Hassan.
    Thread Starter mrblade

    (@mrblade)

    Thanks for your reply :*

    this is a part of the code for listing.php

    
    <?php
    foreach ($user_orders as $order) {
    $the_order = new WC_Order( $order->order_id );
    ?>
    
    <td class="dokan-order-id">
    <?php echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'order_id' => dokan_get_prop( $the_order, 'id' ) ), dokan_get_navigation_url( 'orders' ) ), 'dokan_view_order' ) ) . '"><strong>' . sprintf( __( 'Order %s', 'dokan-lite' ), esc_attr( $the_order->get_order_number() ) ) . '</strong></a>'; ?>
    </td>
    

    i would change number id with item title (or add this).
    If i add in foreach
    $product_item = new WC_Order_Item( $item->get_name ); and in echo
    $product_item->get_name()
    i have an error.
    Can you help me?
    Thanks!

    Hello,

    I can provide a sample code only like below-

    function get_product_title_by_order( $order_id ) {
        $order = wc_get_order( $order_id );
    
        foreach ( $order->get_items( 'line_item' ) as $item ) {
            $product_id    = $item->get_product()->get_id();
            $product       = wc_get_product( $product_id );
            return $product->get_title();
        }
    }
    
    get_product_title_by_order(2782);

    You need to follow such kind of process.

    Thread Starter mrblade

    (@mrblade)

    ok thanks!
    with this i have
    UNCAUGHT ERROR: CALL TO A MEMBER FUNCTION GET_ITEMS()

    sorry, i am a newbie ??
    thanks!

    Hello @mrblade,

    I said that this is an example code. If you have used it directly then you should get an error. We are helpless if you are unable to modify the code as per your need. As per our policy, we are unable to help with the modification of our plugin. I have tried my best to provide each and every information.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘change order id with item name’ is closed to new replies.