Example #1
0
 public static function buildRawExamples()
 {
     // Order persons
     echo ' 8: Initial data: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Inserting an order person
     $newOrderPerson = new \OrderPerson();
     $newOrderPerson->setEmail('*****@*****.**');
     $newOrderPerson->setFirstName('lilian');
     $newOrderPerson->setLastName('tikk');
     $newOrderPerson->insert();
     echo ' 10: After insertion: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Querying full data of an order person
     $orderPerson = new OrderPerson();
     $orderPerson->setId(3);
     $orderPerson->setCompleteOrderPerson();
     echo ' 20: Order person #3: <pre>';
     var_dump($orderPerson);
     echo '</pre>';
     // Updating data of an order person
     $orderPerson->setAddress('Pärnu, Pärnu');
     $orderPerson->update();
     echo ' 24: After updating the order person #3: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Deleting the order person #2
     $orderPerson = new \OrderPerson();
     $orderPerson->setId(2);
     $orderPerson->delete();
     echo ' 43: After deleting the order person #2: <pre>';
     var_dump(\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Items
     require_once dirname(__FILE__) . '/Item.php';
     $item = new Item();
     $item->setId(1);
     $item->setName('õun');
     $item->setPrice(1.0);
     $item->setAmount(20.0);
     $item->insertItem($item);
     $item = new \shiporder\Item();
     $item->setId(2);
     $item->setName('pirn');
     $item->setPrice(2.0);
     $item->setAmount(10.0);
     $item->insertItem($item);
     $items = $item->getItems();
     var_dump($items);
 }
Example #2
0
 /**
  * Initialize the object with raw data
  *
  * @param $data
  * @return Item
  */
 public static function initializeWithRawData($data)
 {
     $item = new Item();
     if (isset($data['description'])) {
         $item->setDescription($data['description']);
     }
     if (isset($data['amount'])) {
         $item->setAmount($data['amount']);
     }
     if (isset($data['price'])) {
         $item->setPrice($data['price']);
     }
     if (isset($data['vat'])) {
         $item->setVat($data['vat']);
     }
     if (isset($data['reference_id'])) {
         $item->setReferenceId($data['reference_id']);
     }
     if (isset($data['total_without_vat'])) {
         $item->setTotalWithoutVat($data['total_without_vat']);
     }
     if (isset($data['total_vat'])) {
         $item->setTotalVat($data['total_vat']);
     }
     if (isset($data['total_with_vat'])) {
         $item->setTotalWithVat($data['total_with_vat']);
     }
     if (isset($data['discount'])) {
         $item->setDiscount($data['discount']);
     }
     if (isset($data['percentage'])) {
         $item->setDiscountIsPercentage($data['percentage']);
     }
     if (isset($data['discount_description'])) {
         $item->setDiscountDescription($data['discount_description']);
     }
     return $item;
 }
 /**
  * Adds a new product/item in this payment request
  * 
  * @param String $id
  * @param String $description
  * @param String $quantity
  * @param String $amount
  * @param String $weight
  * @param String $shippingCost
  */
 public function addItem($id, $description = null, $quantity = null, $amount = null, $weight = null, $shippingCost = null)
 {
     $param = $id;
     if ($this->items == null) {
         $this->items = array();
     }
     if (is_array($param)) {
         array_push($this->items, new Item($param));
     } else {
         if ($param instanceof Item) {
             array_push($this->items, $param);
         } else {
             $item = new Item();
             $item->setId($param);
             $item->setDescription($description);
             $item->setQuantity($quantity);
             $item->setAmount($amount);
             $item->setWeight($weight);
             $item->setShippingCost($shippingCost);
             array_push($this->items, $item);
         }
     }
 }
 private static function parseTransactionItem($data)
 {
     // <transaction> <items> <item>
     $item = new Item();
     // <transaction> <items> <item> <id>
     if (isset($data["id"])) {
         $item->setId($data["id"]);
     }
     // <transaction> <items> <item> <description>
     if (isset($data["description"])) {
         $item->setDescription($data["description"]);
     }
     // <transaction> <items> <item> <quantity>
     if (isset($data["quantity"])) {
         $item->setQuantity($data["quantity"]);
     }
     // <transaction> <items> <item> <amount>
     if (isset($data["amount"])) {
         $item->setAmount($data["amount"]);
     }
     // <transaction> <items> <item> <weight>
     if (isset($data["weight"])) {
         $item->setWeight($data["weight"]);
     }
     return $item;
 }