コード例 #1
0
 /**
  * Adds the line item as a child to this line item. If there is another child line
  * item with the same LIN_code, it is overwritten by this new one
  * @param EE_Line_Item $line_item
  * @return boolean success
  */
 function add_child_line_item(EE_Line_Item $line_item)
 {
     if ($this->ID()) {
         //check for any duplicate line items (with the same code), if so, this replaces it
         $line_item_with_same_code = $this->get_child_line_item($line_item->code());
         if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
             $this->delete_child_line_item($line_item_with_same_code->code());
         }
         $line_item->set_parent_ID($this->ID());
         if ($this->TXN_ID()) {
             $line_item->set_TXN_ID($this->TXN_ID());
         }
         return $line_item->save();
     } else {
         $this->_Line_Item[$line_item->code()] = $line_item;
         return TRUE;
     }
 }
コード例 #2
0
 /**
  * Adds the line item as a child to this line item
  * @param EE_Line_Item $line_item
  * @return void
  */
 function add_child_line_item(EE_Line_Item $line_item)
 {
     if ($this->ID()) {
         $line_item->set_parent_ID($this->ID());
         $line_item->save();
     } else {
         $this->_Line_Item[$line_item->code()] = $line_item;
     }
 }