-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix incrementQuantity() & decrementQuantity() Throwing Error #224
Comments
Hi @driesvints, I know i'm bothering you a lot lately, But I tried to send a pull request with the fix for this issue but it failed the tests with the following message If you can check it out and let me know what I have done wrong to fail the tests I would really appretiate it so that I can send a pull request directly if I found any other issues. Thanks! |
Hi @driesvints, Thank you! BTW I checked the PR and it's only including the fix for the issue (1). |
Oh you're correct. Added that as well 👍 |
Thanks @driesvints I really appreciate your help! |
Cashier Paddle Version
2.x
Laravel Version
10.10
PHP Version
8.1
Database Driver & Version
No response
Description
Issue (1)
The
incrementQuantity()
method was failing and throwing the error below.In the
updateQuantity()
runningpluck(['quantity', 'price_id'])
on the result fromget(['quantity', 'price_id'])
was returning null in the following line$items = $this->items()->get(['quantity', 'price_id'])->pluck(['quantity', 'price_id'])->toArray();
I'm also not sure you could pass and array to
pluck
, I think this was added by mistake.Solution (1)
Removed
pluck(['quantity', 'price_id'])
Steps To Reproduce (1)
Try running
$user->subscription()->incrementQuantity(1, 'price_id');
.Issue (2)
The
decrementQuantity()
method was failing and throwing the error below.The problem is that the

decrementQuantity()
is not passing the$item
or the$price_id
to theupdateQuantity()
method as you can see belowSolution (2)
Pass the
$item
instance to theupdateQuantity()
method.return $this->updateQuantity(max(1, $item->quantity - $count));
Steps To Reproduce (2)
Try running
$user->subscription()->decrementQuantity(1, 'price_id');
.The text was updated successfully, but these errors were encountered: