How to add action button on woocommerce admin order detail page in WordPress

How to add action button on woocommerce admin order detail page in Wordpress

This code is used to add a button to your order page in the admin panel. and this code adds for the function.php file WordPress.

<?php
add_action( 'woocommerce_order_item_add_action_buttons', 'action_woocommerce_order_item_add_action_buttons', 10, 1);

function action_woocommerce_order_item_add_action_buttons( $order ){
 $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
 $order = new WC_Order( $order_id );
 $items = $order->get_items();
 foreach ( $items as $item ) {
 $product_id = $item['product_id'];
 $meta = get_post_meta($product_id);
 $vender_product_link = get_post_meta($product_id, 'venderproductlink', true);
 if(!empty($vender_product_link)){
 echo '<a class="button generate-items" target="_blank" href="'.$vender_product_link1.'">Vender Product Link</a>';
 }   
 }
};
?>
Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us

Fill in the form below or give us a call and we'll contact you. We endeavour to answer all enquiries within 24 hours on business days.