I Got a WooCommerce store with the Shipstation for WooCommerce plugin installed. They provide a simple PHP function to send custom field data associated with an order to ShipStation. Here's the snippet:
add_filter( 'woocommerce_shipstation_export_custom_field_2', 'shipstation_custom_field_2' ); function shipstation_custom_field_2() { return '_meta_key'; // Replace this with the key of your custom field } This works great as long as the _meta_key you want to set is located in the wp_postmeta table. But the meta key is located in wp_woocommerce_order_itemmeta table (the related meta key is _wc_checkout_add_on_value).
Is there some way to get the ShipStation function above to look up _wc_checkout_add_on_value in the wp_woodcommerce_order_itemmeta table?
Or, as a workaround, is there a way to return a fixed text string instead of a meta key? I've tried everything I can think of but can't get it to work. Seems to want a meta key from the wp_postmeta table and nothing else will do.
Here's the logic I think might work here:
- Check for a particular value in the wp_woocommerce_order_itemmeta table for each order
- If the value is found, send a fixed text string for the "shipstation_custom_field_2" that gets send to ShipStation.
I can do the first part of this. It's the second part, sending a fixed value to SS, that I can't seem to get working. Maybe it's impossible with this function.
Any ideas or workarounds would be most welcome.
add_filter( 'woocommerce_shipstation_export_custom_field_2', 'shipstation_custom_field_2' ); function shipstation_custom_field_2() { //return '_meta_key'; // Replace this with the key of your custom field //return 'test'; echo 'test'; }
Источник: https://stackoverflow.com/questions/780 ... oocommerce