Support for WooGraphQL
-
Hi there
I’d like to request first class support for WooGraphQL – it’s a popular option for using graphql with woocommerce and I was able to make peach payments (version 2 anyway, haven’t tried 3) work with it with a few additions to my functions.php
But there is still some flakiness and it would be great to have “official” support as some of it is a bit of a hack as I need to artificially add stuff to $_POST in places where it doesn’t feel right
// Add saved cards to graphql register_graphql_object_type('PeachPaymentsSavedCard', [ 'description' => __('Describe the Type and what it represents', 'wp-graphql'), 'fields' => [ 'payment_id' => [ 'type' => 'String', 'description' => __('Card registration ID', 'wp-graphql'), ], 'active_card' => [ 'type' => 'String', 'description' => __('Last 4 digits', 'wp-graphql'), ], 'exp_month' => [ 'type' => 'String', 'description' => __('Expiry Month', 'wp-graphql'), ], 'exp_year' => [ 'type' => 'String', 'description' => __('Expiry Year', 'wp-graphql'), ], 'brand' => [ 'type' => 'string', 'description' => __('Card brand', 'wp-graphql'), ], ], ]); add_action( 'graphql_register_types', function() { register_graphql_field( 'Customer', 'peachPaymentsSavedCards', [ 'type' => [ 'list_of' => 'PeachPaymentsSavedCard' ], 'description' => __( 'Saved cards from Peach Payments', 'wp-graphql' ), 'resolve' => function( $customer ) { $credit_cards = get_user_meta( $customer->databaseId, '_peach_payment_id', false ); return $credit_cards ? $credit_cards : array(); } ] ); } ); add_action( 'graphql_woocommerce_before_checkout', function() { $_POST['peach_payment_id'] = 'dontsave'; } ); add_filter( 'graphql_peach-payments_process_payment_args', function ($args) { $peach_payment_id = get_post_meta($args[0], '_peach_payment_id', true); if (isset($peach_payment_id)) { $_POST['peach_payment_id'] = $peach_payment_id; } else { $_POST['peach_payment_id'] = 'dontsave'; } return $args; });
This is the current code I have in my theme, and after doing a checkout mutation I redirect to the redirect url for payment/completion
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Support for WooGraphQL’ is closed to new replies.