Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create mn_spco_change_line_item_before_payment_options_step.php
in response to eventespresso/event-espresso-core#240
- Loading branch information
Mike Nelson
committed
Sep 19, 2017
1 parent
b9f8813
commit 993e7bb
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
checkout/mn_spco_change_line_item_before_payment_options_step.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//changes the first line item's unit price to 10, from whatever it was before | ||
//this will be displayed during SPCO's payment options step | ||
|
||
add_action('AHEE__Single_Page_Checkout__after_attendee_information__process_reg_step', 'custom_hook', 10, 1); | ||
function custom_hook(EE_SPCO_Reg_Step_Attendee_Information $data) | ||
{ | ||
$purchases = $data->checkout->transaction->items_purchased(); | ||
$first_item = reset($purchases); | ||
//we need to edit the sub-item's unit price, as | ||
//the line item's total is calculated from its sub-items | ||
$children = $first_item->children(); | ||
$child_line_item = reset($children); | ||
$child_line_item->set('LIN_unit_price', 10); | ||
$data->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); | ||
$data->update_checkout(); | ||
} |