I have a solution here for Magento 2. I am sharing this for basic Idea. You can create an observer in 1.9 for sales_model_service_quote_submit_after
in your XML file.
<events>
<sales_model_service_quote_submit_after>
<observers>
<onepagecheckout>
<type>model</type>
<class>onepagecheckout/observer</class>
<method>saveData</method>
</onepagecheckout>
</observers>
</sales_model_service_quote_submit_after>
</events>
In observer file you can update your item ID. Here is the code that we need to add observer file.
protected $_checkoutSession;
public function __construct ( \Magento\Checkout\Model\Session $_checkoutSession ) {
$this->_checkoutSession = $_checkoutSession;
}
public function saveData(\Magento\Framework\Event\Observer $observer)
{
$cartData = $this->_checkoutSession->getQuote()->getAllVisibleItems();
foreach( $cartData as $item ):
/* Here we can manipulate data */
endforeach;
$cartData->save();
}
for manipulate database and to process data you need block or model files. you also need to initialize resource, then you need to call connection. I hope it will give you an idea to save varient_id
. Also here is a link can help you that How to manipulate db tables helplink1 helplink2