magento 2 add custom data to checkout session

Solutions on MaxInterview for magento 2 add custom data to checkout session by the best coders in the world

showing results for - "magento 2 add custom data to checkout session"
Juliana
15 Jun 2018
1// reference https://bit.ly/3nbIQzs
2
3class myClass {
4  	
5  	// \Magento\Checkout\Model\Session
6  	private $_checkoutSession;
7
8	public function __construct(
9		\Magento\Checkout\Model\Session $checkoutSession
10	){  
11		$this->_checkoutSession = $checkoutSession;
12	}
13  
14	public function execute() {
15		// set data
16    	$this->_checkoutSession->setTestData('123');
17
18		// get data
19    	$this->_checkoutSession->getTestData('123');
20		
21		// unset data
22    	$this->_checkoutSession->unsTestData('123');
23	}
24}