Add discount codes to ticket booking list
WordPress Event Management, Calendars & Registration › Forums › General Question › Add discount codes to ticket booking list
This topic contains 6 replies, has 2 voices, and was last updated by Alex Steer 10 years, 3 months ago.
-
AuthorPosts
-
June 29, 2015 at 9:21 pm #17607
Is there a way to display and record the discount codes used on the bookings list?
It’s not showing on my list so there is no way to tell which code was use on a transaction without working it out.
Alex Steer
June 29, 2015 at 11:40 pm #17617This one is strange.
I have the dicount code column on my CSV but no code is in the cell.
It isn’t in the booking info single view either.
Alex Steer
June 30, 2015 at 10:59 pm #17637Hi Alex,
Yes, you’re right this should appear in the booking admin. In lieu of a more permanent solution (which will be subject to any potential reorganising of that screen) please us the following snippet which displays the VAT & discount code used on the booking admin page.
//Add metabox add_action( 'admin_menu', function(){ add_meta_box( 'my-discounts-tax', 'Discounts and tax', 'my_discount_tax_metabox_render', 'event_page_bookings', 'side' ); }); //Render metabox contents function my_discount_tax_metabox_render( $booking ){ //Discount $discount = get_post_meta( $booking->ID, '_eo_booking_discount', true ); $code = isset( $discount['code'] ) ? $discount['code'] : false; $amount = get_post_meta( $booking->ID, '_eo_booking_discount_amount', true ); printf( '<p>Discount code: %s</p>', esc_html( $code ) ); printf( '<p>Discount: %s</p>', eo_format_price( floatval( $amount ) ) ); //VAT $vat_amount = get_post_meta( $booking->ID, '_eo_booking_vat_amount', true ); $vat_rate = get_post_meta( $booking->ID, '_eo_booking_vat_percent', true ); printf( '<p>VAT (%s%%): %s</p>', intval( $vat_rate ), eo_format_price( floatval( $vat_amount ) ) ); }The fact the discount code doesn’t appear in the CSV is a bug which I’ll look into.
Stephen Harris
July 1, 2015 at 1:09 am #17650Hi Stephen,
Thanks for this it looks much better in the admin now.
I like this box 🙂 could we mod it a little for the benefit of all.
Idea…
Is it possible to have the box as a quick breakdown?
Example:
Transaction Overview<br>
Ticket Value (x1): £342<br>
VAT (20%): £47.88<br>
Discount Code: 30SOM<br>
Discount (30%): £102.60<br>
Grand Total: £287.28<br>This would look cool.
Alex Steer
July 1, 2015 at 10:40 pm #17670You can display the tickets with:
$tickets = eo_get_booking_tickets( $booking->ID ); if( $tickets ){ foreach( $tickets as $ticket ){ printf( '<p>%s : %s (x%d)</p>', esc_html( $ticket->ticket_name ), eo_format_price( $ticket->ticket_price ), intval( $ticket->ticket_quantity ) ); }and the total with
$total = eo_get_booking_meta( $booking->ID, 'booking_amount' ); echo eo_format_price( $total );Stephen Harris
July 2, 2015 at 10:55 pm #17707Thanks Stephen that worked a treat!
I have taken it further for anyone interested – please feel free to tidy or amend.
function my_discount_tax_metabox_render( $booking ){ // Tickets $tickets = eo_get_booking_tickets( $booking->ID ); if( $tickets ){ $ticketsum = 0; foreach( $tickets as $ticket ){ printf( '%s : %s (x%d)
', esc_html( $ticket->ticket_name ), eo_format_price( $ticket->ticket_price ), intval( $ticket->ticket_quantity ) ); $ticketsum+= $ticket->ticket_price; } printf('<hr>'); echo 'Booking value:Â ' . eo_format_price( $ticketsum ); } // VAT $vat_amount = get_post_meta( $booking->ID, '_eo_booking_vat_amount', true ); $vat_rate = get_post_meta( $booking->ID, '_eo_booking_vat_percent', true ); printf( 'VAT (%s%%): %s
', intval( $vat_rate ), eo_format_price( floatval( $vat_amount ) ) ); // VAT Total $vat_total = $ticketsum + $vat_amount; printf('Subtotal:Â ' . eo_format_price( $vat_total ) . '
<hr>'); // Discount code $discount = get_post_meta( $booking->ID, '_eo_booking_discount', true ); $code = isset( $discount['code'] ) ? $discount['code'] : false; $amount = get_post_meta( $booking->ID, '_eo_booking_discount_amount', true ); printf( 'Discount code: %s
', esc_html( $code ) ); // Discount type amount $distype = isset( $discount['code'] ) ? ' (' . $discount['discount_type'] : false; $disamt = isset( $discount['code'] ) ? $discount['discount'] . ') ' : false; printf( 'Discount:'. $distype . 'Â ' . $disamt .' - %s
<hr>', eo_format_price( floatval( $amount ) ) ); // Final amount $total = eo_get_booking_meta( $booking->ID, 'booking_amount' ); printf('Final total:Â ' . eo_format_price( $total ) . '
'); }Alex Steer
July 23, 2015 at 10:09 pm #18044Stephen,
The discount code is still not showing on the CSV… Is this due to be fixed?
Also in the CSV, is it possible to report:
Discount value (eg. -£35)
Discount type (eg. 40%)
VAT amount and percentageThanks
Alex Steer
-
AuthorPosts