Hi @astral4ik,
1. Yes, this code snippet will print either Processing or On hold on your PDFs:
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_add_status_to_pdf', 10, 2 );
function wpo_wcpdf_add_status_to_pdf( $template_type, $order ) {
if ( ! empty($order) ) {
$status = wc_get_order_status_name( $order->get_status() );
if ( $status === "On hold" || $status === "Processing" ) {
?>
<tr class="order-status">
<th>Order status: </th>
<td><?php echo wc_get_order_status_name( $order->get_status() ); ?></td>
</tr>
<?php
}
}
}
For the watermark, it is more complex but you can use the structure above & check for the shipping methods (an order can have over 1) using $order->get_shipping_methods(). Then only return the watermark HTML if local_pickup is amongst the shipping methods.
@dpeyou Thanks, it works with order status,
but with shipping method it doesnt work
Could you write right snippet here for me?
Thnks
Hi @astral4ik,
Sorry for the late reply!
As my colleague Darren said: you could have more than one shipping methods in your order (although this is not very common).
That said, if you only have a shipping method in your store, you can get it with this:
if ( $order->get_shipping_method() == 'Local Pickup' ) {
// Your code goes here!
}
However, if you have several shipping methods, it’s a good practice to use a loop for the check, like this:
foreach ( $order->get_shipping_methods() as $shipping_method ) {
if ( $shipping_method['method_id'] == 'local_pickup' ) {
// Your code goes here!
}
}
Hope it helps!