1
votes

I want to add a custom button in the page where admin can manually create new order (Admin Order page).

Admin -> Woocommerce -> order -> Add order

After i add product and when clicked edit button can i show a custom button near to Add Meta button ? I cannot find a hook to use.

add_action( 'woocommerce_after_order_itemmeta', 'editable_order_meta_general' );
function editable_order_meta_general(){
  ?>
  <button class="add_values button"><?php _e( 'Add&nbsp;Custom', 'woocommerce' ); ?></button>
  <?php
}

I have added the above code. I got the result but the button is displayed soon after i add the product. I only want the button to display when i click edit button.

This is my error I don't want button here

This is my requirement. I want button here

#UPDATE

When i added the following code, it worked. Is it the right way ? Since woocommerce button in the same field is set display:none; initially .

add_action( 'woocommerce_after_order_itemmeta', 'editable_order_meta_general' );
function editable_order_meta_general(){
  ?>
  <div class="edit" style="display: none;">
  <button class="add_values button"><?php _e( 'Add&nbsp;Custom', 'woocommerce' ); ?></button>
  </div>
  <?php
}

#Answer

As mentioned by Loiz in comment, there is no hook in WooCommerce to achieve this requirement. Have to change logic or something else.

1
There is no available hook for that. You can check yourself in this related source code for html-order-item-meta.php … So you will have to think differently what you are trying to do.LoicTheAztec
Thanks bro @LoicTheAztec. Please post your answer and i can mark it so someone will find usefulmelvin
Is better if you make an update at the end of your question… Also with my first comment here it's just explicit for others.LoicTheAztec

1 Answers

0
votes

The hook you're looking for is woocommerce_order_item_add_action_buttons()

I found this tutorial: https://hungred.com/how-to/woocommerce-hook-custom-button-admin-order-page/

Hope that helps