Information doesn't get stored in session when I'm populating checkout billing fields through javascript
[13:04, 26.01.2023] Alexandru WeConnect: TL:DR I populate input fields with js, but fields take their previous values on user edit (jquery generated inputs don't save to session data);
When dynamically populating billing fields (i.e. company name, address and so on), the values of the fields change without an issue. However, when I edit any input of the corresponding section, the information reloads from session. I've tried triggering both the on change event and the keyup/keydown event to try forcing j3checkout to see a change occured in the input and to save the information into session, haven't had any success.
I've also tried making a new controller in the controller/journal3 folder and calling it via ajax/post, it didn't produce any result. Below is an example of the function that edits the company name field and calls the controller upon updating:
function verificafirma() {
let companyname = $('#input-payment-company');
// Changes the value but it doesn't trigger the session save in data
companyname.val('Test');
companyname.change();
$.ajax({
type: "POST",
url: "
https://driedfruits.ro/index.php?route= ... saveextern",
data: { payment_company: bnumec.val() },
success: function(response){
console.log("Company name updated successfully");
}
});
}
// Variants i've tried in the newly created controller file (saveextern)
class ControllerJournal3SaveExtern extends \Journal3\Opencart\Controller {
public function index() {
$this->load->language('checkout/checkout');
$this->session->data['payment_company'] = $this->request->post['payment_company'];
$this->session->data['input-payment-company'] = $this->request->post['payment_company'];
$this->session->data['company'] = $this->request->post['payment_company'];
$data['payment_address_block'] = $this->renderView('journal3/checkout/address', array(
'type' => 'payment',
'entry_company' => 'Depal123',
));
echo json_encode(['success' => true]);
}
}
[13:05, 26.01.2023] Alexandru WeConnect: Any help in the matter would be greatly appreciated,
Thank you.