Skip to content
Advertisement

Save WooCommerce order total volume as a custom field for Shipstation

I’ve been coding a WP plugin for Calculating the square inch total volume for an order and send it via custom field to Shipstation:

JavaScript

I uploaded it via SFTP to the sites files and it shows up on WP but when I click activate I get a fatal error:

Fatal error: Uncaught Error: Call to a member function get_cart() on null in /nas/content/live/sfmstaging/wp-content/plugins/boxCalc/boxCalc.php:10 Stack trace: #0 /nas/content/live/sfmstaging/wp-admin/includes/plugin.php(2299): include() #1 /nas/content/live/sfmstaging/wp-admin/plugins.php(191): plugin_sandbox_scrape(‘boxCalc/boxCalc…’) #2 {main} thrown in /nas/content/live/sfmstaging/wp-content/plugins/boxCalc/boxCalc.php on line 10

Am I pulling the cart data right? Is there an issue with the Woocommerce global?

Advertisement

Answer

Note that cart is live customer Object that you can’t get as you are actually doing.

Now in ShipStation plugin documentation the woocommerce_shipstation_export_custom_field_2 filter hook is just to return the meta key of an existing order custom field.

That mean that you need to save the cart total volume as custom order meta data when customer place an order.

Try the following instead:

JavaScript

Code goes in functions.php file of the active child theme (or active theme) or in a plugin file. Tested and works.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement