Skip to content

Commit

Permalink
Add documentation to mt_show_in_cart_fields filter and add ticket t…
Browse files Browse the repository at this point in the history
…ype argument.
  • Loading branch information
joedolson committed Sep 8, 2024
1 parent 3da71aa commit 04b19d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/mt-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,18 @@ function mt_generate_cart_table( $cart, $format = 'cart' ) {
$hidden = '';
}
$total = $total + ( $price * $count );
$custom = apply_filters( 'mt_show_in_cart_fields', '', $event_id );
/**
* Show custom fields associated with individual cart items.
*
* @hook mt_show_in_cart_fields
*
* @param {string} $fields HTML output of displayed fields. Default empty.
* @param {int} $event_id The event currently displayed.
* @param {string} $type The current ticket type.
*
* @return {string}
*/
$custom = apply_filters( 'mt_show_in_cart_fields', '', $event_id, $type );
// Translators: (number of tickets) at (price per ticket).
$cart_message = sprintf( __( '%1$s at %2$s', 'my-tickets' ), "<span class='count' data-limit='$max'>$count</span>", apply_filters( 'mt_money_format', $price ) );
$output .= "
Expand Down
5 changes: 3 additions & 2 deletions src/mt-fields-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function mt_add_actions() {
// Save field data to cookie/user meta for use in cart.
add_action( 'mt_add_to_cart_ajax_field_handler', 'mt_handle_custom_field', 10, 2 );
// Display field data in shopping cart.
add_filter( 'mt_show_in_cart_fields', 'mt_show_custom_field', 10, 2 );
add_filter( 'mt_show_in_cart_fields', 'mt_show_custom_field', 10, 3 );
// Insert submitted data into Payment post meta.
add_action( 'mt_save_payment_fields', 'mt_insert_custom_field', 10, 3 );
// Display field data in tickets list.
Expand Down Expand Up @@ -245,10 +245,11 @@ function mt_handle_custom_field( $saved, $submit ) {
*
* @param string $content Shopping cart html.
* @param int $event_id Event ID.
* @param string $type Ticket type for this line item.
*
* @return string
*/
function mt_show_custom_field( $content, $event_id ) {
function mt_show_custom_field( $content, $event_id, $type ) {
$custom_fields = mt_get_custom_fields( 'display' );
$return = '';
foreach ( $custom_fields as $name => $field ) {
Expand Down

0 comments on commit 04b19d1

Please sign in to comment.