Title: Create label by php activation
Last modified: May 6, 2024

---

# Create label by php activation

 *  [ludsloper](https://wordpress.org/support/users/ludsloper/)
 * (@ludsloper)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/create-label-by-php-activation/)
 *     ```wp-block-code
       use PostNLWooCommerce\Main;
   
       $main = Main::instance();
   
       $order_id = 1234;
   
       $label_params = array(
   
       "action" => "postnl_order_save_form",
   
       "order_id" => $order_id,
   
       "postnl_id_check" => "",
   
       "postnl_insured_shipping" => "",
   
       "postnl_return_no_answer" => "",
   
       "postnl_signature_on_delivfooery" => "",
   
       "postnl_only_home_address" => "",
   
       "postnl_letterbox" => "yes",
   
       "postnl_num_labels" => "",
   
       "postnl_create_return_label" => "",
   
       "postnl_position_printing_labels" => "top-left",
   
       "postnl_label_nonce" => wp_create_nonce('postnl_download_label_nonce'),
   
       "woocommerce-login-nonce" => "",
   
       "_wpnonce" => "",
   
       "woocommerce-reset-password-nonce" => ""
   
       );
   
       $main->shipping_order->save_meta_value($order_id, $label_params);
       ```
   
 * Hi I would like to automatically create a label for a certain order in PHP. If
   I add the following code in functions.php I get the error saying “$main->shipping_order”
   is NULL, what am I doing wrong?
 * Is it possible to create a label for a certain order in PHP, and how so?
    -  This topic was modified 2 years, 1 month ago by [ludsloper](https://wordpress.org/support/users/ludsloper/).

The topic ‘Create label by php activation’ is closed to new replies.

 * ![](https://ps.w.org/woo-postnl/assets/icon-256x256.png?rev=1807921)
 * [PostNL for WooCommerce](https://wordpress.org/plugins/woo-postnl/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-postnl/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-postnl/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-postnl/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-postnl/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-postnl/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [ludsloper](https://wordpress.org/support/users/ludsloper/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/create-label-by-php-activation/)
 * Status: not resolved