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

Coupon usage_count triggered twice via /orders/ API #31

Open
Weeb opened this issue Sep 11, 2019 · 1 comment
Labels

Comments

@Weeb
Copy link

@Weeb Weeb commented Sep 11, 2019

Describe the bug
When creating a new order via the API with a coupon code like this:

"coupon_lines": [
{
"code": "something"
}
],

The usage_count is triggered twice IF you also include:

"set_paid": true

To Reproduce
Steps to reproduce the behavior:

  1. Create new coupon, notice usage_count = 0
  2. Create new order via /orders/ API. Include coupon_lines to apply the new coupon AND "set_paid" :true
  3. On success check usage_count for the coupon, now = 2
  4. Do it again but instead use "set_paid": false and notice usage_count increased by 1

Expected behavior
Regardless of payment status the usage_count should only increase by 1?

Isolating the problem (mark completed items with an [x]):

  • [x ] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • [x ] This bug happens with a default WordPress theme active, or Storefront.
  • [x ] I can reproduce this bug consistently using the steps above.

WordPress Environment

WordPress Environment

WordPress address (URL): http://payload.test
Site address (URL): http://payload.test
WC Version: 3.7.0
REST API Version: ✔ 1.0.2
Log Directory Writable: ✔
WP Version: 5.2.3
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –

Server Environment

Server Info: Apache/2.4.29 (Win64) OpenSSL/1.1.1a PHP/7.3.3
PHP Version: 7.3.3
PHP Post Max Size: 2 GB
PHP Time Limit: 36000
PHP Max Input Vars: 1000
cURL Version: 7.64.0
OpenSSL/1.1.1a

SUHOSIN Installed: –
MySQL Version: 5.7.19
Max Upload Size: 2 GB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 3.7.0
WC Database Prefix: wp_stm_
MaxMind GeoIP Database: ✔
Total Database Size: 63.49MB
Database Data Size: 31.75MB
Database Index Size: 31.74MB
wp_stm_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_stm_woocommerce_order_items: Data: 1.52MB + Index: 0.44MB + Engine InnoDB
wp_stm_woocommerce_order_itemmeta: Data: 10.52MB + Index: 10.03MB + Engine InnoDB
wp_stm_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_stm_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_comments: Data: 3.52MB + Index: 3.55MB + Engine InnoDB
wp_stm_failed_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_mailchimp_carts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_options: Data: 1.13MB + Index: 0.02MB + Engine InnoDB
wp_stm_postmeta: Data: 8.52MB + Index: 11.03MB + Engine InnoDB
wp_stm_posts: Data: 2.52MB + Index: 2.38MB + Engine InnoDB
wp_stm_queue: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_term_relationships: Data: 0.22MB + Index: 0.19MB + Engine InnoDB
wp_stm_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_stm_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_stm_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_wc_customer_lookup: Data: 0.23MB + Index: 0.20MB + Engine InnoDB
wp_stm_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_stm_wc_order_product_lookup: Data: 2.52MB + Index: 2.70MB + Engine InnoDB
wp_stm_wc_order_stats: Data: 0.28MB + Index: 0.28MB + Engine InnoDB
wp_stm_wc_order_tax_lookup: Data: 0.19MB + Index: 0.17MB + Engine InnoDB
wp_stm_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_stm_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_stm_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB

Security

Secure connection (HTTPS):
Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: ✔

Active Plugins (1)

WooCommerce: by Automattic – 3.7.0

Inactive Plugins (8)

Klarna Checkout for WooCommerce: by Krokedil – 1.11.0
Mailchimp for WooCommerce: by Mailchimp – 2.2.2 – Not tested with the active version of WooCommerce
WooCommerce Admin: by WooCommerce – 0.18.0
WP Migrate DB Pro: by Delicious Brains – 1.9.8
WP Migrate DB Pro Media Files: by Delicious Brains – 1.4.14
WP Migrate DB Pro Multisite Tools: by Delicious Brains – 1.2.6
WP Migrate DB Pro Theme & Plugin Files: by Delicious Brains – 1.0.5
WP Migrate DB Pro Tweaks: by Delicious Brains – 0.2

Settings

API Enabled: –
Force SSL: –
Currency: SEK (kr)
Currency Position: left_space
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: –

WC Pages

Shop base: woocommerce/woocommerce#5 - /shop/
Cart: woocommerce/woocommerce#6 - /cart/
Checkout: woocommerce/woocommerce#7 - /checkout/
My account: woocommerce/woocommerce#8 - /my-account/
Terms and conditions: Page not set

Theme

Name: Twenty Nineteen
Version: 1.4
Author URL: https://wordpress.org/
Child Theme: – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ✔

Templates

Overrides: –

Action Scheduler

Complete: 4,485
Oldest: 2019-08-11 05:10:49 +0000
Newest: 2019-09-11 05:38:56 +0000

Pending: 1
Oldest: 2019-09-12 04:13:59 +0000
Newest: 2019-09-12 04:13:59 +0000

Canceled: 1
Oldest: 2019-09-11 05:44:02 +0000
Newest: 2019-09-11 05:44:02 +0000

In-progress: 0
Oldest: –
Newest: –

Failed: 0
Oldest: –
Newest: –

@claudiosanches claudiosanches transferred this issue from woocommerce/woocommerce Sep 16, 2019
@issue-label-bot issue-label-bot bot added the type: bug label Sep 16, 2019
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Sep 16, 2019

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.