wp-graphql-woocommerce icon indicating copy to clipboard operation
wp-graphql-woocommerce copied to clipboard

Decimal Product Quantities

Open mruknowme opened this issue 3 years ago • 2 comments

Is it possible to force edit field type for the schema? I installed plugin 'Decimal Product Quantities' but GraphqQL Schema still requires quantity in addToCart to be Int.

mruknowme avatar Sep 06 '22 01:09 mruknowme

@mruknowme You'd have to deregister and register the quantity field across the schema.

This includes both the CartItemInput field and CartItem field.

You have to unregister the Int type fields using the deregister_graphql_field() function, and register Float type fields with register_graphql_field()

kidunot89 avatar Sep 11 '22 22:09 kidunot89

Thanks for the information, will read about it and give it a try

mruknowme avatar Sep 12 '22 03:09 mruknowme

Just confirming that your suggestion worked, though I also had to de-register and register with Float additionally the following:

  deregister_graphql_field('CartItemQuantityInput', 'quantity');
  deregister_graphql_field('LineItem', 'quantity');
  deregister_graphql_field('LineItemInput', 'quantity');
  deregister_graphql_field('CartToCartItemConnection', 'itemCount');

mruknowme avatar Sep 30 '22 08:09 mruknowme