woocommerce / woocommerce

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

When adding product attribute terms using the REST API (V3) ordering is not kept #28158

Open kevinamorim opened 4 years ago

kevinamorim commented 4 years ago

Prerequisites:

Describe the bug When using the field 'menu_order' for creating product attribute terms using the REST API, the order is not kept, using custom ordering for the product attribute.

Expected behavior The attribute terms for a given attribute should follow the order specified in the 'menu_order' field, if custom ordering is selected for the product attribute.

Actual behavior The attribute terms are presented in a somewhat random order even if 'menu_order' is specified when creating the term via REST API and having the product attribute as 'Custom Ordering'.

Steps to reproduce the bug Steps to reproduce the bug:

  1. Go to WooCommerce > Attributes and create a new attribute default sort order as: "Custom ordering".
  2. Submit some new product attribute terms using the REST API: /wp-json/wc/v3/products/attributes//terms with name and 'menu_order' for the attribute created in step 1.
  3. Go back to WooCommerce > Attributes.
  4. Click on "Configure terms" for the attribute created in step 1.
  5. Check that the order is not correct.

Isolating the problem:

This was tested and replicated on a completely fresh install of WP + WC.

WordPress Environment

` ### WordPress Environment ### WordPress address (URL): http://one.wordpress.test Site address (URL): http://one.wordpress.test WC Version: 4.6.1 REST API Version: ✔ 4.6.1 WC Blocks Version: ✔ 3.4.0 Action Scheduler Version: ✔ 3.1.6 WC Admin Version: ✔ 1.6.2 Log Directory Writable: ✔ WP Version: 5.5.3 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: ✔ WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: nginx/1.19.4 PHP Version: 7.2.34-8+ubuntu18.04.1+deb.sury.org+1 PHP Post Max Size: 1 GB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 7.58.0 OpenSSL/1.1.1g SUHOSIN Installed: – MySQL Version: 5.5.5-10.4.15-MariaDB-1:10.4.15+maria~bionic Max Upload Size: 1 GB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 4.6.1 WC Database Prefix: wp_ Total Database Size: 3.78MB Database Data Size: 2.32MB Database Index Size: 1.46MB 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.11MB + 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: 1.48MB + Index: 0.03MB + Engine InnoDB wp_postmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_posts: Data: 0.02MB + 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.02MB + 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.05MB + 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.11MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.06MB + 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: 1 page: 6 post: 2 ### Security ### Secure connection (HTTPS): ❌ Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates. Hide errors from visitors: ❌Error messages should not be shown to visitors. ### Active Plugins (1) ### WooCommerce: by Automattic – 4.6.1 ### Inactive Plugins (0) ### ### Settings ### API Enabled: – Force SSL: – Currency: GBP (£) Currency Position: left 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 Version: 1.5 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 ### Canceled: 1 Oldest: 2020-10-31 23:45:22 +0000 Newest: 2020-10-31 23:45:22 +0000 Complete: 1 Oldest: 2020-10-31 23:45:22 +0000 Newest: 2020-10-31 23:45:22 +0000 `
rrennick commented 3 years ago

@kevinamorim Thanks for reporting the issue.

I'm adding the developer feedback label. I have confirmed that the menu_order field on attribute terms in the Rest API are not reflected elsewhere in WooCommerce (either dashboard or single product view).

kevinamorim commented 3 years ago

@rrennick Thanks! I've made a pull request that fixes this.

rrennick commented 3 years ago

@rrennick Thanks! I've made a pull request that fixes this.

@kevinamorim I apologize. I should have checked the issue when I read the notification. Can you provide a link to your PR?

kevinamorim commented 3 years ago

@rrennick No problem, sure. Here you go: https://github.com/woocommerce/woocommerce/pull/28159

rrennick commented 3 years ago

@kevinamorim Thanks.

The Closes #{issue-number} in the PR description automatically connects the PR to the issue. The second feature of the line is that Github will automatically close the issue when the PR is merged. So, if there is an issue related to future PRs, please complete that line in the PR template.

gerdus commented 3 months ago

Ran into this issue today. Attributes are synced from the client's ERP that has the correct ordering and manually sorting it in wordpress admin is a huge pain. Is there a workaround?