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

addToCart mutation on custom fields #440

Closed
sn3h opened this issue Feb 20, 2021 · 4 comments
Closed

addToCart mutation on custom fields #440

sn3h opened this issue Feb 20, 2021 · 4 comments

Comments

@sn3h
Copy link

sn3h commented Feb 20, 2021

Is your feature request related to a problem? Please describe.
I need to let a customer add custom value to product parameters, i.e. custom text on tshirt, and/or change value of the product based on those values.. Attributes have predefined values and cannot be customized.

Describe the solution you'd like
Set custom fields value using AFC(or other solution that adds custom fields to products, like Advanced Product Fields for WooCommerce).

Describe alternatives you've considered
After multiple fails to achieve this with WC + wpgqlWC, I am considering only calling login mutation with some private function not to expose JWT and creating product configured by the costumer before adding it to basket, but it has many problems such as I don't know if the order will be finished and paid at the moment of adding it.

Additional context
Images of what state is unreachable now, source is images taken from https://product-demo.studiowombat.com/
image
image
baseket : image

@jasminetracey
Copy link

@sn3h Did get a workaround for this?

@sn3h
Copy link
Author

sn3h commented May 11, 2021

@jasminetracey Hi. Well there are few options, none of them perfect.

  1. You can create order with all required parameters with admin login (with some proxy that handles login), but then there's a problem with getting payment link and verifying that the order is withnin some "reasonable" boundries (anyone can send any payload unless protected with custom logic)
  2. just write / hire someone to write custom php funcitons that will do the price modifications based on meta data. You can start here https://rudrastyh.com/woocommerce/change-product-prices-in-cart.html .
addToCart(
	input: {
      productId: 47, 
      quantity: 1,
    e```
xtraData:"{\"custom_key\":\"custom_value\"}"
  })

will add line item extraData array of objects

"extraData": [
                {
                  "id": "cart___custom_key",
                  "key": "custom_key",
                  "value": "custom_value"
                },...
              ]

so you can modify the price of cart based on your extra data. You have to parse numbers as WC stores everything in extraData as string (no comment on that) .

Big difference vs #1 is that you don't even get your extraData on cart___contents___nodes to show anywhere like if you add metaData to lineItems in createOrder, so you don't see them in the order in WC UI. and have to handle it again This is absolutely terrible and again custom logic is needed.


I am forced to go with #2 but I am quite unhappy with it. So I was checking for option #3 which is another ecommerce solution, but there are some issues everywhere, so I am stuck with 2. Possitive thing about 2 is that you can use starters (gatsby and next) for the logic and save some time.

If you can handle payments yourself and don't need some WP/WC heavylifting you can try https://cartql.com/ to manage cart or try snipcart and other headless solutions.

I hope I helped at least a little

@jasminetracey
Copy link

Thanks for the suggestions i'll try them out and see which one works best

@kidunot89
Copy link
Member

@sn3h You should be able to your desired functionality with WooGraphQL Pro and Product Addons, otherwise your feature request is beyond the scope of WooGraphQL. I'll be closing this issue.

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

No branches or pull requests

3 participants