wclovers

Untitled

Aug 29th, 2023
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. add_action( 'wp_ajax_wcfm_repair_order', function() {
  2.     $order_id = $_POST['order_id'];
  3.     if($order_id) {
  4.         do_action( 'wcfm_manual_order_reset', $order_id, true );
  5.         $order_posted = get_post( $order_id );
  6.         $the_order = wc_get_order( $order_id );
  7.         do_action( 'wcfm_manual_order_processed', $order_id, $order_posted, $the_order );
  8.     }
  9.     die;
  10. });
  11. add_action( 'wcfm_order_details_after_order_table', function( $order ) {
  12.     if( !wcfm_is_vendor() ) {
  13.         echo '<a id="wcfm-order-' . $order->get_id() . '" data-order="' . $order->get_id() . '" href="#" class="wcfm_repair_order add_new_wcfm_ele_dashboard text_tip" style="float:left!important;color:#ffffff!important;margin-right:10px;" data-tip="' . __('Click to regenarate vendor orders', 'wcfm-gosend') . '"><span class="">' . __( 'Repair Vendor Orders', 'wc-frontend-manager-ultimate') . '</span></a>';
  14.         echo '<div class="wcfm_clearfix"></div><br />';
  15. ?>
  16. <script>
  17.     jQuery(document).ready(function($) {
  18.         $('.wcfm_repair_order').click(function( event ) {
  19.             event.preventDefault();
  20.             var rconfirm = confirm( "Do you really want to do this?" );
  21.             if( rconfirm ) {
  22.                 var data = {
  23.                     action : 'wcfm_repair_order',
  24.                     order_id : $('.wcfm_repair_order').data('order')
  25.                 }
  26.                 $.ajax({
  27.                     type: 'POST',
  28.                     url: wcfm_params.ajax_url,
  29.                     data: data,
  30.                     success: function(response) {
  31.                         window.location = window.location.href;
  32.                     }
  33.                 });
  34.             }
  35.             return false;
  36.         });
  37.     });
  38. </script>
  39. <?php
  40.     }
  41. }, 500 );
  42.  
Add Comment
Please, Sign In to add comment