Search
woogc/sequential_order_number/format - WP Global Cart
17542
documentation-template-default,single,single-documentation,postid-17542,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

woogc/sequential_order_number/format

WP Global Cart / woogc/sequential_order_number/format
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

woogc/sequential_order_number/format

Name: woogc/sequential_order_number/format
Type: Filter
Arguments: (int) $order_number, (int) $order_id

The woogc/sequential_order_number/format filter in WooCommerce allows you to customize the format of the order number generated for new orders within the WooCommerce Global Cart. This filter can be used to modify the default sequential order number by prepending or appending custom prefixes, suffixes, or any other modifications to suit your business needs.

Example Usage

The following code example demonstrates how to customize the order number format by adding a custom prefix to the order number:


    add_filter ( 'woogc/sequential_order_number/format', 'custom_order_number_format', 10, 2 );
    function custom_order_number_format ( $order_number, $order_id )
        {
            $order_number   =   'WHG-' . $order_number;    
            
            return $order_number;
        }

The code should be placed inside a php file on wp-content/mu-plugins folder.

Description of the Code:

  • Filter Hook: woogc/sequential_order_number/format is the filter hook that you use to modify the order number format before it’s returned and assigned to the order.
  • Parameters:
    • $order_number: The original order number that would have been assigned.
    • $order_id: The ID of the order being created.
  • Customization: In this example, the filter prepends the string ‘WHG-‘ to the order number, resulting in a customized order number like WHG-12345 instead of the default sequential number like 12345.

Use Cases:

  • Adding Prefix/Suffix: You can add a unique prefix (e.g., a store code, year, or order category) to the order number to make it more identifiable.
  • Custom Order Formatting: The filter allows you to implement complex order number schemes (e.g., combining the current year, month, or specific product codes).
  • Sequential Number Control: This method ensures that the numbering remains sequential but allows flexibility in format.

This filter is especially useful for businesses that need to integrate specific order numbering schemes for reporting, inventory management, or branding purposes in WooCommerce.

0
Would love your thoughts, please comment.x
()
x