Skip to content

Instantly share code, notes, and snippets.

@tfont tfont/code.php Secret
Last active Sep 13, 2017

Embed
What would you like to do?
<?php
public static function custom_hook(EE_SPCO_Reg_Step_Attendee_Information $data)
{
$first_key = key($data->checkout->transaction->items_purchased());
$data->checkout->transaction->items_purchased()[$first_key]->set('LIN_unit_price', 10);
$data->checkout->transaction->items_purchased()[$first_key]->recalculate_total_including_taxes();
$data->checkout->transaction->set('LIN_unit_price', 10);
$data->checkout->cart->get_grand_total()->set('LIN_unit_price', 10);
$data->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
$data->update_checkout();
// actually cause false return error
$data->checkout->transaction->set('LIN_unit_price', 10);
$data->checkout->transaction->save(array('LIN_unit_price', 10));
}
@tfont

This comment has been minimized.

Copy link
Owner Author

tfont commented Sep 11, 2017

Also tried statically, no luck.

$line_item_id = $data->checkout->transaction->items_purchased()[$first_key]->get('LIN_ID');
EEM_Line_Item::instance()->get_one_by_ID($line_item_id)->set('LIN_unit_price', 10);
@mnelson4

This comment has been minimized.

Copy link

mnelson4 commented Sep 11, 2017

that last line should really be $data->checkout->transaction->save(); as you've already changed the transaction's unit price, so now you only need to save that transaction with its set data.

Providing an array with no keys like you did would cause an error, I believe.

@tfont

This comment has been minimized.

Copy link
Owner Author

tfont commented Sep 13, 2017

@mnelson4 also using $data->checkout->transaction->set('LIN_unit_price', 10); seem to cause an error. Applying your change and removing $data->checkout->transaction->set() allow the transition to procced to step 3, however, still no price change.

May I ask what the explanations are for the following? :

  • $data->checkout->transaction->items_purchased() :
    1. $data->checkout->transaction->items_purchased()[]->set()
    2. $data->checkout->transaction->items_purchased()[]->recalculate_total_including_taxes()

  • $data->checkout->transaction :
    1. $data->checkout->transaction->set()
    2. $data->checkout->transaction->save()

  • $data->checkout->cart->get_grand_total() :
    1. $data->checkout->cart->get_grand_total()->set()
    2. $data->checkout->cart->get_grand_total()->recalculate_total_including_taxes()

  • $data (EE_SPCO_Reg_Step_Attendee_Information) :
    1. $data->update_checkout()

They all seem too similar, yet do nothing to the transition from step 2 to step 3 on the SPCO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.