nguyenminh

Adding suffix and prefix to WooCommerce order number without using a plugin

add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number', 1, 2);

function change_woocommerce_order_number( $order_id, $order ) {
    $prefix = '#SAM-';
    $suffix = '-' . date(Y); 
    // You can use either one of $order->id (or) $order_id
    // Both will work
    return $prefix .  sprintf("%02d", $order->id) . $suffix;
}

Categorised in: Tổng hợp

0 Comments for "Adding suffix and prefix to WooCommerce order number without using a plugin"

2 thoughts on “Adding suffix and prefix to WooCommerce order number without using a plugin”

  1. admin says:

    You can try str_pad($month, 2, ‘0’, STR_PAD_LEFT);

  2. Hello, I enjoy reading through your article post. I wanted
    to write a little comment to support you.

Leave a Reply

Your email address will not be published. Required fields are marked *