Problem/Motivation

Users need to have a route which shows them their order history.

Proposed resolution

  • Create a View with a path at /user/{user}/orders
  • Display a table of the user's placed orders
  • Order by placed timestamp
  • Do not show carts

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mglaman created an issue. See original summary.

bojanz’s picture

goz’s picture

Assigned: Unassigned » goz
goz’s picture

Status: Active » Needs review
StatusFileSize
new18.88 KB
new32.92 KB

This patch uses state views filter added by https://www.drupal.org/node/2648684

Remaining tasks :

  • Change permissions view permissions to order view permissions when it will be available
  • Change State filter = not in Draft by placed is not null when date field views filter will allow IS NOT NULL.
mglaman’s picture

Status: Needs review » Needs work
Related issues: +#2648684: Use InOperator filter for state views filter

Marking needs work while we wait on #2648684: Use InOperator filter for state views filter

goz’s picture

Assigned: goz » Unassigned
Status: Needs work » Needs review

#2648684 is fixed and commited.

mglaman’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new25.29 KB

We should drop the "created" column as the only timestamp relevant to the customer should be "placed"

bojanz’s picture

We also want to show the store, but hide it if there's only 1, just like the order admin view does.

mglaman’s picture

Status: Needs work » Needs review

Made a PR: https://github.com/drupalcommerce/commerce/pull/305

Takes #4 but removes created field. Adds a test.

aaronchristian’s picture

I've attached 2 different variations. One as a default and another concept for orders with shippable goods.

Let me know what you guys think!

bojanz’s picture

Status: Needs review » Needs work

Waiting on a rebase.

goz’s picture

Status: Needs work » Needs review

Skip the Store field asked by Bojan in #8 until we actually have a Stores page.

goz’s picture

Status: Needs review » Needs work
mglaman’s picture

Status: Needs work » Needs review

Rebased

  • bojanz committed 33fd923 on 8.x-2.x authored by GoZ
    Issue #2646214 by GoZ, mglaman: Create an order history route and view...
bojanz’s picture

Status: Needs review » Fixed

I committed just the view, with the cart filter removed (cause it was unneeded and orders can't assume the existence of carts).

The test can't work because it tests access controls that the view doesn't have yet, Tavi is working on that.
Here's the removed code:

  /**
   * Tests the user order listing.
   */
  public function testUserOrderHistory() {
    $user1 = $this->drupalCreateUser();
    $user2 = $this->drupalCreateUser();
    $line_item = $this->createEntity('commerce_line_item', [
      'type' => 'product_variation',
      'unit_price' => [
        'amount' => '999',
        'currency_code' => 'USD',
      ],
    ]);
    $order = $this->createEntity('commerce_order', [
      'type' => 'default',
      'mail' => $user1->getEmail(),
      'uid' => $user1->id(),
      'line_items' => [$line_item],
    ]);

    $this->drupalLogin($user2);
    $this->drupalGet('user/' . $user2->id());
    $this->assertResponse(403);

    $this->drupalLogin($user1);
    $this->drupalGet('user/' . $user1->id());
    $this->assertLinkByHref("user/{$user1->id()}/orders");
    $this->clickLink('Orders');
  }

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.