Skip to content
Discussion options

You must be logged in to vote

Product Variants are special - you can't set them in the same way you can any other field. You need to use the specific productVariants method.

When you set the variants, you need to provide an array for both the options & the individual variants. Make sure you have a variant for each of the combinations.

You can set the options & variants like this:

$product->productVariants([
  'variants' => [
    ['name' => 'Colour', 'values' => ['Red', 'Green', 'Blue']],
    ['name' => 'Size', 'values' => ['Small', 'Medium']]
  ],
  'options' => [
    [
      'key' => 'Red_Small',
      'variant' => 'Red, Small',
      'price' => 1599,
    ],
    [
      'key' => 'Red_Medium',
      'variant' => 'Red,…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@de-raaf-media
Comment options

@duncanmcclean
Comment options

@de-raaf-media
Comment options

@duncanmcclean
Comment options

@de-raaf-media
Comment options

Answer selected by de-raaf-media
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants