WC_Product_Data_Store_CPT::delete PHP Method

delete() public method

Method to delete a product from the database.
public delete ( &$product, array $args = [] )
$args array Array of args to pass to the delete method.
    public function delete(&$product, $args = array())
    {
        $id = $product->get_id();
        $post_type = $product->is_type('variation') ? 'product_variation' : 'product';
        $args = wp_parse_args($args, array('force_delete' => false));
        if ($args['force_delete']) {
            wp_delete_post($product->get_id());
            $product->set_id(0);
        } else {
            wp_trash_post($product->get_id());
            $product->set_status('trash');
        }
        do_action('woocommerce_delete_' . $post_type, $id);
    }