• Resolved teowork

    (@teowork)


    Hi Lawrence,

    I’m trying make a reprint button for my custom dasboard and I’m using your star-cloudprnt-for-woocommerce_20200630 version.

    Custom Dashboard Code

    if (isset($_GET['reprint'])) {
    	reprint($_GET['reprint']);
    }
    function reprint($coming_id) {
    	$order_id = $coming_id;
    	do_action('woocommerce_order_action_star_cloudprnt_reprint_action_new');
    	echo header('Location: '.get_home_url().'/wp-admin/admin.php?page=new_order_notification');
    
    }

    order-handler.php code:

    add_action('woocommerce_order_action_star_cloudprnt_reprint_action_new', 'star_cloudprnt_trigger_print', 1, 1 );
    

    but is not working. Do you have suggest for it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor lawrenceowen

    (@lawrenceowen)

    Hi, and thanks for trying to make the improvements that you need.
    I’m not certain why this isn’t working, but I’m keen to help, adding a reprint button would be much quicker than the current method of using an order action.

    My only concern with this code (and I may just not understand the mechanism, I’m really a C++/C# programmer, so PHP is quite new to me), is how the $order_id parameter is passed to the action hook by your reprint($coming_id) function.

    Maybe you should call do_action() like this:
    do_action('woocommerce_order_action_star_cloudprnt_reprint_action_new', $order_id);

    If that doesn’t work then I think you will need to add some logging. Firstly to ensure that the hook is being triggered, an then to see if a valid order id is being passed in to it.

    Thread Starter teowork

    (@teowork)

    Thank you for your detailed answer. Release plugin is awesome.

    Actually, I tried all alternative method as yours but not working. I created new actions and test trigger by change your code but something wrong. Now, I’m thinking change order status like that hold and again processing ?? But it will be bad for completed orders.

    Do you have a suggest for this example URL? I want to use your action with URL like status action.

    
    wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$status_slug.'&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
    • This reply was modified 4 years, 8 months ago by teowork.
    Thread Starter teowork

    (@teowork)

    I Solved the problem. I was sending $order_id . Yes, It was true for function but trigger wanted $order for other processes.

    Worked do_action:

    
    do_action('woocommerce_order_action_star_cloudprnt_reprint_action', $order);
    

    Thank you for opened my mind

    • This reply was modified 4 years, 8 months ago by teowork.
    Plugin Contributor lawrenceowen

    (@lawrenceowen)

    Great, well done getting it working and thanks for letting me know ??

    Hi @teowork

    Can I kindly ask where you are trying to add your ‘Reprint’ button?
    What is your custom dashboard?

    All the best

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Reprint Button’ is closed to new replies.