我将自定义操作添加到订单页面,该页面打印了来自第三方API的送货标签,这是我目前的代码:
add_action('woocommerce_order_actions', 'tcs_woocommerce_order_actions', 10, 1);
function tcs_woocommerce_order_actions($actions)
{
$actions['tcs_print_label_action'] = __("Print shipping label");
return $actions;
}
add_action('woocommerce_order_action_tcs_print_label_action', 'tcs_print_label', 10, 1);
function tcs_print_label($order)
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Shipping Label</title>
<style>
</style>
</head>
<body>
<img src="/example-label.png" alt="" />
<script>
window.print();
//window.history.back();
</script>
</body>
</html>
<?php
// Do something here with the WooCommerce $order object
}
我要添加自定义代码以联系API并获取标签,但有人可以告诉我更好的方法来打印标签,然后重定向回订单吗?