我已在报价会话中保存自定义属性,但无法在购物车页面中接收其值。我想在产品会话中保存自定义属性并在购物车中获取价值。我用代码
$quoteItem = $cart->getQuote()->getItemById($productId);
$quoteItem->addOption(array('label' => 'buymode', 'code' => 'buymode', 'value' => '2222'));
$quoteItem->save();
答案 0 :(得分:0)
试试这个:
$quoteItems = $quote->getAllItems();
$itemId = null;
foreach($quoteItems as $item){
if($item->getProductId() == $productId){
$itemId = $item->getId();
}
}
if($itemId){
$quoteItem = $cart->getQuote()->getItemById($itemId);
$quoteItem->addOption(array('label' => 'buymode', 'code' => 'buymode', 'value' => '2222'));
$quoteItem->save();
}