Jump to content

Modify gift_message when adding a new order


Recommended Posts

I am developing a carrier module which has multiple select options from which the user can choose from.I am saving his choice in the session, and I want to display his choice in the backend office, so when an employee views the order he knows which option the user has picked.
Here is my issue.Whenever I try to modify the order from the actionValidateOrder hook, no changes are actually applied to the order..

public function hookActionValidateOrder($params){
			
				$id_order = $params['order']->id;
				$id_carrier = $params['order']->id_carrier;
				
				if($id_carrier == Configuration::get(self::PREFIX . 'mycustomcarrier')){
					if (session_status() == PHP_SESSION_NONE) {
						session_start();
					}
					
					if(isset($_SESSION['mycustomcarrier'])){
						$params['order']->gift_message .= "User has picked .."; //you get the idea
					}
				}
			
		}

I am a rookie at developing prestashop modules, so feel free to share opinions or best practices approaching these the type of problem.

Link to comment
Share on other sites

I'm not sure if this is the best idea but I'll save values using

// save(update) value
Configuration::updateValue('my_module_something', 'some value'); 

// get value
Configuration::get('my_module_something'); // returns 'some value'

In your case for let's say order: #ASDFGS  I will save the value in json format like

{
  "param1":"zxcv",
  "param2":"qwer"
}

then read it from admin panel

// my_module = your module name
// ASDFGS = order reference id
Configuration::get('my_module_ASDFGS');
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...