0

I'm using CT. When a customer checks out they are required to select a location for where they want to pickup their order. I would like to save both the location's ID and the location's pickup date to custom fields that I'v set on the orders channel. Currently, when a customer selects a location from the select menu the location ID is submitted along with the form. I've written an extension that looks for the cartthrob_on_authorize hook. It allows me to get the location ID from the custom field and run a query to get the location date. My question is, how do I save the location date to the order through my extension? I've tired various combinations like this:

"ee()->cartthrob->cart->order->set_custom_data('order_pickup_date', $pickup_date)"

but nothing like that seems to work. Any help is much appreciated. Thanks!

1 Answer 1

0

Once the order is authorized (once you've gotten to the on_authorize hook), custom data isn't going into the order… because the order's basically "done" and not still compiling the data in the order. That said though, you can update the order fairly easily:

If you have an order channel field with the name of order_pickup_date do something like this:

ee()->load->model("order_model");
$order_data = array(
    'order_pickup_date' => $pickup_date,
);
ee()->order_model->update_order(ee()->cartthrob->cart->order('entry_id'), $order_data); 

You could also add custom_data using the pre_process hook (the order is still being set at that point), which wouldn't require the work above. Either way it's pretty simple once you see it done one time.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.