Skip to content

Instantly share code, notes, and snippets.

@zorem
Last active August 5, 2020 04:28
Show Gist options
  • Save zorem/1b87ba54f97663de0996871f68b68351 to your computer and use it in GitHub Desktop.
Save zorem/1b87ba54f97663de0996871f68b68351 to your computer and use it in GitHub Desktop.
WooCommerce Shipping Compatibility - Replace "update_label_order_meta_data" function in "class-wc-connect-service-settings-store.php" file in "classes" folder inside plugin
/*
* status_shipped - (0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled))
*/
public function update_label_order_meta_data( $order_id, $new_label_data ) {
$result = $new_label_data;
$labels_data = $this->get_label_order_meta_data( $order_id );
foreach( $labels_data as $index => $label_data ) {
if ( $label_data['label_id'] === $new_label_data->label_id ) {
$result = array_merge( $label_data, (array) $new_label_data );
$labels_data[ $index ] = $result;
if ( ! isset( $label_data['tracking'] ) && isset( $result['tracking'] ) ) {
WC_Connect_Extension_Compatibility::on_new_tracking_number( $order_id, $result['carrier_id'], $result['tracking'] );
if ( class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
if ( function_exists( 'ast_insert_tracking_number' ) ) {
ast_insert_tracking_number($order_id, $result['tracking'], $result['carrier_id'], date("Y-m-d"), 1);
}
}
}
}
}
update_post_meta( $order_id, 'wc_connect_labels', $labels_data );
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment