0

How to add the product price to session with AJAX Magento 2. Please give me an example of the custom module of this solution.

1 Answer 1

1

I think I have answered your previous question(Link) where you asked how to save custom data into the session, please use those same controllers from it, now, please look below code -

public function execute()
{
$productPrice = "200";
$productId = "5762413";
$customerSession = $this->session->getData();
$this->session->setProductId($productId);
$this->session->setProductPrice($productPrice);
$data = $this->session->getData();
$redirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$params = $this->request->getParams();
return $redirect->setPath('cms/custom/index');
}

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.