Closed it-can closed 2 years ago
Ok it seems that qty is not being set on php8.1
output php 8.0.13
LukePOLO\LaraCart\CartItem^ {#867
#itemHash: "7af08c2a78f26847e87a02cb9a8bcc8e"
#itemModel: null
#itemModelRelations: []
+locale: null
+lineItem: false
+discount: 0
+active: true
+subItems: []
+couponInfo: []
+currencyCode: null
+options: array:6 [
"id" => 1
"qty" => 52
"name" => "test"
"taxable" => true
"price" => 107.44
"tax" => 0.21
]
}
php 8.1
LukePOLO\LaraCart\CartItem^ {#866
#itemHash: "7af08c2a78f26847e87a02cb9a8bcc8e"
#itemModel: null
#itemModelRelations: []
+locale: null
+lineItem: false
+discount: 0
+active: true
+subItems: []
+couponInfo: []
+currencyCode: null
+options: & array:5 [
"id" => 1
"name" => "test"
"price" => 107.44
"tax" => 0.21
"taxable" => true
]
}
mmm removing this line makes it works again...
https://github.com/lukepolo/laracart/blob/master/src/CartItem.php#L95
does 8.1 do something by passing by reference oddly or something?
I am no longer using PHP as my main language, so im not caught up in the details of the releases.
I think this line is the problem
https://github.com/lukepolo/laracart/blob/master/src/CartItem.php#L92
$cartItemArray = (array) $this;
I think this should be:
$cartItemArray = (array) clone $this;
I get no results on php8.1 (on php8.0.13 it works perfectly), I have this test:
I use Laracart 1.12.0-RC-1 (same problem in the latest version)
php 8.0.13 output
php 8.1 output