Skip to content

Make the ShoppingCart MatchObjectFilter easier to understand/use #331

Description

@jedateach

I wanted to get a cart item which has a specific relation. What is unclear is whether to specify the relation as RelationName or RelationNameID. After needing to dive into the code with a debugger, I had to do both in different places:

Yaml config for required_fields (used by MatchObjectFilter)

Product_OrderItem:
  extensions:
    - MenuOrderItemExtension
  required_fields:
    - MenuProductSelection #not there is no 'ID' present

Inside MenuProductSelection.php:

    public function getCartItem() {
        return ShoppingCart::singleton()
            ->get($this->Product(), array(
                "MenuProductSelectionID" => $this->ID //note the use of ID
            ));
    }

This is only really a 'bug' in the API usability sense. Its also kind of related to SilverStripe framework in general. Unclear when to use ID, and when not to.

Potential solution

Maybe we just allow both uses: with and without id. This kind of customisation work is kind of edge-case anyway.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions