Closed ismailkoksal closed 1 year ago
Hi there @ismailkoksal I tried this and could not replicate. Can you consistently replicate this over multiple attempts?
I also noticed that requests were succeeding regardless of whether I used the JWT, can you confirm if that's the case for you as well?
Could you also try with WC Blocks 9.6.0 which was released earlier today?
Yes I can consistently replicate this over multiple attempts.
Here an example in video https://user-images.githubusercontent.com/20714736/219174960-9a666182-6562-4f76-aadb-b52985798e36.mp4
@opr I'm using internal woocoomerce-blocks package from woocommerce plugin. How can I install WC Blocks 9.6.0 ?
Hi @ismailkoksal thank you for the information, I will continue to investigate today.
How can I install WC Blocks 9.6.0
You can install our feature plugin from https://wordpress.org/plugins/woo-gutenberg-products-block/
Let me know if this changes things for you!
Hi @ismailkoksal thank you for the information, I will continue to investigate today.
@opr Hi, ok ty
You can install our feature plugin from https://wordpress.org/plugins/woo-gutenberg-products-block/
Let me know if this changes things for you!
Same problem with WC Blocks 9.6.0
@ismailkoksal I have tried multiple times with the following steps:
Can you confirm these are the steps you're doing too?
On step 8, can you double check the customer_id
matches the ID of the new customer you created in step 1?
Thanks!
@opr Yes these are the steps I'm doing and order customer_id matches the ID of the new customer I created. Note that I'm using paypal as payment method.
Here the content of my functions.php
<?php
add_filter('woocommerce_should_load_paypal_standard', '__return_true');
Thank you, I have been able to replicate this, I will add it to our queue to work on!
To summarise, the testing steps are:
You will need to use the paypal
payment method, and send the following payment data with your request:
"payment_data": [
{
"key": "wc-paypal-new-payment-method",
"value": false
}
]
This code https://github.com/woocommerce/woocommerce/blob/4dcff8ccf1b989888170a247be69c6e91deed27b/plugins/woocommerce/includes/class-wc-discounts.php#L654 is called twice when placing the order, the first time it succeeds, the second time it fails.
Hi @ismailkoksal, this is a problem with PayPal not with Blocks, I will leave this issue open while we investigate some more to see if we can apply a fix on our end. I edited your main comment to show these reproduction steps instead.
@wavvves since you will be working on this next week please note that this only happens with PayPal and there are some easier reproductions steps here:
@opr Actually, I have the same problem with another payment method "SogeCommerce" https://sogecommerce.societegenerale.eu/doc/en-EN/plugins/#woocommerce so I don't think its specific to Paypal
If I comment this line the problem disappears https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/StoreApi/Routes/V1/AbstractCartRoute.php#L121
Thanks for the clarification @ismailkoksal - I am not familiar with SogeCommerce, can you let me know if this takes users away from the WooCommerce store (i.e. off-site) to complete the payment?
If not specific to PayPal, then it is specific to the way payment methods that go off-site to complete payment work.
Either way, we will investigate it some more and update this issue when we find more information.
@opr
can you let me know if this takes users away from the WooCommerce store (i.e. off-site) to complete the payment?
Yes
@ismailkoksal great! well this gives us more to go on. Thanks again and keep an eye on this issue for updates.
Hi @opr @wavvves, thanks for the amazing job you guys are doing.
I face the exact same thing at my end on a website, using Paypal. Any chance you could share us any visibility about the fix for this issue ?
Thank you guys and good luck !
Hi @mikailturkoglu , thanks for reaching out. We are planning to take the time to fix it in the current cycle, so it is expectable to see a PR being attached to this during the next week
Hi @wavvves, any news for this issue ?
Thanks for your help.
Hi @mikailturkoglu, this is being investigated right now, so far it seems the problem is not attached to either the payment gateway or the JWT usage, and it is a bug relating to single usage coupons and Store API. Having to create new coupons and orders is slowing debug down a bit, sorry for that.
Having to create new coupons and orders is slowing debug down a bit, sorry for that.
I can give you a tip on this! Create 10 coupons, and then create a new user. Cycle through each coupon per user account, so you only need to switch users once every 10 requests. It sped up debugging a lot for me!
Describe the bug
Using WooCommerce Store API, with coupon applied with usage limit per user set to 1. If I checkout with user connected (I'm using JWT Authentication for WP-API plugin to login and use returned token for next requests), coupon amount become 0.
To reproduce
Steps to reproduce the behavior:
See https://github.com/woocommerce/woocommerce-blocks/issues/8446#issuecomment-1433433753 for simpler reproduction steps
Create any coupon and set Usage limit per user to 1Using WooCommerce Store API, add a product to your cartUsing WooCommerce Store API, apply this coupon to your cartUsing WooCommerce Store API, checkoutExpected behavior
Coupon amount to not being 0.
Screenshots
On Get Checkout (/wp-json/wc/store/v1/checkout), its create me a draft order with coupon applied
On Post Checkout, order status change to Pending with coupon amount = 0
Environment
WordPress (please complete the following information):
Desktop (please complete the following information):
Additional context
All steps I've done its with a new customer created with 0 orders.
After some research in the code, I found the error coming from $discounts->apply_coupon( $coupon ) Here the stack trace: