Conversation
supportI’m importing orders and want the plugin to renumber orders at the end of the process. If I click Update in the admin, this happens, but not when importing the order items. I execute the following code at the end of the import as it saves the post (order): $order = new WC_Order( $post_id ); $order->calculate_totals(); $order->save(); Despite this the order doesn’t invoice this plugin. Is there a function to do that?
More info: Uncommenting the line: add_action(‘wp_insert_post’, array($this, ‘set_sequential_number’), 10, 2); in the file class-wt-advanced-order-number.php does what I want but I’d still like a way to do this in my code since that will be overwritten when the plugin updates
Hi @sitetherapy-rick , We use the woocommerce_new_order hook, not wp_insert_post in the plugin. Kindly let us know the issue you’re facing when add_action('wp_insert_post', array($this, 'set_sequential_number'), 10, 2); is hidden. Also, please share your WooCommerce system status report (WooCommerce > Status > System status > Get system report) for a better understanding of the issue. You may share the details via this link if you have any privacy concerns.
If I don’t uncomment that line then the order number does not update when I do an import – it uses the default Woo order number. To get the plugin to update the order number I need to open each imported order and click the Update button If I do uncomment the wp_insert_post line the order number correctly updates to the settings I’ve created in your plugin NOTE: You’ll see a some complaints below about woocommerce templates. These are irrelevant since I’m using Breakdance which disables the theme. ` WordPress Environment</p></p> <p>` WordPress Environment WordPress address (URL): https://kaiscissors.biz Site address (URL): https://kaiscissors.biz WC Version: 10.0.4 Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site. Action Scheduler Version: ✔ 3.9.2 Log Directory Writable: ✔ WP Version: 6.8.2 WP Multisite: – WP Memory Limit: 768 MB WP Debug Mode: ✔ WP Cron: – Language: en_US External object cache: ✔ Server Environment Server Info: nginx/1.28.0 Server Architecture: Linux 6.8.0-62-generic x86_64 PHP Version: 8.2.28 PHP Post Max Size: 64 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 8.5.0 OpenSSL/3.0.13 SUHOSIN Installed: – MySQL Version: 8.4.5 Max Upload Size: 64 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ Database WC Database Version: 10.0.4 WC Database Prefix: npw_ Total Database Size: 150.75MB Database Data Size: 111.65MB Database Index Size: 39.10MB npw_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_order_itemmeta: Data: 0.08MB + Index: 0.09MB + Engine InnoDB npw_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_ac_segments: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_actions: Data: 0.11MB + Index: 0.11MB + Engine InnoDB npw_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_logs: Data: 0.06MB + Index: 0.03MB + Engine InnoDB npw_admin_columns: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_breakdance_icon_sets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_breakdance_icons: Data: 2.52MB + Index: 0.34MB + Engine InnoDB npw_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_comments: Data: 22.55MB + Index: 18.09MB + Engine InnoDB npw_ewwwio_images: Data: 1.52MB + Index: 1.75MB + Engine InnoDB npw_ewwwio_queue: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_facetwp_index: Data: 0.14MB + Index: 0.20MB + Engine InnoDB npw_gf_addon_feed: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_gf_entry: Data: 0.50MB + Index: 0.14MB + Engine InnoDB npw_gf_entry_meta: Data: 1.52MB + Index: 2.08MB + Engine InnoDB npw_gf_entry_notes: Data: 1.52MB + Index: 0.17MB + Engine InnoDB npw_gf_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_gf_form_meta: Data: 0.03MB + Index: 0.00MB + Engine InnoDB npw_gf_form_revisions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_gf_form_view: Data: 0.08MB + Index: 0.03MB + Engine InnoDB npw_gf_rest_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_customers: Data: 3.52MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_customers_pairs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_data_pairs: Data: 0.08MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_items: Data: 2.52MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_account: Data: 0.09MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_class: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_customertype: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_inventorysite: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_paymentmethod: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_salesrep: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_salestaxcode: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_shipmethod: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_list_term: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_log: Data: 1.52MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_map_paymentmethod: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_map_promo_code: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_map_shipping_product: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_map_tax: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_map_wq_cf: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_product_pairs: Data: 0.05MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_variation_pairs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_mw_wc_qbo_desk_qbd_vendors: Data: 0.23MB + Index: 0.00MB + Engine InnoDB npw_options: Data: 3.36MB + Index: 1.56MB + Engine InnoDB npw_oses_attachments: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_oses_clicks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_oses_email_attachments: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_oses_emails: Data: 22.52MB + Index: 0.11MB + Engine InnoDB npw_oses_failures: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_oses_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_pmxe_exports: Data: 0.08MB + Index: 0.00MB + Engine InnoDB npw_pmxe_google_cats: Data: 0.39MB + Index: 0.00MB + Engine InnoDB npw_pmxe_posts: Data: 0.09MB + Index: 0.00MB + Engine InnoDB npw_pmxe_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_pmxi_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_pmxi_geocoding: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_pmxi_hash: Data: 4.52MB + Index: 0.00MB + Engine InnoDB npw_pmxi_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_pmxi_images: Data: 0.14MB + Index: 0.00MB + Engine InnoDB npw_pmxi_imports: Data: 0.11MB + Index: 0.00MB + Engine InnoDB npw_pmxi_posts: Data: 0.13MB + Index: 0.00MB + Engine InnoDB npw_pmxi_templates: Data: 0.14MB + Index: 0.00MB + Engine InnoDB npw_postmark_log: Data: 3.52MB + Index: 0.00MB + Engine InnoDB npw_postmeta: Data: 5.52MB + Index: 3.03MB + Engine InnoDB npw_posts: Data: 1.52MB + Index: 0.52MB + Engine InnoDB npw_redirection_404: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_redirection_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_redirection_items: Data: 0.02MB + Index: 0.09MB + Engine InnoDB npw_redirection_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_relevanssi: Data: 2.52MB + Index: 4.55MB + Engine InnoDB npw_relevanssi_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_relevanssi_stopwords: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_taxjar_record_queue: Data: 0.28MB + Index: 0.16MB + Engine InnoDB npw_term_relationships: Data: 0.11MB + Index: 0.08MB + Engine InnoDB npw_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_termmeta: Data: 0.06MB + Index: 0.03MB + Engine InnoDB npw_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_trustindex_google_reviews: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_usermeta: Data: 1.52MB + Index: 3.03MB + Engine InnoDB npw_users: Data: 0.19MB + Index: 0.22MB + Engine InnoDB npw_wanc_notice: Data: 0.06MB + Index: 0.00MB + Engine InnoDB npw_wc_admin_note_actions: Data: 0.09MB + Index: 0.02MB + Engine InnoDB npw_wc_admin_notes: Data: 0.11MB + Index: 0.00MB + Engine InnoDB npw_wc_avatax_tax_codes: Data: 0.36MB + Index: 0.00MB + Engine InnoDB npw_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wc_customer_lookup: Data: 0.13MB + Index: 0.11MB + Engine InnoDB npw_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_wc_order_product_lookup: Data: 0.02MB + Index: 0.08MB + Engine InnoDB npw_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB npw_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_wc_product_attributes_lookup: Data: 0.05MB + Index: 0.02MB + Engine InnoDB npw_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_wc_product_meta_lookup: Data: 0.06MB + Index: 0.11MB + Engine InnoDB npw_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_wc_reserved_stock: Data: 0.48MB + Index: 0.00MB + Engine InnoDB npw_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wfFileMods: Data: 7.52MB + Index: 0.00MB + Engine InnoDB npw_wfauditevents: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wfblockediplog: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wfblocks7: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_wfconfig: Data: 1.52MB + Index: 0.00MB + Engine InnoDB npw_wfcrawlers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wffilechanges: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_wffilemods: Data: 7.52MB + Index: 0.00MB + Engine InnoDB npw_wfhits: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_wfhoover: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_wfissues: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_wfknownfilelist...
More info: Uncommenting the line: add_action(‘wp_insert_post’, array($this, ‘set_sequential_number’), 10, 2); in the file class-wt-advanced-order-number.php does what I want but I’d still like a way to do this in my code since that will be overwritten when the plugin updates
Hi @sitetherapy-rick , We use the woocommerce_new_order hook, not wp_insert_post in the plugin. Kindly let us know the issue you’re facing when add_action('wp_insert_post', array($this, 'set_sequential_number'), 10, 2); is hidden. Also, please share your WooCommerce system status report (WooCommerce > Status > System status > Get system report) for a better understanding of the issue. You may share the details via this link if you have any privacy concerns.
If I don’t uncomment that line then the order number does not update when I do an import – it uses the default Woo order number. To get the plugin to update the order number I need to open each imported order and click the Update button If I do uncomment the wp_insert_post line the order number correctly updates to the settings I’ve created in your plugin NOTE: You’ll see a some complaints below about woocommerce templates. These are irrelevant since I’m using Breakdance which disables the theme. ` WordPress Environment</p></p> <p>` WordPress Environment WordPress address (URL): https://kaiscissors.biz Site address (URL): https://kaiscissors.biz WC Version: 10.0.4 Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site. Action Scheduler Version: ✔ 3.9.2 Log Directory Writable: ✔ WP Version: 6.8.2 WP Multisite: – WP Memory Limit: 768 MB WP Debug Mode: ✔ WP Cron: – Language: en_US External object cache: ✔ Server Environment Server Info: nginx/1.28.0 Server Architecture: Linux 6.8.0-62-generic x86_64 PHP Version: 8.2.28 PHP Post Max Size: 64 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 8.5.0 OpenSSL/3.0.13 SUHOSIN Installed: – MySQL Version: 8.4.5 Max Upload Size: 64 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ Database WC Database Version: 10.0.4 WC Database Prefix: npw_ Total Database Size: 150.75MB Database Data Size: 111.65MB Database Index Size: 39.10MB npw_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_order_itemmeta: Data: 0.08MB + Index: 0.09MB + Engine InnoDB npw_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB npw_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB + Engine InnoDB npw_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB npw_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB npw_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_ac_segments: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_actions: Data: 0.11MB + Index: 0.11MB + Engine InnoDB npw_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB npw_actionscheduler_logs: Data: 0.06MB + Index: 0.03MB + Engine InnoDB npw_admin_columns: Data: 0.02MB +...
Hi @sitetherapy-rick , When importing orders programmatically, the woocommerce_new_order hook may not always fire as expected. This can prevent sequential order numbers from being assigned automatically. You can call the sequential order number function directly in your import code. Option 1- Call the function directly: // Force sequential order number assignment if ( class_exists( 'Wt_Advanced_Order_Number' ) ) { $temp_instance = new Wt_Advanced_Order_Number(); $temp_instance->set_sequential_number( $post_id ); } Option 2- Use the hook that works for manual updates: $order = new WC_Order( $post_id ); $order->calculate_totals(); $order->save(); // Trigger the sequential order number assignment do_action( 'woocommerce_process_shop_order_meta', $post_id, $order );