Page 1 of 1

Add fields to $_SESSION['cart']

Posted: Mon Sep 06, 2021 11:13 pm
by LeeFoster
Hi,

I am trying to create a text input pi module. Some of the products we sell allow or require text input.

I have created a text input box but am stumped on the next step, adding it to the cart session and then in to the customers_basket table.

Does anyone have experience of doing this? I would prefer to use hooks as opposed to hard coding.

Any help is much appreciated.

Re: Add fields to $_SESSION['cart']

Posted: Tue Sep 07, 2021 12:11 am
by ecartz
For what you are doing, you might be better off doing things in some different fashion. Note that the original Option Type Feature modified the tables to store a string instead of a number. The contents array is accessible from outside the shopping cart. So you could override the necessary actions and modify the array directly.

I could add new hooks to the action processing. That would save having to override the action file. But it probably won't get released until at least November.

Re: Add fields to $_SESSION['cart']

Posted: Tue Sep 07, 2021 12:53 am
by LeeFoster
ecartz wrote: Tue Sep 07, 2021 12:11 am So you could override the necessary actions and modify the array directly.
Could you point me in the direction of which file/s to modify?

Re: Add fields to $_SESSION['cart']

Posted: Tue Sep 07, 2021 1:00 am
by ecartz
includes/actions/add_product.php might be the only action that works with attributes.

Re: Add fields to $_SESSION['cart']

Posted: Tue Sep 07, 2021 6:22 am
by LeeFoster
ecartz wrote: Tue Sep 07, 2021 1:00 am includes/actions/add_product.php might be the only action that works with attributes.
I'm not adding it as an attribute, it's a stand alone field.