Skip to content

Instantly share code, notes, and snippets.

@darrylmorley
Last active August 1, 2020 22:42
Show Gist options
  • Save darrylmorley/789db0e9b5657d66eb775d872edfac31 to your computer and use it in GitHub Desktop.
Save darrylmorley/789db0e9b5657d66eb775d872edfac31 to your computer and use it in GitHub Desktop.
Delete Object Using CRUD #woocommerce
<?php
/**
* Delete an object, set the ID to 0, and return result.
*
* @param bool $force_delete
* @return bool result
*/
public function delete( $force_delete = false ) {
// Trigger action before deleting from DB. Allows you to adjust some related object props before delete.
do_action( 'woocommerce_before_' . $this->object_type . '_object_delete', $this, $this->data_store );
if ( $this->data_store ) {
$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
$this->set_id( 0 );
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment