magento 2 checkout session set data code example
Example: 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');
}
}