Automattic\WooCommerce\Internal\DataStores\Fulfillments
FulfillmentsDataStore::delete_meta
Method to delete the metadata for a fulfillment.
Method of the class: FulfillmentsDataStore{}
No Hooks.
Returns
null. Nothing (null).
Usage
$FulfillmentsDataStore = new FulfillmentsDataStore(); $FulfillmentsDataStore->delete_meta( $data, $meta ): void;
- $data(Fulfillment) (required) (passed by reference — &)
- The fulfillment object to delete.
- $meta(WC_Meta_Data) (required)
- Meta object (containing at least ->id).
FulfillmentsDataStore::delete_meta() FulfillmentsDataStore::delete meta code WC 10.3.6
public function delete_meta( &$data, $meta ): void {
// Check if the fulfillment and meta are saved.
$data_id = $data->get_id();
// Prevent deletion of metadata from a deleted fulfillment.
if ( $data->get_date_deleted() ) {
throw new \Exception( esc_html__( 'Cannot delete meta from a deleted fulfillment.', 'woocommerce' ) );
}
$meta_id = $meta->id;
if ( ! is_numeric( $data_id ) || $data_id <= 0 || ! is_numeric( $meta_id ) || $meta_id <= 0 ) {
throw new \Exception( esc_html__( 'Invalid fulfillment or meta.', 'woocommerce' ) );
}
// Delete the metadata for the fulfillment.
global $wpdb;
$wpdb->delete(
$wpdb->prefix . 'wc_order_fulfillment_meta',
array(
'fulfillment_id' => $data_id,
'meta_id' => $meta_id,
),
array(
'%d',
'%d',
)
);
}