Answers for "magento 2 add custom data to checkout session"

PHP
0

magento 2 add custom data to checkout session

// reference https://bit.ly/3nbIQzs

class myClass {
  	
  	// \Magento\Checkout\Model\Session
  	private $_checkoutSession;

	public function __construct(
		\Magento\Checkout\Model\Session $checkoutSession
	){  
		$this->_checkoutSession = $checkoutSession;
	}
  
	public function execute() {
		// set data
    	$this->_checkoutSession->setTestData('123');

		// get data
    	$this->_checkoutSession->getTestData('123');
		
		// unset data
    	$this->_checkoutSession->unsTestData('123');
	}
}
Posted by: Guest on October-01-2020

Code answers related to "magento 2 add custom data to checkout session"

Browse Popular Code Answers by Language