get_id(); if ( ! $id ) { return; } wp_delete_post( $id ); $order->set_id( 0 ); do_action( 'woocommerce_delete_order_refund', $id ); } /** * Read refund data. Can be overridden by child classes to load other props. * * @param WC_Order $refund Refund object. * @param object $post_object Post object. * @since 3.0.0 */ protected function read_order_data( &$refund, $post_object ) { parent::read_order_data( $refund, $post_object ); $id = $refund->get_id(); $refund->set_props( array( 'amount' => get_post_meta( $id, '_refund_amount', true ), 'refunded_by' => metadata_exists( 'post', $id, '_refunded_by' ) ? get_post_meta( $id, '_refunded_by', true ) : absint( $post_object->post_author ), 'reason' => metadata_exists( 'post', $id, '_refund_reason' ) ? get_post_meta( $id, '_refund_reason', true ) : $post_object->post_excerpt, ) ); } /** * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. * * @param WC_Order $refund Refund object. * @since 3.0.0 */ protected function update_post_meta( &$refund ) { parent::update_post_meta( $refund ); $updated_props = array(); $meta_key_to_props = array( '_refund_amount' => 'amount', '_refunded_by' => 'refunded_by', '_refund_reason' => 'reason', ); $props_to_update = $this->get_props_to_update( $refund, $meta_key_to_props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $refund->{"get_$prop"}( 'edit' ); update_post_meta( $refund->get_id(), $meta_key, $value ); $updated_props[] = $prop; } do_action( 'woocommerce_order_refund_object_updated_props', $refund, $updated_props ); } /** * Get a title for the new post type. * * @return string */ protected function get_post_title() { return sprintf( /* translators: %s: Order date */ __( 'Refund – %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.UnorderedPlaceholdersText ); } }