Skip to content

Load Position by ID or Model #6

@teone

Description

@teone

Now to use the decrease the quantity of an Item I had to make this cycle:

$positions = Yii::app()->shoppingCart->getPositions();
                foreach($positions as $position) {
                    if ($position->id == $id){
                        $total = $position->getQuantity();
                        Yii::app()->shoppingCart->update($position,$total-1); //1 item with id=1, quantity=2.
                         $price = $position->getSumPrice();
                    } 
                }

Is this right?
If it is a

Yii::app()->shoppingCart->getPosition($book);

to load directly one resource without cycle trought all could be usefull.. Or maybe I just didn't find the right method to do this...

Kindly waiting for a feedback :) Thanks for your great Job!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions