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 * @since 2.7.0 */ protected function update_post_meta( &$refund ) { parent::update_post_meta( $refund ); $updated_props = array(); $changed_props = $refund->get_changes(); $meta_key_to_props = array( '_refund_amount' => 'amount', '_refunded_by' => 'refunded_by', '_refund_reason' => 'reason', ); foreach ( $meta_key_to_props as $meta_key => $prop ) { if ( ! array_key_exists( $prop, $changed_props ) ) { continue; } $value = $refund->{"get_$prop"}( 'edit' ); if ( '' !== $value ? update_post_meta( $refund->get_id(), $meta_key, $value ) : delete_post_meta( $refund->get_id(), $meta_key ) ) { $updated_props[] = $prop; } } } /** * Get a title for the new post type. * * @return string */ protected function get_post_title() { // @codingStandardsIgnoreStart /* translators: %s: Order date */ return sprintf( __( 'Refund – %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreEnd } }