Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Configurable variants which were added manually and have custom option(s) should not be added to cart #803

Closed
TomashKhamlai opened this issue Aug 5, 2019 · 2 comments

Comments

@TomashKhamlai
Copy link
Contributor

TomashKhamlai commented Aug 5, 2019

Preconditions (*)

Related to #799

  1. Color attribute has options: black, white
  2. Attribute set: attr-color-black-and-white has color attribute
  3. Simple Product with SKU simple-product-1-black with a required custom option of any type is created
  4. Simple Product with SKU simple-product-1-white is created
  5. Configurable product with SKU configurable-product-1 has product variants added manually. (Keep in mind that all the products have visibility Catalog/Search by default.)

Steps to reproduce (*)

  1. Use query products to gather information about options. The main idea is to use the next code snippet:
    	... on CustomizableProductInterface {
        options {
          option_id
          required
          sort_order
          title
          __typename
        }
        __typename
      }

The part of the output is:

"stock_status": "IN_STOCK",
          "options": [
            {
              "option_id": 2,
              "required": true,
              "sort_order": 1,
              "title": "opt",
              "__typename": "CustomizableFieldOption"
            }
          ],
  1. Add configurable product to cart using next query but first verify that Customer cannot add this as a variation of the Configurable Product and the only option he has is to buy the simple-product-1-black
mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "{{ $cart_id }}"
      cart_items: {
        data: {
          quantity: 1
          sku: "simple-product-1-black"
        }
        customizable_options: {
          id: 2
          value_string: "Hello!"
        }
        parent_sku: "configurable-product-1"
      }
    }
  ) {
    cart {
      email
      items {
        id
        quantity
      }
    }
  }
}
  1. It is not hard to predict that Merchant changes the visibility of configurable variants of simple-product-1-white and simple-product-1-black to Not Visible Individually
  2. Add configurable product to cart using next query but first, verify that Customer cannot add this as a variation of the Configurable Product or using catalog search or navigating through catalog simple-product-1-black
mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "{{ $cart_id }}"
      cart_items: {
        data: {
          quantity: 1
          sku: "simple-product-1-black"
        }
        customizable_options: {
          id: 2
          value_string: "Hello!"
        }
        parent_sku: "configurable-product-1"
      }
    }
  ) {
    cart {
      email
      items {
        id
        quantity
      }
    }
  }
}

Expected result (*)

  1. The same behavior.

Actual result (*)

  1. When catalog visibility has changed to Not Visible Individually it is not possible to find out what is the id of the option and which type of option it is.
  2. Creates a "feature" for unfair trades. This is not allowed from Storefront.
    Peek 2019-08-05 18-53
@pmclain
Copy link
Contributor

pmclain commented Aug 24, 2019

Simple products with required options are not valid configurable variants. Child variants with required options are explicitly excluded when loading the child products

public function getChildrenIds($parentId, $required = true)
{
$select = $this->getConnection()->select()->from(
['l' => $this->getMainTable()],
['product_id', 'parent_id']
)->join(
['p' => $this->getTable('catalog_product_entity')],
'p.' . $this->optionProvider->getProductEntityLinkField() . ' = l.parent_id',
[]
)->join(
['e' => $this->getTable('catalog_product_entity')],
'e.entity_id = l.product_id AND e.required_options = 0',

This behavior can be seen in the admin and on the storefront. Below is a configurable product with two configurable attributes. I have added an optional custom option to the first variant sku:

co-optional

The variant option 1, option 1 is available on the storefront:
Screen Shot 2019-08-24 at 12 12 11 AM

After requiring the custom option the simple product is no longer listed as a variant of the configurable product in the admin:

co-required

The variant option 1, option 1 is not available on the storefront:

Screen Shot 2019-08-24 at 12 11 42 AM

@TomashKhamlai
Copy link
Contributor Author

They are not valid but still can be added using GraphQL. I think it is an issue and desirable behavior is as the title of the issue states that configurable variants which were added manually and have custom option(s) should not be added to cart.

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

No branches or pull requests

3 participants