Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\commerce_order\Entity\Order */
     $orderType = OrderType::load($entity->bundle());
     $row = ['order_id' => $entity->id(), 'type' => $orderType->label(), 'customer' => ['data' => ['#theme' => 'username', '#account' => $entity->getOwner()]], 'state' => $entity->getState()->getLabel(), 'created' => $this->dateFormatter->format($entity->getCreatedTime(), 'short')];
     return $row + parent::buildRow($entity);
 }
Ejemplo n.º 2
0
  /**
   * Tests shopping cart refresh options in order type form.
   */
  function testCartRefreshSettings() {
    $url = 'admin/commerce/config/order-types/default/edit';
    $this->drupalGet($url);
    $this->assertField('refresh_mode', 'Shopping cart refresh mode field found.');
    $this->assertField('refresh_frequency', 'Shopping cart refresh frequency field found.');

    $edit['refresh_mode'] = 'always';
    $edit['refresh_frequency'] = 60;
    $this->drupalPostForm($url, $edit, t('Save'));
    $orderType = OrderType::load('default');
    $refreshMode = $orderType->getThirdPartySetting('commerce_cart', 'refresh_mode', 'owner_only');
    $refreshFrequency = $orderType->getThirdPartySetting('commerce_cart', 'refresh_frequency', 30);
    $this->assertEqual($refreshMode, $edit['refresh_mode'], 'The value of the shopping cart refresh mode has been changed.');
    $this->assertEqual($refreshFrequency, $edit['refresh_frequency'], 'The value of the shopping cart refresh frequency has been changed.');
  }
Ejemplo n.º 3
0
 /**
  * Tests deleting a Order Type programmaticaly and through the form.
  */
 public function testDeleteOrderType()
 {
     // Create a order type programmaticaly.
     $type = $this->createEntity('commerce_order_type', ['id' => 'foo', 'label' => 'Label for foo', 'workflow' => 'order_default']);
     commerce_order_add_line_items_field($type);
     // Create a order.
     $order = $this->createEntity('commerce_order', array('type' => $type->id(), 'mail' => $this->loggedInUser->getEmail()));
     // Try to delete the order type.
     $this->drupalGet('admin/commerce/config/order-types/' . $type->id() . '/delete');
     $this->assertRaw(t('%type is used by 1 order on your site. You can not remove this order type until you have removed all of the %type orders.', array('%type' => $type->label())), 'The order type will not be deleted until all orders of that type are deleted');
     $this->assertNoText(t('This action cannot be undone.'), 'The order type deletion confirmation form is not available');
     // Deleting the order type when its not being referenced by a order.
     $order->delete();
     $this->drupalGet('admin/commerce/config/order-types/' . $type->id() . '/delete');
     $this->assertRaw(t('Are you sure you want to delete the order type %label?', array('%label' => $type->label())));
     $this->assertText(t('This action cannot be undone.'), 'The order type deletion confirmation form is available');
     $this->drupalPostForm(NULL, NULL, t('Delete'));
     $type_exists = (bool) OrderType::load($type->id());
     $this->assertFalse($type_exists, 'The order type has been deleted from the database.');
 }
Ejemplo n.º 4
0
 /**
  * Gets the workflow for the state field.
  *
  * @param \Drupal\commerce_order\Entity\OrderInterface $order
  *   The order.
  *
  * @return string
  *   The workflow id.
  */
 public static function getWorkflow(OrderInterface $order)
 {
     $workflow = OrderType::load($order->bundle())->getWorkflow();
     return $workflow;
 }