Customize ‘Mark as Shipped’ Checkbox Default Behaviour

Our plugin provides a feature in the Add Tracking Lightbox that allows users to mark an order as shipped automatically when adding tracking information. By default, the “Mark as Shipped” checkbox is checked. This guide describes how developers can change this default behavior using a custom filter.


Some users may prefer not to mark the order as shipped by default when adding tracking. To accommodate this preference, the AST plugin offers a filter that allows overriding the default state of the “Mark as Shipped” checkbox.

Code Snippet to Uncheck ‘Mark as Shipped’ by Default

Insert the following code into your theme’s functions.php file or a custom plugin:

add_filter( 'wc_ast_default_mark_shipped','wc_ast_default_mark_shipped');
function wc_ast_default_mark_shipped( $checked ) {
    return 0;  // Return 0 to uncheck the 'Mark as Shipped' checkbox by default

Explanation of the Code

  • Filter Hook: wc_ast_default_mark_shipped – This filter allows you to modify the default checked state of the “Mark as Shipped” checkbox.
  • Function: wc_ast_default_mark_shipped($checked) – A custom function hooked to the above filter. It’s passed the current checked state ($checked).
  • Return Value: Returning 0 changes the default state to unchecked. To keep it checked by default, return 1.

Implementing the Code

  1. Edit the Theme or Plugin: Open your theme’s functions.php file or your custom plugin file where you intend to place the code.
  2. Insert the Code: Copy and paste the provided code snippet into the file.
  3. Save the Changes: After inserting the code, save the file. If you’re editing a live site, it’s best to test this change on a staging site first to avoid any disruptions.

Important Notes

  • Testing: Always test code snippets in a staging environment before applying them to a live site to prevent any potential issues.
  • Updates: Customizations made directly in theme files may be overwritten during theme updates. Consider using a child theme or a custom plugin to preserve your changes.

By following this guide, developers can provide users with an alternative default setting for the “Mark as Shipped” checkbox, enhancing the plugin’s flexibility to match different workflow preferences.


Billed annually

Buy Now