Home Forums Theme Support Dokan Modify function in order-functions.php

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Carlos 3 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #68653

    Carlos
    Participant
    Post count: 66

    Hello,

    We need to make a change to the function dokan_sync_insert_order called on order-functions.php. What is the proper way to unhook these actions (lines 272 and 273) so we can customize them?

    add_action( ‘woocommerce_checkout_update_order_meta', ‘dokan_sync_insert_order' );
    add_action( ‘dokan_checkout_update_order_meta', ‘dokan_sync_insert_order' );

    We have tried the following remove_actions, but none of them have worked:

    global $dokan;
    remove_action( ‘woocommerce_checkout_update_order_meta', array( $dokan, ‘dokan_sync_insert_order' ));
    remove_action( ‘dokan_checkout_update_order_meta', array( $dokan, ‘dokan_sync_insert_order' ));

    remove_action( ‘woocommerce_checkout_update_order_meta', ‘dokan_sync_insert_order' );
    remove_action( ‘dokan_checkout_update_order_meta', ‘dokan_sync_insert_order' );

    ——————–

    $dokan = WeDevs_Dokan::init();
    remove_action( ‘woocommerce_checkout_update_order_meta', array( $dokan, ‘dokan_sync_insert_order' ));
    remove_action( ‘dokan_checkout_update_order_meta', array( $dokan, ‘dokan_sync_insert_order' ));

    ———————

    Thanks.

    #68741

    Nayem
    Moderator
    Post count: 6480

    Hello,

    Do you want to override anything?. Then after removing the action you have to add a new action then create a function. In the function, you can override what you want to.

    Thanks.

    #68756

    Carlos
    Participant
    Post count: 66

    Hello,

    Yes, we want to override the function. We have a new action that creates the function, but we haven't been able to make the remove_action work, resulting in duplicate orders.

    What is the correct remove_action code we should use to remove dokan_sync_insert_order?

    Thanks.

    #68831

    Nayem
    Moderator
    Post count: 6480

    Hello,

    I have checked and both are working-

    remove_action( 'woocommerce_checkout_update_order_meta', 'dokan_sync_insert_order' );
    remove_action( 'dokan_checkout_update_order_meta', 'dokan_sync_insert_order' );
    #68839

    Carlos
    Participant
    Post count: 66

    Hello,

    Where are you inserting that code? We have an external plugin that is loading both those lines of code, as well as the other variations we listed earlier, however dokan_sync_insert_order is still being called, resulting in duplicate orders when we call our own instance.

    Thanks.

    #68840

    Nayem
    Moderator
    Post count: 6480

    You can put those codes in your theme's function.php file.

    #68841

    Carlos
    Participant
    Post count: 66

    Thanks for your help. Got it working.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Modify function in order-functions.php’ is closed to new replies.