I have a printed-syllabus-fee that users can elect to add on to their order to receive a printed version of the event syllabus. While this works perfectly when no promotional code has been applied, when a promo code is active, I want to zero out the cost of the printed syllabus fee. The below code seems to accomplish this, but when I checkout, there is still at $75 charge that remains “unpaid.” That leads me to believe the old line item still exists. Is there some way to remove a line item? Something like the inverse of the $pre_tax_subtotal->add_child_line_item call?
function bc_ee_apply_transaction_surcharge( EE_Checkout $checkout ) {
//If the promotions add-on is not active we don’t need any of this to run.
if( class_exists(‘EEM_Promotion’) ) {
//$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
//Create an array to hold the event ID’s.
$EVT_IDs = array();
//Pull the event ID’s from the registrations.
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
if ( $event instanceof EE_Event ) {
$EVT_IDs[] = $event->ID();
}
}
}
//We only need each event ID once.
$EVT_IDs = array_unique($EVT_IDs);
//Pull any promotions linked to the events in the cart.
$promotions = EEM_Promotion::instance()->count(
array(
array(
‘Promotion_Object.POB_type’ => ‘Event’,
‘Promotion_Object.OBJ_ID’ => array( ‘IN’, $EVT_IDs )
)
)
);
// if Promo Active, then set surcharge to zero
if( $promotions != 0 ) {
// SURCHARGE DETAILS – EDIT THIS
$surcharge_details = apply_filters(
‘FHEE__bc_ee_apply_transaction_surcharge__surcharge_details’,
array(
// name for surcharge that will be displayed, ie: ‘printing fee’
‘name’ => ‘Printed syllabus fee’,
// unique code used to identify surcharge in the db, ie: ‘print-at-home-fee’
‘code’ => ‘printed-syllabus-fee’,
// ‘fee for printing tickets’
‘description’ => ‘fee for printed syllabus’,
// surcharge amount
‘unit_price’ => 0.00,
// whether or not tax is applied on top of the surcharge
‘taxable’ => false,
)
);
} // end if ( $transaction instanceof EE_Transaction )
} // end if ( $checkout instanceof EE_Checkout )
} // end if( class_exists(‘EEM_Promotion’) )
else {
// DEFAULT SURCHARGE DETAILS – EDIT THIS
$surcharge_details = apply_filters(
‘FHEE__bc_ee_apply_transaction_surcharge__surcharge_details’,
array(
// name for surcharge that will be displayed, ie: ‘printing fee’
‘name’ => ‘Printed syllabus fee’,
// unique code used to identify surcharge in the db, ie: ‘print-at-home-fee’
‘code’ => ‘printed-syllabus-fee’,
// ‘fee for printing tickets’
‘description’ => ‘fee for printed syllabus’,
// surcharge amount
‘unit_price’ => 75.00,
// whether or not tax is applied on top of the surcharge
‘taxable’ => false,
)
);
The support post ‘Zero Surcharge with Promo Code’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.