laravelshoppingcart icon indicating copy to clipboard operation
laravelshoppingcart copied to clipboard

Call to a member function applyCondition() on array

Open robertnicjoo opened this issue 5 years ago • 5 comments

When I try to save my cart data to database I'm getting error below on all my app (it completely messed my app now i can't load any page of my app!)

Call to a member function applyCondition() on array

screenshot_2019-02-04 whoops there was an error

Cart DD

CartCollection {#2781 ▼
  #items: array:1 [▼
    22 => ItemCollection {#2624 ▼
      #config: array:6 [▶]
      #items: array:6 [▼
        "id" => 22
        "name" => "style four"
        "price" => 50000.0
        "quantity" => "1"
        "attributes" => ItemAttributeCollection {#2625 ▼
          #items: array:3 [▼
            "attr" => array:2 [▼
              "name" => "weight"
              "value" => "1"
            ]
            "slug" => "style-four"
            "photo" => "productCover-gmyrDtczNR.jpeg"
          ]
        }
        "conditions" => array:2 [▼
          0 => CartCondition {#2626 ▼
            -args: array:4 [▼
              "name" => "red"
              "value" => "7500"
              "type" => "additional"
              "target" => "item"
            ]
            -parsedRawValue: 7500.0
          }
          1 => CartCondition {#2627 ▼
            -args: array:4 [▼
              "name" => "title 33"
              "value" => "3"
              "type" => "additional"
              "target" => "item"
            ]
            -parsedRawValue: 3.0
          }
        ]
      ]
    }
  ]
}

Item DD

ItemCollection {#2624 ▼
  #config: array:6 [▶]
  #items: array:6 [▼
    "id" => 22
    "name" => "style four"
    "price" => 57503.0
    "quantity" => "1"
    "attributes" => ItemAttributeCollection {#2625 ▼
      #items: array:3 [▼
        "attr" => array:2 [▼
          "name" => "weight"
          "value" => "1"
        ]
        "slug" => "style-four"
        "photo" => "productCover-gmyrDtczNR.jpeg"
      ]
    }
    "conditions" => array:2 [▼
      0 => array:2 [▼
        "name" => "red"
        "value" => "7500"
      ]
      1 => array:2 [▼
        "name" => "title 33"
        "value" => "3"
      ]
    ]
  ]
}

robertnicjoo avatar Feb 04 '19 05:02 robertnicjoo

Getting same error when trying item level conditions

Mohammed-Daud avatar Aug 08 '20 15:08 Mohammed-Daud

Also getting the same error. Any workarounds?

alibaba258 avatar Sep 29 '20 12:09 alibaba258

Any resolutions for this? I have the same error and issue has been active for quite sometime.

From debugging the code, calling $cart->getContent()->toArray() causes the item level conditions to store incorrectly. This issue happens only when an item condition exists. The item level condition gets stored as following

 "conditions": [{"parsedRawValue": null}],

abishekrsrikaanth avatar Sep 15 '23 21:09 abishekrsrikaanth

@robertnicjoo @Mohammed-Daud @alibaba258 were you guys able to fix this issue?

abishekrsrikaanth avatar Sep 16 '23 02:09 abishekrsrikaanth

Pushed a fix for this, hopefully it helps others.

abishekrsrikaanth avatar Sep 16 '23 04:09 abishekrsrikaanth