Jump to content

Inserting custom data to ps_orders table


wallchopz

Recommended Posts

I have a radio group added on step #4 of the checkout page (order-carrier.tpl). I need the selected radio to be inserted into the database. Radio items has name=variable and id=variable.

 

Here's what I did, so far:

1. Create new column in ps_orders. Data type is text.

2. Override order.php:

       Add public $variable;

       Add to the array :: 'variable' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

3. Override paymentmodule.php:

      Add inside foreach ($packageByAddress as $id_package => $package) function :: $order->variable = Tools::getValue('variable');

 

On the order confirmation page, $order->variable is NULL. Therefore, it can't be saved to the database. What am I missing?

Edited by wallchopz (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

I'm new to PrestaShop, but not to SQL tables.  An SQL table containing null values is usually not possible, so you must set a non-null value such as '0' to represent null as a default. That way you have data no matter what. It's a shot in the dark here, but it may solve the null value problem for you. You will then have to ensure you have not used '0' to represent something else. Hope it helps, Mark

Link to comment
Share on other sites

I have a radio group added on step #4 of the checkout page (order-carrier.tpl). I need the selected radio to be inserted into the database. Radio items has name=variable and id=variable.

 

Here's what I did, so far:

1. Create new column in ps_orders. Data type is text.

2. Override order.php:

       Add public $variable;

       Add to the array :: 'variable' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

3. Override paymentmodule.php:

      Add inside foreach ($packageByAddress as $id_package => $package) function :: $order->variable = Tools::getValue('variable');

 

On the order confirmation page, $order->variable is NULL. Therefore, it can't be saved to the database. What am I missing?

for this I think following link helps you.

https://www.prestashop.com/forums/topic/463223-variable-smarty-in-controller-to-a-tpl/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...