How Can We Help?
< Back
You are here:
Print

Developer / Advanced Documentation

Post Meta Fields from Cost of Shipping

On each of the WooCommerce Orders, there are a couple new meta fields stored in the database:

'_wc_cost_of_shipping' // (value format: Float)

This meta field is associated to the float (read as: decimal) value associated with the cost of shipping


'_wc_cos_method'  // (value format: String)

This meta field is associated with the method in which the cost of shipping was stored. Currently, this would be one String of [ manual | shipstation | wc_services ]


'_wc_cos_history' // (value format: array of associated arrays, [ [ 'method' => $method, 'cos' => $cost ] ]  )

Introduced in 1.3.0, this meta field stores an Array of historical Cost of Shipping data for this WC_Order. This is only done if the Cost of Shipping has been modified after the first value was saved in order to save one additional database row for each order.

Action Reference

do_action( 'wc_cos_before_cost_of_shipping_stored', $order_id, $cos, $method );

Executed just prior to retrieving the old data and storing the new method and cost, as well as the Historical Cost of Shipping Meta.

do_action( 'wc_cos_after_cost_of_shipping_stored', $order_id, $cos, $method );

Executed just after storing the new method, cost of shipping, and if applicable, historical data.

do_action( 'wc_cos_before_ajax_set_shipping_cost', $post_id, $cos, 'manual' );

Executed just before the “manual edit” of the Cost of Shipping callback from the WooCommerce Edit Order screen.

do_action( 'wc_cos_after_ajax_set_shipping_cost', $post_id, $cos, 'manual' );

Executed just after the storing of the manually input value from the WooCommerce Edit Order screen.

do_action( 'wc_cos_before_ajax_set_label_cost_wcs', $post_id );

Only applicable if using WooCommerce Services: executed if the import or re-import buttons are pressed in the meta box on the WooCommerce Edit Order screen. This executes just prior to attempting to save the Cost of Shipping into the meta fields.

do_action( 'wc_cos_after_ajax_set_label_cost_wcs', $post_id );

Only applicable if using WooCommerce Services: executed if the import or re-import buttons are pressed in the meta box on the WooCommerce Edit Order screen. This executes just after the Cost of Shipping meta fields successfully saved.

do_action( 'wc_cos_after_ajax_no_labels_wcs', $post_id );

Only applicable if using WooCommerce Services: executed if there were No WooCommerce Services Shipping labels to (re-)import.

Filter Reference

apply_filters( 'wc_cos_store_cost_of_shipping', $cos, $order_id );

Primary way of influencing the Cost of Shipping after the Shipping Gateway of choice has passed data back. Found in the primary and only method which saves the Cost of Shipping data.

apply_filters( 'wc_cos_store_cost_of_shipping_method', $method, $order_id );

Change the String which describes the method in which the Cost of Shipping was saved.

Table of Contents