Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sub items qty's increase the wrong item #65

Open
lukepolo opened this issue Feb 2, 2016 · 0 comments
Open

Adding sub items qty's increase the wrong item #65

lukepolo opened this issue Feb 2, 2016 · 0 comments
Assignees
Milestone

Comments

@lukepolo
Copy link
Owner

lukepolo commented Feb 2, 2016

add x1 (shows qty_x = 1)
add x1 with sub y1 (shows qty_xy = 1)
add x1 with sub y1 again and all of a sudden qty_x = 2
qty_xy should = 2

The solution would be to change the qty of x1. And re-add x2 as a new item with the sub item (which is no problem). The problem is x2 is no longer x2. For instance

    $x1 = $this->addItem();
    // $x2 is really just $x1 now since we increased the qty to 2
    $x2 = $this->addItem();
    // $x2 is now with the sub item
    $x2->addSubItem([
        'size' => 'XXL',
        'price' => 2.50
    ]);
    // and $x2 should be its own item but its attached to x1

The TEST :

public function testSubItemQtys()
{
    $item_1 = $this->addItem();

    $item_2 = $this->addItem();

    $subItem = $item_2->addSubItem([
        'size' => 'XXL',
        'price' => 2.50
    ]);

    $this->assertEquals(1, $item_1->qty);
    $this->assertEquals(1, $item_2->qty);

    $item_3 = $this->addItem();

    $subItem = $item_3->addSubItem([
        'size' => 'XXL',
        'price' => 2.50
    ]);

    $this->assertEquals(1, $item_2->qty);
    $this->assertEquals(2, $item_2->qty);
}

This test fails because of these issues.

@lukepolo lukepolo self-assigned this Feb 2, 2016
@lukepolo lukepolo added this to the 3.0 milestone Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant