public function addOptionChoice(ProductOptionChoice $choice) { if (!$choice->isLoaded()) { $choice->load(); } foreach ($this->optionChoices as $key => $ch) { // already added? if ($ch->choice->get()->getID() == $choice->getID()) { return $ch; } // other choice from the same option - needs removal if ($ch->choice->get()->option->get()->getID() == $choice->option->get()->getID()) { $this->removeOptionChoice($ch->choice->get()); } } $choice = OrderedItemOption::getNewInstance($this, $choice); $this->optionChoices[$choice->choice->get()->option->get()->getID()] = $choice; if ($this->isFinalized()) { $choice->updatePriceDiff(); $this->price->set($this->price->get() + $this->reduceBaseTaxes($choice->priceDiff->get())); } return $choice; }
public function addChoice(ProductOptionChoice $choice) { $this->choices[$choice->getID()] = $choice; }
public function addOptionChoice(ProductOptionChoice $choice) { if (!$choice->isLoaded()) { $choice->load(); } foreach ($this->optionChoices as $key => $ch) { // already added? if ($ch->choice->get()->getID() == $choice->getID()) { return $ch; } // other choice from the same option - needs removal if ($ch->choice->get()->option->get()->getID() == $choice->option->get()->getID()) { $this->removedChoices[] = $ch; unset($this->optionChoices[$key]); } } $choice = OrderedItemOption::getNewInstance($this, $choice); $this->optionChoices[$choice->choice->get()->option->get()->getID()] = $choice; return $choice; }