Skip to content

REST API for endpoint /wp-json/wc/v3/products not working as expected #32715

Description

@tobiasgardner

Prerequisites

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

For some reason, the LIST operation gives duplicates when default orderby value is used (i.e. no orderby is provided in the call).

Expected behavior

Should give a (unique) list of products.

r = wcapi.get('products', params={'per_page': no_per_page, 'page': page_no})

Actual behavior

r = wcapi.get('products', params={'per_page': no_per_page, 'page': page_no})

The operation above will let me know that there is 1922 products, but when I loop over the results from each page and consolidate the data in a dict, with the id as key, I get duplicates (in my case approx 40%)...

After a tip, I changed the operation to
r = wcapi.get('products', params={'per_page': no_per_page, 'page': page_no, 'orderby': 'id'})

And then it works as expected, i.e. no duplicates at all.

I am using the python library to communicate with the Woocommerce backend.

Steps to reproduce

Se description above.

WordPress Environment

`

WordPress Environment

WC Version: 6.4.1
REST API Version: ✔ 6.4.1
WC Blocks Version: ✔ 7.2.2
Action Scheduler Version: ✔ 3.4.0
WC Admin Version: ✔ 3.3.2
Log Directory Writable: ✔
WP Version: 5.9.3
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: sv_SE
External object cache: ✔

Server Environment

Server Info: LiteSpeed
PHP Version: 7.4.28
PHP Post Max Size: 50 MB
PHP Time Limit: 90
PHP Max Input Vars: 3000
cURL Version: 7.71.0
OpenSSL/1.1.1d

SUHOSIN Installed: –
MySQL Version: 5.5.5-10.5.15-MariaDB-cll-lve
Max Upload Size: 50 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 6.3.1
WC Database Prefix: wp_
Total databasstorlek: 395.13MB
Datastorlek för databas: 341.72MB
Indexstorlek för databas: 53.41MB
wp_woocommerce_sessions: Data: 207.68MB + Index: 3.88MB + Motor MyISAM
wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_woocommerce_order_items: Data: 0.92MB + Index: 0.59MB + Motor MyISAM
wp_woocommerce_order_itemmeta: Data: 11.52MB + Index: 4.73MB + Motor MyISAM
wp_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_log: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_actionscheduler_actions: Data: 1.60MB + Index: 0.86MB + Motor MyISAM
wp_actionscheduler_claims: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_actionscheduler_groups: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_actionscheduler_logs: Data: 1.22MB + Index: 0.79MB + Motor MyISAM
wp_aws_cache: Data: 4.69MB + Index: 0.00MB + Motor MyISAM
wp_aws_index: Data: 6.84MB + Index: 8.95MB + Motor MyISAM
wp_berocket_termmeta: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_commentmeta: Data: 0.01MB + Index: 0.02MB + Motor MyISAM
wp_comments: Data: 5.07MB + Index: 1.97MB + Motor MyISAM
wp_facetwp_index: Data: 1.61MB + Index: 0.68MB + Motor MyISAM
wp_links: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_litespeed_avatar: Data: 0.01MB + Index: 0.01MB + Motor MyISAM
wp_litespeed_img_optm: Data: 2.35MB + Index: 0.87MB + Motor MyISAM
wp_litespeed_img_optming: Data: 0.04MB + Index: 0.01MB + Motor MyISAM
wp_litespeed_url: Data: 0.35MB + Index: 0.46MB + Motor MyISAM
wp_litespeed_url_file: Data: 0.88MB + Index: 1.08MB + Motor MyISAM
wp_mclean_refs: Data: 0.09MB + Index: 0.04MB + Motor MyISAM
wp_mclean_scan: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_ms_snippets: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_options: Data: 7.43MB + Index: 0.45MB + Motor MyISAM
wp_pmxe_exports: Data: 0.38MB + Index: 0.00MB + Motor MyISAM
wp_pmxe_google_cats: Data: 0.26MB + Index: 0.05MB + Motor MyISAM
wp_pmxe_posts: Data: 0.23MB + Index: 0.11MB + Motor MyISAM
wp_pmxe_templates: Data: 0.14MB + Index: 0.00MB + Motor MyISAM
wp_pmxi_files: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_pmxi_hash: Data: 0.19MB + Index: 0.18MB + Motor MyISAM
wp_pmxi_history: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_pmxi_images: Data: 0.34MB + Index: 0.04MB + Motor MyISAM
wp_pmxi_imports: Data: 0.44MB + Index: 0.00MB + Motor MyISAM
wp_pmxi_posts: Data: 2.08MB + Index: 0.59MB + Motor MyISAM
wp_pmxi_templates: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_postmeta: Data: 46.53MB + Index: 21.77MB + Motor MyISAM
wp_posts: Data: 6.01MB + Index: 1.95MB + Motor MyISAM
wp_seopress_significant_keywords: Data: 0.10MB + Index: 0.13MB + Motor MyISAM
wp_snippets: Data: 0.05MB + Index: 0.00MB + Motor MyISAM
wp_termmeta: Data: 0.23MB + Index: 0.21MB + Motor MyISAM
wp_terms: Data: 0.04MB + Index: 0.07MB + Motor MyISAM
wp_term_relationships: Data: 0.34MB + Index: 0.73MB + Motor MyISAM
wp_term_taxonomy: Data: 0.05MB + Index: 0.04MB + Motor MyISAM
wp_usermeta: Data: 0.20MB + Index: 0.08MB + Motor MyISAM
wp_users: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_wc_admin_notes: Data: 0.01MB + Index: 0.00MB + Motor MyISAM
wp_wc_admin_note_actions: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wc_category_lookup: Data: 0.01MB + Index: 0.02MB + Motor MyISAM
wp_wc_customer_lookup: Data: 0.28MB + Index: 0.24MB + Motor MyISAM
wp_wc_download_log: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wc_order_coupon_lookup: Data: 0.04MB + Index: 0.09MB + Motor MyISAM
wp_wc_order_product_lookup: Data: 0.62MB + Index: 0.63MB + Motor MyISAM
wp_wc_order_stats: Data: 0.41MB + Index: 0.28MB + Motor MyISAM
wp_wc_order_tax_lookup: Data: 0.22MB + Index: 0.28MB + Motor MyISAM
wp_wc_product_attributes_lookup: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wc_product_meta_lookup: Data: 0.14MB + Index: 0.23MB + Motor MyISAM
wp_wc_rate_limits: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wc_reserved_stock: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wc_tax_rate_classes: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_wc_webhooks: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woocommerce_bundled_itemmeta: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
wp_woocommerce_bundled_items: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_woof_query_cache: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
wp_wpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
wp_wpmailsmtp_emails_log: Data: 30.02MB + Index: 0.22MB + Motor InnoDB
wp_wpmailsmtp_tasks_meta: Data: 0.03MB + Index: 0.01MB + Motor MyISAM

Post Type Counts

acf-field: 1
acf-field-group: 1
attachment: 2610
b2bking_custom_field: 9
b2bking_custom_role: 2
b2bking_group: 4
b2bking_rule: 3
br_product_filter: 2
ct_template: 13
custom_css: 1
nav_menu_item: 44
oxy_user_library: 1
page: 40
post: 1
product: 1925
product_variation: 80
revision: 153
seopress_404: 5255
seopress_bot: 7
seopress_schemas: 1
shop_coupon: 284
shop_order: 5051
shop_order_refund: 31
wapf_product: 1
wp_block: 1

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (41)

Advanced Custom Fields PRO: av Delicious Brains – 5.12.2
Advanced Database Cleaner: av Younes JFR. – 3.0.4
Advanced Product Fields for WooCommerce: av StudioWombat – 1.4.7
Advanced Woo Search PRO: av ILLID – 2.52
All-in-One WP Migration: av ServMask – 7.58
Code Snippets: av Code Snippets Pro – 2.14.3
B2BKing: av WebWizards – 3.1.0
Cookies och Content Security Policy: av Jonk @ Follow me Darling – 2.06
Google Tag Manager for Wordpress: av Thomas Geiger – 1.15
Hydrogen Pack: av Clean Plugins – 1.3.10
Facebook for WooCommerce: av Facebook – 2.6.12
Fortnox: av Redlight Media – 4.2.3
Fraktjakts fraktmetod för WooCommerce: av Fraktjakt AB (Sverige) – 2.4.4
OMGF: av Daan from FFW.Press – 5.1.2
LiteSpeed Cache: av LiteSpeed Technologies – 4.6
Loco Translate: av Tim Whitlock – 2.6.1
Media Cleaner (Pro): av Jordy Meow – 6.3.2
OxyNinja: av OxyNinja – 3.4.3
Oxy Toolbox: av Gagan S Goraya
Sridhar Katakam – 1.5.4

Oxygen Gutenberg Integration: av Soflyy – 1.4
Oxygen Elements for WooCommerce: av Soflyy – 1.4
Oxygen: av Soflyy – 3.9
Remember Me Controls: av Scott Reilly – 1.9.1
Svea Checkout för WooCommerce: av The Generation AB – 1.18.1
UpdraftPlus - Backup/Restore: av UpdraftPlus.Com
DavidAnderson – 1.22.11

User Menus: av Code Atlantic – 1.2.9
WooCommerce EU VAT Number: av WooCommerce – 2.3.26
WooCommerce Stripe Gateway: av WooCommerce – 6.3.0
WooCommerce Swish Ecommerce Gateway: av Redlight media – 5.1.5
WooCommerce Sequential Order Numbers: av SkyVerge – 1.9.6
WooCommerce: av Automattic – 6.4.1
WP All Export Pro: av Soflyy – 1.7.5
WP All Import Pro: av Soflyy – 4.7.2
Asset CleanUp: Page Speed Booster: av Gabe Livan – 1.3.8.5
WP Mail SMTP Pro: av WPForms – 3.3.0
SEOPress PRO: av SEOPress – 5.6
SEOPress: av SEOPress – 5.6
WP All Export - ACF Export Add-On Pro: av Soflyy – 1.0.3
WP All Export - WooCommerce Export Add-On Pro: av Soflyy – 1.0.4
WP All Import - ACF Add-On: av Soflyy – 3.3.6
WP All Import - WooCommerce Import Add-On Pro: av Soflyy – 3.3.0

Inactive Plugins (18)

annasta Woocommerce Product Filters: av annasta.net – 1.5.0
Better Search Replace: av Delicious Brains – 1.4
CoBlocks: av GoDaddy – 2.22.10
FacetWP: av FacetWP
LLC – 3.5.10

FacetWP - Submit button: av FacetWP
LLC – 0.1

Flying Analytics by FlyingPress: av FlyingPress – 2.0.1
Flying Images by WP Speed Matters: av Gijo Varghese – 2.4.13
Flying Scripts by WP Speed Matters: av Gijo Varghese – 1.2.2
OxyPowerPack: av The OxyPowerPack team – 2.0.4
Regenerate Thumbnails: av Alex Mills (Viper007Bond) – 3.1.5
Site Kit by Google: av Google – 1.72.0
WooCommerce Blocks: av Automattic – 7.4.2
WOOF - WooCommerce Products Filter: av realmag777 – 1.2.6.4
WP-Optimize - Clean, Compress, Cache: av David Anderson
Ruhani Rabin
Team Updraft – 3.2.3

WPlit Woo Conditions for Oxygen: av WPlit – 1.0.1
WP Mail SMTP: av WPForms – 3.3.0
Yoast SEO: WooCommerce: av Team Yoast – 12.6.1
Yoast SEO Premium: av Team Yoast – 13.2

Dropin Plugins (1)

object-cache.php: object-cache.php

Settings

API Enabled: –
Force SSL: –
Currency: SEK (kr)
Currency Position: right_space
Thousand Separator:
Decimal Separator: ,
Number of Decimals: 2
Taxonomies: Product Types: bundle (bundle)
composite (composite)
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

Butikbas: #131 - /shop/
Varukorg: #133 - /kundvagn/
Kassan: ❌ Sidan innehåller inte kortkoden [woocommerce_checkout] eller blocket woocommerce/checkout.
Mitt konto: #132 - /konto/
Allmänna villkor: #174 - /allmanna-villkor/

Theme

Name: Twenty Twenty
Version: 1.9
Author URL: https://wordpress.org/
Child Theme: ❌ – Om du modifierar WooCommerce på ett modertema som du själv inte byggt
så rekommenderar vi att du använder ett barntema istället. Läs: Hur du skapar ett barntema

WooCommerce Support: ✔

Templates

Overrides: –

Swish Ecommerce

Swish Testmode: -
Merchant Swish number: 1236737167
Swish Technical Supplier: ✔

Action Scheduler

Färdigbehandlad: 2 061
Oldest: 2022-04-15 13:19:04 +0200
Newest: 2022-04-21 12:52:02 +0200

Väntar: 3
Oldest: 2022-04-22 05:34:03 +0200
Newest: 2022-04-26 14:53:03 +0200

Status report information

Generated at: 2022-04-21 12:59:33 +02:00
`

Isolating the problem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThe issue is a confirmed bug.REST/Store API/WebhooksIssues related to WooCommerce REST API.plugin: woocommerceIssues related to the WooCommerce Core plugin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions