Action
rpress_edit_discount_form_before_code
On this page
Fires on the Edit Discount form before the Code row.
Runs while the Edit Discount form is being printed, inside the form table, before the Code row. Output complete table rows (tr elements) so the markup stays valid. The callback receives the discount ID and the loaded discount object, which lets you pre-fill your own fields.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$discount_id | int | The discount ID being edited. |
$discount | RPRESS_Discount|false | The discount object loaded with rpress_get_discount(); false when the discount was not found. |
Example#
function my_discount_field_row( $discount_id, $discount ) {
$note = get_post_meta( $discount_id, '_my_discount_note', true );
?>
<tr>
<th scope="row"><label for="my-discount-note"><?php esc_html_e( 'Internal note', 'my-plugin' ); ?></label></th>
<td><input type="text" id="my-discount-note" name="my_discount_note" class="regular-text" value="<?php echo esc_attr( $note ); ?>" /></td>
</tr>
<?php
}
add_action( 'rpress_edit_discount_form_before_code', 'my_discount_field_row', 10, 2 );
Notes#
Printing a field does not save it. Save submitted values from rpress_post_insert_discount (add) or rpress_post_update_discount (edit).
Source#
Fired from:
includes/admin/discounts/edit-discount.php(line 49)
See also#
Was this page helpful?
