Beispiel #1
0
 /**
  * Test: get_parent_id
  */
 function test_get_parent_id()
 {
     $object = new WC_Order();
     $set_to = 100;
     $object->set_parent_id($set_to);
     $this->assertEquals($set_to, $object->get_parent_id());
 }
Beispiel #2
0
 /**
  * Test: get_parent_id
  */
 function test_get_parent_id()
 {
     $object1 = new WC_Order();
     $parent_id = $object1->save();
     $object = new WC_Order();
     $object->set_parent_id($parent_id);
     $this->assertEquals($parent_id, $object->get_parent_id());
 }
 /**
  * Prepare links for the request.
  *
  * @param WC_Order $order Order object.
  * @return array Links for the given order.
  */
 protected function prepare_links($order)
 {
     $links = array('self' => array('href' => rest_url(sprintf('/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id()))), 'collection' => array('href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base))));
     if (0 !== (int) $order->get_user_id()) {
         $links['customer'] = array('href' => rest_url(sprintf('/%s/customers/%d', $this->namespace, $order->get_user_id())));
     }
     if (0 !== (int) $order->get_parent_id()) {
         $links['up'] = array('href' => rest_url(sprintf('/%s/orders/%d', $this->namespace, $order->get_parent_id())));
     }
     return $links;
 }
 /**
  * Method to update an order in the database.
  * @param WC_Order $order
  */
 public function update(&$order)
 {
     $order->set_version(WC_VERSION);
     wp_update_post(array('ID' => $order->get_id(), 'post_date' => date('Y-m-d H:i:s', $order->get_date_created('edit')), 'post_date_gmt' => get_gmt_from_date(date('Y-m-d H:i:s', $order->get_date_created('edit'))), 'post_status' => 'wc-' . ($order->get_status('edit') ? $order->get_status('edit') : apply_filters('woocommerce_default_order_status', 'pending')), 'post_parent' => $order->get_parent_id(), 'post_excerpt' => $this->get_post_excerpt($order)));
     $this->update_post_meta($order);
     $order->save_meta_data();
     $order->apply_changes();
     $this->clear_caches($order);
 }