magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

[WIP] Add products to the Wishlist #982

Closed rogyar closed 4 years ago

rogyar commented 4 years ago

Description (*)

This PR introduces functionality for adding products to wishlist. Different types of customizable options are also covered as well as different types of products.

Fixed Issues (if relevant)

  1. 831: [Wish List] Add products to the Wish List

Manual testing scenarios (*)

You must be logged in to use the wishlist functionality

Add simple product

mutation {
  addProductsToWishlist(input: {
    wishlist_items: {
      sku: "simple"
    }
  }) {
    items_count
    items {
      product {
        name
      }
    }
  }
}

Add simple product with customizable options (entered)

mutation {
  addProductsToWishlist(input: {
    wishlist_items: {
      sku: "simple"
      quantity: 3
      entered_options: [
        {
          id: "Y3VzdG9tLW9wdGlvbi8x"
          value:"dGVzdF92YWx1ZQ=="
        }
      ]
    }
  }) {
    items_count
    sharing_code
    name
    items {
      product {
        name
      }
    }
  }
}

Where

{
      id: "Y3VzdG9tLW9wdGlvbi8x" // base64_encode(14)
      value:"dGVzdF92YWx1ZQ==" // base64_encode('custom-option/15')
 }

Add simple product with customizable options (selected)

mutation {
  addProductsToWishlist(input: {
    wishlist_items: {
      sku: "simple"
      quantity: 3
      selected_options: [
        "Y3VzdG9tLW9wdGlvbi8yLzI="
      ]
    }
  }) {
    items_count
    sharing_code
    name
    items {
      product {
        name
      }
    }
  }
}

Where

 selected_options: [
        "Y3VzdG9tLW9wdGlvbi8yLzI=" // base64_encode('custom-option/17/18')
      ]

In case if the custom option has multiple selection (multiselect, checkbox), the non-encoded request string for the option should look like the following custom-option/19/[22,23] where [22, 23] are the selected values

Add configurable product

mutation {
  addProductsToWishlist(input: {
    wishlist_items: {
      sku: "Configurable-2"
      parent_sku: "Configurable"
      quantity: 3
      selected_options: [
        "Y29uZmlndXJhYmxlLzEvMg=="
      ]
    }
  }) {
    items_count
    sharing_code
    name
    items {
      product {
        name
      }
    }
  }
}

Where

selected_options: [
        "Y29uZmlndXJhYmxlLzEvMg==" // base64_encode('configurable/22/27')
      ]
TomashKhamlai commented 4 years ago

Caught this message We can't specify a wish list. from https://github.com/magento/graphql-ce/blob/795b2c6152e0fdf27bfb720d18e1bcd29723b154/app/code/Magento/Wishlist/Model/Item.php#L314 for Customer who has never placed anything to Wish List before.

lenaorobei commented 4 years ago

Hi @rogyar! Unfortunately we need to close this PR in order to not to increase tech debt with new storefront approach. Hope you'll join us in upcoming project.

ghost commented 4 years ago

Hi @rogyar, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.