Skip to content
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

added withQuantity method to checkout #56

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dcblogdev
Copy link

@dcblogdev dcblogdev commented Nov 9, 2023

added option to set quantities on checkout defaults to 1.

This allows usage:

$request->user()->checkout('variant-id')->withQuantity(5)

This added the array key to the payload

['variant_quantities'] = [
    [
         'variant_id' => (int) $this->variant,
          'quantity' => $quantity,
    ],
]

@davidsket
Copy link

I tried this solution, but it didn't work for me. I believe variant_quantities should be an array of objects

Documentation

...
"variant_quantities": [
  {
    "variant_id": 1,
    "quantity": 10
  }
]
...

So, something like that worked.

$this->checkoutData['variant_quantities'] = [
    [
        'variant_id' => (int) $this->variant,
        'quantity' => $quantity,
    ],
];

@cwbmuller
Copy link

@davidsket 's solution works 👍

$this->checkoutData['variant_quantities'] = [
    [
        'variant_id' => (int) $this->variant,
        'quantity' => $quantity,
    ],
];

@simpsoncarlos3
Copy link

i just came for this feature.
how do i use this feature rightnow as main repon don't have this merged?

@davidsket
Copy link

You can use repository directly in composer, or use overrides for specific class. I wouldn't recommend doing it in production.

use array of arrays
@dcblogdev
Copy link
Author

thanks @davidsket updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants