get_items() as $item ) : ?>
get_product();
$sku = $product && $product->get_sku() ? $product->get_sku() : '';
// Both figures ex-tax, so unit × quantity reconciles with the
// ex-tax subtotal below. Unit is the list price before any
// line discount; the line total is after it.
$unit = (float) $order->get_item_subtotal( $item, false, true );
$lineTot = (float) $order->get_line_total( $item, false, true );
?>
get_order_number();
$orderDate = Helpers::date( $order );
// The print date is when this label is produced, which is what a dispatch
// desk cares about. The order's own date stays on the invoice.
$printDate = Helpers::date( time(), true );
$isCompact = $heightMm < 90;
$classes = 'alabel'
. ( $isCompact ? ' alabel--compact' : '' )
. ( $oneCol ? ' alabel--onecol' : '' );
$hasHead = ( $showLogo && '' !== $logo ) || $showOid || ( $showOdate && '' !== $orderDate );
// Without rotation the width is pinned and the height is content-defined,
// so a long order flows onto the next label. With rotation the content box
// keeps its natural size but is turned inside a swapped-size wrapper that
// owns the page break — which is how a printer whose driver refuses to
// rotate still produces an upright label.
if ( 0 !== $rotate ) {
$boxStyle = sprintf(
'position:absolute;top:0;left:0;width:%dmm;height:%dmm;--logo-w:%dmm;overflow:hidden;transform-origin:top left;%s',
$widthMm,
$heightMm,
$logoWmm,
90 === $rotate
? sprintf( 'transform:translateX(%dmm) rotate(90deg)', $heightMm )
: sprintf( 'transform:translateY(%dmm) rotate(-90deg)', $widthMm )
);
$wrapStyle = sprintf(
'position:relative;width:%dmm;height:%dmm;overflow:hidden;page-break-after:always',
$heightMm,
$widthMm
);
} else {
$boxStyle = sprintf( 'width:%dmm;--logo-w:%dmm', $widthMm, $logoWmm );
$wrapStyle = '';
}
// The address is assembled from its parts rather than taken from
// WooCommerce's formatted address, which repeats the name and postcode and
// appends the country — each of which appears exactly once here.
$name = trim( $order->get_formatted_shipping_full_name() );
$name = '' !== $name ? $name : trim( $order->get_formatted_billing_full_name() );
$country = $order->get_shipping_country() ?: $order->get_billing_country();
$state = Helpers::stateName( $country, $order->get_shipping_state() ?: $order->get_billing_state() );
$city = $order->get_shipping_city() ?: $order->get_billing_city();
$addr1 = $order->get_shipping_address_1() ?: $order->get_billing_address_1();
$addr2 = $order->get_shipping_address_2() ?: $order->get_billing_address_2();
$address = implode( '، ', array_filter( [ $state, $city, $addr1, $addr2 ] ) );
$postcode = $order->get_shipping_postcode() ?: $order->get_billing_postcode();
$phone = Helpers::recipientPhone( $order );
$note = $order->get_customer_note();
?>