woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.32k stars 10.75k forks source link

Woocommerce Max Discount its not Apply Through API & Other Smart Coupon Rules #31372

Closed HBaz92 closed 2 years ago

HBaz92 commented 2 years ago

Prerequisites (mark completed items with an [x]):

Describe the bug im using smart coupon plugin from woocommerc and when i add rules For example like max discount its not apply through api ..The order is created through api but does not comply to any rules i had set it on it......

Expected behavior & Actual behavior i create coupon "Dis10" and the discount_type is : "Percentage discount" 10% with max discount 10$...after that i create the order from api and i put the coupon "Dis10".... and the total of basket is 150$ ...the final total should be 140$ after apply coupon ...but instead i get final total 135$ ?!!!

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.) Steps to reproduce the bug:

  1. Create new Coupon With discount_type : "Percentage discount" with value of 10% and max discount 10$.
  2. and this is the details of the coupon that i created
    "id": 25804 "code": "dis10", "amount": "10.00", "date_created": "2021-01-12T13:10:54", "date_created_gmt": "2021-01-12T10:10:54", "date_modified": "2021-12-06T14:40:57", "date_modified_gmt": "2021-12-06T11:40:57", "discount_type": "percent", "description": "", "date_expires": null, "date_expires_gmt": null, "usage_count": 254, "individual_use": true, "product_ids": [ ], "excluded_product_ids": [ ], "usage_limit": 5000, "usage_limit_per_user": null, "limit_usage_to_x_items": null, "free_shipping": false, "product_categories": [ ], "excluded_product_categories": [ ], "exclude_sale_items": false, "minimum_amount": "0.00", "maximum_amount": "0.00", "email_restrictions": [ ], "used_by": [ ], "meta_data": [ { "id": 330529, "key": "sa_cbl_locations_lookup_in", "value": { "address": "billing" } }, { "id": 330532, "key": "wc_coupon_message", "value": "" }, { "id": 330533, "key": "wc_email_message", "value": "no" }, { "id": 330544, "key": "sc_restrict_to_new_user", "value": "no" }, { "id": 330545, "key": "auto_generate_coupon", "value": "no" }, { "id": 330546, "key": "coupon_title_prefix", "value": "" }, { "id": 330547, "key": "coupon_title_suffix", "value": "" }, { "id": 330548, "key": "sc_coupon_validity", "value": "" }, { "id": 330549, "key": "validity_suffix", "value": "days" }, { "id": 330550, "key": "sc_is_visible_storewide", "value": "yes" }, { "id": 330551, "key": "sc_disable_email_restriction", "value": "no" }, { "id": 330552, "key": "is_pick_price_of_product", "value": "no" }, { "id": 330553, "key": "wc_sc_add_product_details", "value": [ ] }, { "id": 330554, "key": "wc_sc_max_discount", "value": "10" }, { "id": 330555, "key": "wc_sc_expiry_time", "value": "" }, { "id": 330556, "key": "sa_cbl_billing_locations", "value": [ ] }, { "id": 330557, "key": "wc_sc_payment_method_ids", "value": [ ] }, { "id": 330558, "key": "wc_sc_shipping_method_ids", "value": [ ] }, { "id": 330559, "key": "wc_sc_user_role_ids", "value": [ ] }, { "id": 330560, "key": "wc_sc_product_attribute_ids", "value": "" }, { "id": 330561, "key": "wc_sc_exclude_product_attribute_ids", "value": "" }, { "id": 402660, "key": "_coupon_held_1616996387_sDyF3S", "value": "" }, { "id": 402661, "key": "_maybe_used_by_1616996387_iV0Epi", "value": "306" }, { "id": 427477, "key": "_coupon_held_1617370817_tKZ37r", "value": "" }, { "id": 427478, "key": "_maybe_used_by_1617370817_Cujl98", "value": "488" }, { "id": 640787, "key": "phone_model_app_reg", "value": "" }, { "id": 640788, "key": "_phone_model_app_reg", "value": "field_60eabdc574ebc" }, { "id": 640789, "key": "ver_app_reg", "value": "" }, { "id": 640790, "key": "_ver_app_reg", "value": "field_60eabdda74ebd" }, { "id": 681445, "key": "_coupon_held_1628746342_sqJP2y", "value": "" }, { "id": 681446, "key": "_maybe_used_by_1628746342_yBaxau", "value": "1705" }, { "id": 1078255, "key": "_is_coupon_cashback", "value": "no" }, { "id": 1078256, "key": "wc_sc_auto_apply_coupon", "value": "no" }, { "id": 1078257, "key": "wc_sc_exclude_user_role_ids", "value": [ ] }, { "id": 1078258, "key": "wc_sc_taxonomy_restrictions", "value": [ ] } ], "_links": { "self": [ { "href": "https://xxxxxx.com/wp-json/wc/v3/coupons/25804" } ], "collection": [ { "href": "https://xxxxxx.com/wp-json/wc/v3/coupons" } ] } }

3- create order from api postman as following in api body:

{"line_items":[{"product_id":"53056","quantity":1,"meta_data":[]}],"customer_id":25, "billing":{"first_name":"Dived","last_name":"Loy","address_1":"g1","address_2":"g2","company":"wordpress company","city":"jeddah","state":"Makkah","country":"SA","phone":"+966555555555","postcode":"12345","mapUrl":null,"mobile_model":null,"ver_app":null,"email":"xxx@xxx.com"}, "shipping":{"first_name":"Dived","last_name":"Loy","address_1":"g1","address_2":"g2","company":"wordpress company","city":"jeddah","state":"Makkah","country":"SA","phone":"+966555555555","postcode":"12345","mapUrl":null,"mobile_model":null,"ver_app":null,"email":"xxx@xxx.com"}, "coupon_lines":[{"code":"dis10","discount_type":"percent"}]}

4-the Final total shows wrong as 135$ ...and its should be 140$ .

Screenshots Screen-Shot-2021-12-06-at-2-41-49-PM

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

WordPress Environment

### WordPress Environment ### WordPress address (URL): https://xxxxx.com Site address (URL): https://xxxxx.com WC Version: 5.9.0 REST API Version: ✔ 5.9.0 WC Blocks Version: ✔ 6.1.0 Action Scheduler Version: ✔ 3.3.0 WC Admin Version: ✔ 2.8.0 Log Directory Writable: ✔ WP Version: 5.8.2 WP Multisite: – WP Memory Limit: 2 GB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 7.4.26 PHP Post Max Size: 8 MB PHP Time Limit: 2000 PHP Max Input Vars: 4000 cURL Version: 7.79.1 OpenSSL/1.1.1l SUHOSIN Installed: – MySQL Version: 5.7.36 Max Upload Size: 8 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 5.6.0 WC Database Prefix: wp_ Total Database Size: 585.97MB Database Data Size: 454.08MB Database Index Size: 131.89MB wp_woocommerce_sessions: Data: 13.47MB + Index: 0.19MB + Engine MyISAM wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_order_items: Data: 2.76MB + Index: 1.00MB + Engine MyISAM wp_woocommerce_order_itemmeta: Data: 26.57MB + Index: 12.06MB + Engine MyISAM wp_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woocommerce_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM coupon_app: Data: 0.00MB + Index: 0.01MB + Engine MyISAM orders: Data: 0.02MB + Index: 0.00MB + Engine InnoDB order_meta_data: Data: 0.02MB + Index: 0.00MB + Engine InnoDB postmeta_coupon_app: Data: 0.01MB + Index: 0.01MB + Engine MyISAM wp_actionscheduler_actions: Data: 41.88MB + Index: 14.70MB + Engine MyISAM wp_actionscheduler_claims: Data: 0.24MB + Index: 0.45MB + Engine MyISAM wp_actionscheduler_groups: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_actionscheduler_logs: Data: 30.82MB + Index: 16.50MB + Engine MyISAM wp_addonlibrary_addons: Data: 0.04MB + Index: 0.00MB + Engine MyISAM wp_addonlibrary_categories: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_adtribes_my_conversions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_cartflows_ca_cart_abandonment: Data: 9.52MB + Index: 0.08MB + Engine InnoDB wp_cartflows_ca_email_history: Data: 0.06MB + Index: 0.06MB + Engine InnoDB wp_cartflows_ca_email_templates: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_cartflows_ca_email_templates_meta: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_commentmeta: Data: 0.05MB + Index: 0.04MB + Engine MyISAM wp_comments: Data: 5.80MB + Index: 1.60MB + Engine MyISAM wp_delivery_woo_notification: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_digits_blocked_ip: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_digits_digrest_token: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_digits_mobile_otp: Data: 0.24MB + Index: 0.08MB + Engine MyISAM wp_digits_requests_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_frm_fields: Data: 0.03MB + Index: 0.01MB + Engine MyISAM wp_frm_forms: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_frm_items: Data: 0.02MB + Index: 0.01MB + Engine MyISAM wp_frm_item_metas: Data: 0.04MB + Index: 0.02MB + Engine MyISAM wp_gla_budget_recommendations: Data: 0.22MB + Index: 0.14MB + Engine InnoDB wp_gla_merchant_issues: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_gla_shipping_rates: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_gla_shipping_times: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_icl_content_status: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_core_status: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_flags: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_languages: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_icl_languages_translations: Data: 0.10MB + Index: 0.11MB + Engine MyISAM wp_icl_locale_map: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_message_status: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_mo_files_domains: Data: 0.01MB + Index: 0.01MB + Engine MyISAM wp_icl_node: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_reminders: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_strings: Data: 9.14MB + Index: 8.14MB + Engine MyISAM wp_icl_string_batches: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_string_packages: Data: 0.02MB + Index: 0.00MB + Engine MyISAM wp_icl_string_pages: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_string_positions: Data: 3.86MB + Index: 1.38MB + Engine MyISAM wp_icl_string_status: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_string_translations: Data: 2.70MB + Index: 0.97MB + Engine MyISAM wp_icl_string_urls: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_icl_translate: Data: 11.45MB + Index: 2.70MB + Engine MyISAM wp_icl_translate_job: Data: 0.48MB + Index: 0.18MB + Engine MyISAM wp_icl_translations: Data: 1.87MB + Index: 3.46MB + Engine MyISAM wp_icl_translation_batches: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_icl_translation_downloads: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_icl_translation_status: Data: 23.55MB + Index: 0.47MB + Engine MyISAM wp_links: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_litespeed_img_optm: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_litespeed_optimizer: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_mailchimp_carts: Data: 3.52MB + Index: 0.00MB + Engine InnoDB wp_mailchimp_jobs: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_mobile_builder: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_mobile_builder_carts: Data: 0.16MB + Index: 0.01MB + Engine MyISAM wp_monsterinsights_pageinsights_cache: Data: 6.52MB + Index: 0.14MB + Engine InnoDB wp_mstore_checkout: Data: 2.53MB + Index: 0.01MB + Engine MyISAM wp_options: Data: 11.12MB + Index: 0.53MB + Engine MyISAM wp_pmxe_exports: Data: 0.69MB + Index: 0.00MB + Engine MyISAM wp_pmxe_google_cats: Data: 0.26MB + Index: 0.05MB + Engine MyISAM wp_pmxe_posts: Data: 1.80MB + Index: 0.79MB + Engine MyISAM wp_pmxe_templates: Data: 0.68MB + Index: 0.00MB + Engine MyISAM wp_pmxi_files: Data: 0.04MB + Index: 0.01MB + Engine MyISAM wp_pmxi_hash: Data: 0.90MB + Index: 0.61MB + Engine MyISAM wp_pmxi_history: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_pmxi_images: Data: 0.74MB + Index: 0.18MB + Engine MyISAM wp_pmxi_imports: Data: 4.42MB + Index: 0.00MB + Engine MyISAM wp_pmxi_posts: Data: 2.77MB + Index: 0.91MB + Engine MyISAM wp_pmxi_templates: Data: 0.30MB + Index: 0.00MB + Engine MyISAM wp_postmeta: Data: 139.72MB + Index: 25.03MB + Engine MyISAM wp_posts: Data: 24.87MB + Index: 4.15MB + Engine MyISAM wp_rank_math_404_logs: Data: 0.01MB + Index: 0.02MB + Engine MyISAM wp_rank_math_analytics_ga: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_rank_math_analytics_gsc: Data: 0.55MB + Index: 0.35MB + Engine MyISAM wp_rank_math_analytics_keyword_manager: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_rank_math_analytics_objects: Data: 0.99MB + Index: 0.25MB + Engine MyISAM wp_rank_math_internal_links: Data: 0.66MB + Index: 0.13MB + Engine MyISAM wp_rank_math_internal_meta: Data: 0.21MB + Index: 0.15MB + Engine MyISAM wp_rank_math_redirections: Data: 0.05MB + Index: 0.01MB + Engine MyISAM wp_rank_math_redirections_cache: Data: 0.03MB + Index: 0.01MB + Engine MyISAM wp_relevanssi: Data: 14.23MB + Index: 12.92MB + Engine MyISAM wp_relevanssi_log: Data: 5.04MB + Index: 2.90MB + Engine MyISAM wp_relevanssi_stopwords: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_css: Data: 0.09MB + Index: 0.00MB + Engine MyISAM wp_revslider_css_bkp: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_revslider_layer_animations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_layer_animations_bkp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_navigations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_navigations_bkp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_sliders: Data: 0.02MB + Index: 0.00MB + Engine MyISAM wp_revslider_sliders_bkp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_slides: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_revslider_slides_bkp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_static_slides: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_revslider_static_slides_bkp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_rnlab_template_mobile: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_smush_dir_images: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_sm_advanced_search_temp: Data: 0.06MB + Index: 0.02MB + Engine InnoDB wp_sm_views: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_termmeta: Data: 0.87MB + Index: 0.55MB + Engine MyISAM wp_terms: Data: 0.22MB + Index: 0.37MB + Engine MyISAM wp_term_relationships: Data: 1.57MB + Index: 3.03MB + Engine MyISAM wp_term_taxonomy: Data: 0.22MB + Index: 0.15MB + Engine MyISAM wp_usermeta: Data: 23.87MB + Index: 7.11MB + Engine MyISAM wp_users: Data: 0.55MB + Index: 0.34MB + Engine MyISAM wp_vi_wbe_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_daily_analysis: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wcfm_delivery_orders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wcfm_delivery_orders_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_detailed_analysis: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_enquiries: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_enquiries_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_enquiries_response: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_enquiries_response_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_fbc_chat_rows: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_fbc_chat_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wcfm_fbc_chat_visitors: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_fbc_offline_messages: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_following_followers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_messages: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_messages_modifier: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_messages_stat: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_support: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_support_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_support_response: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcfm_support_response_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wcpdf_invoice_number: Data: 0.03MB + Index: 0.02MB + Engine MyISAM wp_wcpdf_packing_slip_number: Data: 0.03MB + Index: 0.02MB + Engine MyISAM wp_wc_admin_notes: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_wc_admin_note_actions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wc_category_lookup: Data: 0.03MB + Index: 0.04MB + Engine MyISAM wp_wc_customer_lookup: Data: 0.18MB + Index: 0.14MB + Engine MyISAM wp_wc_download_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wc_order_coupon_lookup: Data: 0.05MB + Index: 0.08MB + Engine MyISAM wp_wc_order_product_lookup: Data: 2.62MB + Index: 2.19MB + Engine MyISAM wp_wc_order_stats: Data: 0.18MB + Index: 0.13MB + Engine MyISAM wp_wc_order_tax_lookup: Data: 0.11MB + Index: 0.12MB + Engine MyISAM wp_wc_points_rewards_user_points: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wc_points_rewards_user_points_log: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_wc_product_meta_lookup: Data: 0.70MB + Index: 0.84MB + Engine MyISAM wp_wc_reserved_stock: Data: 0.04MB + Index: 0.03MB + Engine MyISAM wp_wc_tax_rate_classes: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_wc_webhooks: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_woodmart_wishlists: Data: 0.03MB + Index: 0.02MB + Engine MyISAM wp_woodmart_wishlist_products: Data: 0.01MB + Index: 0.02MB + Engine MyISAM wp_woo_wallet_transactions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woo_wallet_transaction_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wpmailsmtp_tasks_meta: Data: 0.03MB + Index: 0.01MB + Engine MyISAM wp_wpnotif_mobile_otp: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_newsletter: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_newsletter_history: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_newsletter_send_history: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_sms_app: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_subgroups: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpnotif_subgroups_subscribers: Data: 0.29MB + Index: 0.83MB + Engine MyISAM wp_wpnotif_subscribers: Data: 0.63MB + Index: 0.50MB + Engine MyISAM wp_wpnotif_whatsapp_messages: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_wpr_rucss_resources: Data: 10.52MB + Index: 0.19MB + Engine InnoDB wp_wpr_rucss_used_css: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wrc_caches: Data: 0.12MB + Index: 0.08MB + Engine MyISAM wp_wrc_relations: Data: 0.08MB + Index: 0.11MB + Engine MyISAM wp_wsal_metadata: Data: 0.16MB + Index: 0.23MB + Engine InnoDB wp_wsal_occurrences: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wsc_collections: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wsc_collections_recs: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yith_wcwl: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_yith_wcwl_lists: Data: 0.00MB + Index: 0.01MB + Engine MyISAM wp_yith_ywpar_points_log: Data: 0.34MB + Index: 0.08MB + Engine MyISAM wp_ylc_chat_rows: Data: 0.01MB + Index: 0.00MB + Engine MyISAM wp_ylc_chat_sessions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_ylc_chat_visitors: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_ylc_offline_messages: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_yoast_indexable: Data: 1.52MB + Index: 0.47MB + Engine InnoDB wp_yoast_indexable_hierarchy: Data: 0.09MB + Index: 0.16MB + Engine InnoDB wp_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_ywcars_messagemeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM wp_ywcars_messages: Data: 0.00MB + Index: 0.00MB + Engine MyISAM ### Post Type Counts ### acf-field: 7 acf-field-group: 5 attachment: 23915 cms_block: 40 frm_form_actions: 2 frm_styles: 2 gift_card: 14 mc4wp-form: 1 nav_menu_item: 103 page: 74 post: 259 product: 6652 product_variation: 2184 racemailtemplate: 1 rank_math_schema: 3 revision: 1547 shop_coupon: 882 shop_order: 2578 shop_order_refund: 5 vc_grid_item: 3 w_default_attributes: 1 woodmart_sidebar: 2 woodmart_slide: 2 yith_refund_request: 10 yith-wccos-ostatus: 14 ylc-macro: 1 ywar_reviews: 28 ywtm_tab: 3 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (59) ### WPML Multilingual CMS: by OnTheGoSystems – 4.4.12 Advanced Custom Fields: by Delicious Brains – 5.11.1 All-in-One WP Migration: by ServMask – 7.50 Bulky - Bulk Edit Products for WooCommerce Premium: by VillaTheme – 1.1.4 Classic Widgets: by WordPress Contributors – 0.2 CMP - Coming Soon & Maintenance Plugin: by NiteoThemes – 4.0.17 Delivery Drivers for WooCommerce: by Devio Digital – 3.2.1 DIGITS: Wordpress Mobile Number Signup and Login: by UnitedOver – 7.8.1.8 GetWooPlugins Updater: by Emran Ahmed – 1.0.0 Hide Admin Bar From Front End: by Ankit Panchal – 2.8.0 WPBakery Page Builder: by Michael M - WPBakery.com – 6.7.0 Members: by MemberPress – 3.1.6 Moyasar Payment Gateway: by Moyasar Development Team – 4.3.4 Mstore API: by InspireUI – 3.3.8 Multilingual Comments: by Yame – 1.0.1 Really Simple SSL: by Really Simple Plugins – 5.2.0 Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.5 Relevanssi: by Mikko Saari – 4.14.4 Safe SVG: by Daryll Doyle – 1.9.9 Smart Manager For WooCommerce – Stock Management, Bulk Edit & more...: by StoreApps – 5.30.0 States, Cities, and Places for WooCommerce: by Kingsley Ochu – 1.3.1 User Menus: by Code Atlantic – 1.2.7 Easy Username Updater: by Yogesh C. Pant – 1.0.4 WooCommerce Smart COD PRO: by woosmartcod.com – 1.4.3 WooCommerce Load Group Attributes Product: by Ali Zarei – 1.0.0 Variation Swatches for WooCommerce: by Emran Ahmed – 1.1.19 TeraWallet: by WCBeginner – 1.3.20 WooCommerce Multilingual: by OnTheGoSystems – 4.12.1 WooCommerce PDF Invoices Italian Add-on: by laboratorio d'Avanguardia – 0.7.0.21 WooCommerce PDF Invoices & Packing Slips: by Ewout Fernhout – 2.10.3 WooCommerce PDF Invoices & Packing Slips + mPDF: by Ewout Fernhout – 2.1.2 WooCommerce PDF Invoices & Packing Slips Professional: by Ewout Fernhout – 2.2.14 WooCommerce PDF Invoices & Packing Slips Premium Templates: by Ewout Fernhout – 2.6.2 Shipping by City for BETRS: by Bolder Elements – 1.1 Shipping Cost Limitations for BETRS: by Bolder Elements – 1.0 WooCommerce Smart Coupons: by StoreApps – 4.33.1 WooCommerce Table Rate Shipping: by Bolder Elements – 4.2 WooCommerce Ultimate Barcodes: by Alexandre Faustino – 1.3.0 WooCommerce: by Automattic – 5.9.0 Woodmart Core: by – 1.0.31 WP All Export Pro: by Soflyy – 1.7.2 WP All Import Pro: by Soflyy – 4.7.1 WP REST Cache: by Acato – 2021.4.1 WP Rocket | Deactivate WooCommerce Refresh Cart Fragments Cache: by WP Rocket Support Team – WP Rocket: by WP Media – 3.10.3 Smush Pro: by WPMU DEV – 3.8.1 WP All Export - ACF Export Add-On Pro: by Soflyy – 1.0.3 WP All Export - User Export Add-On Pro: by Soflyy – 1.0.7 WP All Export - WooCommerce Export Add-On Pro: by Soflyy – 1.0.3 WP All Import - User Import Add-On Pro: by Soflyy – 1.1.6 WP All Import - WooCommerce Add-On Pro: by Soflyy – 3.2.8 WPML All Import: by OnTheGoSystems – 2.2.0 WPML String Translation: by OnTheGoSystems – 3.1.10 WPML Translation Management: by OnTheGoSystems – 2.10.8 YITH WooCommerce Checkout Manager: by YITH – 1.4.3 YITH WooCommerce Custom Order Status Premium: by YITH – 1.2.1 YITH WooCommerce Customize My Account Page: by YITH – 3.1.2 YITH WooCommerce Order Tracking Premium: by YITH – 1.6.9 YITH WooCommerce Points and Rewards Premium: by YITH – 2.0.3 ### Inactive Plugins (24) ### All-in-One WP Migration Google Drive Extension: by ServMask – 2.69 Aramex Shipping WooCommerce: by aramex.com – 1.1.11 DIGITS: Merge Phone Number Addon: by UnitedOver – 1.6.1 DIGITS: Old Account Migrator Addon: by UnitedOver – 1.8.2 DIGITS: REST API Addon: by UnitedOver – 2.1 Font Awesome: by Font Awesome – 4.0.4 Formidable Export View to CSV: by Strategy11 – 1.03 Formidable Forms: by Strategy11 – 5.0.13.1 Formidable Forms Pro: by Strategy11 – 4.09.02 Formidable Multilingual: by Strategy11 – 1.07 Formidable Views: by Strategy11 – 4.0.03 Limit Login Attempts Reloaded: by Limit Login Attempts Reloaded – 2.23.1 MonsterInsights - eCommerce Addon: by MonsterInsights Team – 7.3.8 PublishPress Capabilities: by PublishPress – 2.3 Query Monitor: by John Blackbourn – 3.7.1 Smush: by WPMU DEV – 3.8.8 Variation Swatches for WooCommerce - Pro: by Emran Ahmed – 1.0.55 WooCommerce - Product Importer: by Visser Labs – 1.5.2 WooCommerce Admin: by WooCommerce – 2.8.0 WordPress Importer: by wordpressdotorg – 0.7 WP Mail SMTP: by WPForms – 3.2.1 WP Options Importer: by Matthew Boynes – 5 WPS Hide Login: by WPServeur NicolasKulka wpformation – 1.9.1 YITH Advanced Refund System for WooCommerce Premium: by YITH – 1.1.12 ### Dropin Plugins (1) ### advanced-cache.php: advanced-cache.php ### Must Use Plugins (3) ### installatron_hide_status_test.php: by – WordPress automation by Installatron: by – WP REST Cache - Must-Use Plugin: by Richard Korthuis - Acato – 2018.2.1 ### Settings ### API Enabled: – Force SSL: – Currency: SAR (SAR) Currency Position: right_space Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) gift-card (gift-card) 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: #7 - /shop/ Cart: #8 - /cart/ Checkout: #9 - /checkout/ My account: #10 - /my-account/ Terms and conditions: #21837 - /terms-conditions-checkout/ ### Theme ### Name: Woodmart Child Version: 1.0.0 Author URL: http://xtemos.com Child Theme: ✔ Parent Theme Name: Woodmart Parent Theme Version: 6.2.4 Parent Theme Author URL: http://themeforest.net/user/xtemos WooCommerce Support: ✔ ### Templates ### Overrides: woodmart/woocommerce/archive-product.php woodmart/woocommerce/cart/cart-item-data.php woodmart/woocommerce/cart/cart.php woodmart/woocommerce/cart/cross-sells.php woodmart/woocommerce/cart/mini-cart.php woodmart/woocommerce/checkout/form-checkout.php woodmart/woocommerce/checkout/review-order.php woodmart/woocommerce/checkout/thankyou.php woodmart/woocommerce/content-product-cat.php woodmart/woocommerce/content-product.php woodmart/woocommerce/content-single-product.php woodmart/woocommerce/content-widget-product.php woodmart/woocommerce/global/breadcrumb.php woodmart/woocommerce/global/form-login.php woodmart/woocommerce/global/quantity-input.php woodmart/woocommerce/loop/add-to-cart.php woodmart/woocommerce/loop/loop-end.php woodmart/woocommerce/loop/loop-start.php woodmart/woocommerce/loop/no-products-found.php woodmart/woocommerce/loop/orderby.php woodmart/woocommerce/loop/pagination.php woodmart/woocommerce/loop/sale-flash.php woodmart/woocommerce/myaccount/form-login.php woodmart/woocommerce/product-searchform.php woodmart/woocommerce/single-product/add-to-cart/grouped.php woodmart/woocommerce/single-product/add-to-cart/variable.php woodmart/woocommerce/single-product/meta.php woodmart/woocommerce/single-product/product-image.php woodmart/woocommerce/single-product/product-thumbnails.php woodmart/woocommerce/single-product/rating.php woodmart/woocommerce/single-product/related.php woodmart/woocommerce/single-product/sale-flash.php woodmart/woocommerce/single-product/tabs/tabs.php woodmart/woocommerce/single-product/title.php woodmart/woocommerce/single-product/up-sells.php woodmart/woocommerce/single-product.php woodmart/woocommerce/content-product_cat.php version 2.6.1 is out of date. The core version is 4.7.0 Outdated Templates: ❌ ### Action Scheduler ### Canceled: 120 Oldest: 2021-11-05 17:00:22 +0300 Newest: 2021-11-22 19:50:46 +0300 Complete: 46,397 Oldest: 2021-12-02 16:29:54 +0300 Newest: 2021-12-06 15:36:13 +0300 Failed: 68,959 Oldest: 2020-12-20 16:14:14 +0300 Newest: 2021-07-20 05:37:43 +0300 Pending: 3 Oldest: 2021-12-06 16:32:04 +0300 Newest: 2021-12-12 04:44:34 +0300 ### Status report information ### Generated at: 2021-12-06 15:36:16 +03:00
tammullen commented 2 years ago

Hi @HBaz92 ,

While our goal is to address all the issues reported in this repository, GitHub should be treated as a place to report WooCommerce bugs only.

You checked the checklist item that you have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active however you also mentioned this happens with WooCommerce Smart Coupons Plugin by StoreApps and your system status reports mentions 58 other active plugins.

Can you please confirm if you performed initial troubleshooting such as testing for theme and plugins conflict on your site? To do that, you’d need to deactivate all plugins except for WooCommerce and switch the default theme such as Storefront. Then test again.

To us evaluate this issue can you also confirm which WC API endpoint are you using (including the version e.g. /wp-json/wc/v3/products)?

HBaz92 commented 2 years ago

i have made new Wordpress web Site and this data now you see is i reproduce the bug from

Prerequisites (mark completed items with an [x]):

Describe the bug im using smart coupon plugin from woocommerc and when i add rules For example like max discount its not apply through api ..The order is created through api but does not comply to any rules i had set it on it......

Expected behavior & Actual behavior i create coupon "Dis10" and the discount_type is : "Percentage discount" 10% with max discount 10$...after that i create the order from api and i put the coupon "Dis10".... and the total of basket is 150$ ...the final total should be 140$ after apply coupon ...but instead i get final total 135$ ?!!!

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.) Steps to reproduce the bug: 1. Create new Coupon With discount_type : "Percentage discount" with value of 10% and max discount 10$. 33334

2. and this is the details of the coupon that i created :

{"id":24,"code":"dis10","amount":"10.00","date_created":"2021-12-13T10:49:48","date_created_gmt":"2021-12-13T10:49:48","date_modified":"2021-12-13T13:01:50","date_modified_gmt":"2021-12-13T13:01:50","discount_type":"percent","description":"","date_expires":null,"date_expires_gmt":null,"usage_count":3,"individual_use":true,"product_ids":[],"excluded_product_ids":[],"usage_limit":null,"usage_limit_per_user":null,"limit_usage_to_x_items":null,"free_shipping":false,"product_categories":[],"excluded_product_categories":[],"exclude_sale_items":false,"minimum_amount":"0.00","maximum_amount":"0.00","email_restrictions":[],"used_by":["1","1","1"],"meta_data":[{"id":79,"key":"sa_cbl_locations_lookup_in","value":{"address":"billing"}},{"id":82,"key":"wc_coupon_message","value":""},{"id":83,"key":"wc_email_message","value":"no"},{"id":94,"key":"sc_restrict_to_new_user","value":"no"},{"id":95,"key":"auto_generate_coupon","value":"no"},{"id":96,"key":"coupon_title_prefix","value":""},{"id":97,"key":"coupon_title_suffix","value":""},{"id":98,"key":"sc_coupon_validity","value":""},{"id":99,"key":"validity_suffix","value":"days"},{"id":100,"key":"sc_is_visible_storewide","value":"no"},{"id":101,"key":"sc_disable_email_restriction","value":"no"},{"id":102,"key":"is_pick_price_of_product","value":"no"},{"id":103,"key":"wc_sc_add_product_details","value":[]},{"id":104,"key":"wc_sc_max_discount","value":"10"},{"id":105,"key":"wc_sc_expiry_time","value":""},{"id":106,"key":"wc_sc_auto_apply_coupon","value":"no"},{"id":107,"key":"sa_cbl_billing_locations","value":[]},{"id":108,"key":"wc_sc_payment_method_ids","value":[]},{"id":109,"key":"wc_sc_shipping_method_ids","value":[]},{"id":110,"key":"wc_sc_user_role_ids","value":[]},{"id":111,"key":"wc_sc_exclude_user_role_ids","value":[]},{"id":112,"key":"wc_sc_product_attribute_ids","value":""},{"id":113,"key":"wc_sc_exclude_product_attribute_ids","value":""},{"id":114,"key":"wc_sc_taxonomy_restrictions","value":[]}],"_links":{"self":[{"href":"https:\/\/xxx.com\/wp-json\/wc\/v3\/coupons\/24"}],"collection":[{"href":"https:\/\/xxx.com\/wp-json\/wc\/v3\/coupons"}]}}

3- create order from api postman as following in api body : POST API : https://xxxx.com/wp-json/wc/v3/orders?consumer_key=ck_9e7738ee85eXXXXXX&consumer_secret=cs_0dd3bb39XXXXXX

{"line_items":[{"product_id":"53056","quantity":1,"meta_data":[]}],"customer_id":25, "billing":{"first_name":"mahmmd","last_name":"awad","address_1":"St1","address_2":"ST2","company":"wowo","city":"Jeddah","state":"Makkah","country":"SA","phone":"+966000000000","postcode":"12345","mapUrl":null,"mobile_model":null,"ver_app":null,"email":"xxx@xxx.com"}, "shipping":{"first_name":"mahmmd","last_name":"awad","address_1":"St1","address_2":"ST2","company":"wowo","city":"Jeddah","state":"Makkah","country":"SA","phone":"+966000000000","postcode":"12345","mapUrl":null,"mobile_model":null,"ver_app":null,"email":"xxx@xxx.com"}, "coupon_lines":[{"code":"dis10","discount_type":"percent"}]}

4- create order from api postman as following in api get info : GET API : https://xxxx.com/wp-json/wc/v3/orders/27?consumer_key=ck_9e7738ee85eXXXXXX&consumer_secret=cs_0dd3bb39XXXXXX

{"id":27,"parent_id":0,"status":"pending","currency":"SAR","version":"5.9.0","prices_include_tax":false,"date_created":"2021-12-13T12:33:22","date_modified":"2021-12-13T12:33:22","discount_total":"15.00","discount_tax":"0.00","shipping_total":"0.00","shipping_tax":"0.00","cart_tax":"0.00","total":"135.00","total_tax":"0.00","customer_id":1,"order_key":"wc_order_VSuiwfe2JkOr5","billing":{"first_name":"mahmmd","last_name":"awad","company":"wowo","address_1":"St1","address_2":"ST2","city":"Jeddah","state":"Makkah","postcode":"12345","country":"SA","email":"xxx@xxx.com","phone":"+966000000000"},"shipping"{"first_name":"mahmmd","last_name":"awad","company":"wowo","address_1":"St1","address_2":"ST2","city":"Jeddah","state":"Makkah","postcode":"12345","country":"SA","phone":"+966000000000"},"payment_method":"","payment_method_title":"","transaction_id":"","customer_ip_address":"","customer_user_agent":"","created_via":"rest-api","customer_note":"","date_completed":null,"date_paid":null,"cart_hash":"","number":"26","meta_data":[],"line_items":[{"id":4,"name":"Nice T-shirt blue","product_id":12,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"150.00","subtotal_tax":"0.00","total":"135.00","total_tax":"0.00","taxes":[{"id":1,"total":"0","subtotal":"0"}],"meta_data":[],"sku":"020504-5585","price":135,"parent_name":null}],"tax_lines":[{"id":5,"rate_code":"TAX-1","rate_id":1,"label":"Tax","compound":false,"tax_total":"0.00","shipping_tax_total":"0.00","rate_percent":0,"meta_data":[]}],"shipping_lines":[],"fee_lines":[],"coupon_lines":[{"id":6,"code":"dis10","discount":"15","discount_tax":"0","meta_data":[]}],"refunds":[],"date_created_gmt":"2021-12-13T12:33:22","date_modified_gmt":"2021-12-13T12:33:22","date_completed_gmt":null,"date_paid_gmt":null,"currency_symbol":"\u0631.\u0633","_links":{"self":[{"href":"https:\/\/xxx.com\/wp-json\/wc\/v3\/orders\/26"}],"collection":[{"href":"https:\/\/xxx.com\/wp-json\/wc\/v3\/orders"}],"customer":[{"href":"https:\/\/xxx.com\/wp-json\/wc\/v3\/customers\/1"}]}}

5-the Final total shows wrong as 135$ ...and its should be 140$ .

Screenshots Screen-Shot-2021-12-13-at-3-20-24-PM

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

WordPress Environment

` ### WordPress Environment ### WordPress address (URL): http://xxx.com Site address (URL): http://xxx.com WC Version: 5.9.0 REST API Version: ✔ 5.9.0 WC Blocks Version: ✔ 6.1.0 Action Scheduler Version: ✔ 3.3.0 WC Admin Version: ✔ 2.8.0 Log Directory Writable: ✔ WP Version: 5.8.2 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 8.0.13 PHP Post Max Size: 8 MB PHP Time Limit: 1000 PHP Max Input Vars: 1000 cURL Version: 7.80.0 OpenSSL/1.1.1l SUHOSIN Installed: – MySQL Version: 5.7.36 Max Upload Size: 8 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 5.9.0 WC Database Prefix: wp_ Total Database Size: 4.85MB Database Data Size: 3.42MB Database Index Size: 1.43MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.02MB + Index: 0.13MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 2.48MB + Index: 0.06MB + Engine InnoDB wp_postmeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_posts: Data: 0.06MB + Index: 0.06MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB ### Post Type Counts ### attachment: 2 nav_menu_item: 5 page: 9 post: 2 product: 1 revision: 3 shop_coupon: 1 shop_order: 3 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (2) ### WooCommerce Smart Coupons: by StoreApps – 4.33.1 WooCommerce: by Automattic – 5.9.0 ### Inactive Plugins (0) ### ### Must Use Plugins (1) ### WordPress automation by Installatron: by – ### Settings ### API Enabled: ✔ Force SSL: – Currency: SAR (ر.س) Currency Position: right_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: #6 - /shop/ Cart: #7 - /cart/ Checkout: #8 - /checkout/ My account: #9 - /my-account/ Terms and conditions: ❌ Page not set ### Theme ### Name: Twenty Twenty-One 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: 6 Oldest: 2021-12-13 10:37:00 +0000 Newest: 2021-12-13 13:02:06 +0000 Pending: 1 Oldest: 2021-12-13 13:11:11 +0000 Newest: 2021-12-13 13:11:11 +0000 ### Status report information ### Generated at: 2021-12-13 13:10:31 +00:00 `
AashikP commented 2 years ago

Hello @HBaz92,

I tested this on my local site, but could not replicate the same behavior.

This is the request I sent:

{
    "payment_method": "bacs",
    "payment_method_title": "Direct Bank Transfer",
    "set_paid": true,
    "discount_total": "5.50",
    "discount_tax": "0.00",
    "shipping_total": "10.00",
    "shipping_tax": "0.00",
    "cart_tax": "0.00",
    "total": "59.50",
    "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
    },
    "shipping": {
        "first_name": "John",
        "last_name": "Doe",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
    },
    "line_items": [
        {
            "product_id": 2286,
            "quantity": 2,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "55.00",
            "subtotal_tax": "0.00",
            "total": "49.50",
            "total_tax": "0.00",
            "taxes": [],
            "sku": "woo-belt",
            "price": 49.5
        }
    ],
    "shipping_lines": [
        {
            "method_id": "flat_rate",
            "method_title": "Flat Rate",
            "total": "10.00"
        }
    ],
    "coupon_lines": [
        {
            "code": "test"
        }
    ]
}

Here's my coupon setup:

https://d.pr/i/1W95qy+

The response I received:

{
    "id": 3862,
    "parent_id": 0,
    "status": "processing",
    "currency": "USD",
    "version": "6.0.0",
    "prices_include_tax": false,
    "date_created": "2021-12-18T11:36:39",
    "date_modified": "2021-12-18T11:36:39",
    "discount_total": "5.50",
    "discount_tax": "0.00",
    "shipping_total": "10.00",
    "shipping_tax": "0.00",
    "cart_tax": "0.00",
    "total": "59.50",
    "total_tax": "0.00",
    "customer_id": 0,
    "order_key": "wc_order_REDACTED",
    "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
    },
    "shipping": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "phone": ""
    },
    "payment_method": "bacs",
    "payment_method_title": "Direct Bank Transfer",
    "transaction_id": "",
    "customer_ip_address": "",
    "customer_user_agent": "",
    "created_via": "rest-api",
    "customer_note": "",
    "date_completed": null,
    "date_paid": "2021-12-18T11:36:39",
    "cart_hash": "",
    "number": "3862",
    "meta_data": [{
        "id": 51347,
        "key": "_fue_recorded",
        "value": "1"
    }, {
        "id": 51348,
        "key": "_order_status_emails_queued",
        "value": "1"
    }, {
        "id": 51349,
        "key": "_new_order_email_sent",
        "value": "true"
    }],
    "line_items": [{
        "id": 100428,
        "name": "Belt",
        "product_id": 2269,
        "variation_id": 0,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "55.00",
        "subtotal_tax": "0.00",
        "total": "49.50",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [],
        "sku": "woo-belt",
        "price": 49.5,
        "parent_name": null
    }],
    "tax_lines": [],
    "shipping_lines": [{
        "id": 100429,
        "method_title": "Flat Rate",
        "method_id": "flat_rate",
        "instance_id": "",
        "total": "10.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": []
    }],
    "fee_lines": [],
    "coupon_lines": [{
        "id": 100430,
        "code": "test",
        "discount": "5.5",
        "discount_tax": "0",
        "meta_data": []
    }],
    "refunds": [],
    "date_created_gmt": "2021-12-18T11:36:39",
    "date_modified_gmt": "2021-12-18T11:36:39",
    "date_completed_gmt": null,
    "date_paid_gmt": "2021-12-18T11:36:39",
    "currency_symbol": "$",
    "_links": {
        "self": [{
            "href": "https:\/\/REDACTED\/wp-json\/wc\/v3\/orders\/3862"
        }],
        "collection": [{
            "href": "https:\/\/REDACTED\/wp-json\/wc\/v3\/orders"
        }]
    }
}

Screenshot of the order:

https://d.pr/i/Inuung+


If you're only seeing this behavior with Smart Coupons enabled / for help with configuring the coupons using that extension, or to report bugs about the same, please reach out to the developers for the plugin directly at https://woocommerce.com/my-account/create-a-ticket/?form=ticket and select Smart Coupons under I need help with (you can view the plugin in the list once you log-in to the account where you purchased the extension).

I'm closing this ticket for now as it seems the issue is not related to core WooCommerce coupons.

If you can still replicate the issue under conflict testing conditions with just WooCommerce as the active plugin and Storefront Theme as the active theme, can we please request you to get back to us with the exact steps to replicate under conflict testing conditions?

dieptang commented 10 months ago

Yes, Seems "Maximum Discount" is coming from Smart Coupons. But WC also should support it also because I see here a lot of coupons system are using it.

For example:

Coupon settings

General:

Discount type: Percentage discount Coupon amount: 10% Maximum Discount: 20$

When the user add to cart and total is 450$, then currently when apply the coupon, the discount amout is $45 (10%). It should $20 as I set maximum Discount.