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

Grouped products are missing a price update #27941

Closed
Jensonbruins opened this issue Oct 13, 2020 · 6 comments · Fixed by #42808
Closed

Grouped products are missing a price update #27941

Jensonbruins opened this issue Oct 13, 2020 · 6 comments · Fixed by #42808
Labels
focus: shop Issues related to shop page. plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. team: Kirigami & Origami

Comments

@Jensonbruins
Copy link

Problem description:

  • When a grouped product is created with multiple simple products in its group, it contains a range from lowest product price to highest product price.
  • This lowest (simple) product price is also set in the <script type="application/ld+json"> in the source on the page of the grouped product.
  • The data in <script type="application/ld+json"> is often crawled/used for marketing purposes.
  • Whenever the simple product with the lowest price gets updated, the new price will not be set in the <script type="application/ld+json">.
  • When removing the simple product from the group and re-attach it afterwards the price in <script type="application/ld+json"> does get updated.

Because we use this price for marketing purposes it now shows an incorrect price.

Environment details:
Wordpress: v5.5.1
Plugins: Woocommerce v4.5.2
Theme: Twenty Twenty v1.5

Reproduce:
1. Create an environment with solely the details listed above.
2. Create at least 2 simple products one with a price of 100 and one with a price of 200
3. Create a grouped product and link the simple products
4. Check the section <script type="application/ld+json"> the price should say 100 now
5. Now update the price of the 100 priced product to 50
6. Check the section <script type="application/ld+json"> this still says the products lowest range is 100 when this should be 50
Question:
Is it possible to make a change to the WooCommerce plugin to update this section <script type="application/ld+json"> of a grouped product to have the correct price.

@jacoswan
Copy link
Contributor

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

  • I have 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
Price field of a grouped product returned via REST API / JSON does not update when the price of the cheapest product is, unless the cheapest product is removed, grouped product is updated, and the cheapest product is readded to the grouped product.

Expected behavior
When the price of the cheapest product in the group is updated, the group's price should be updated too.

Actual behavior
The grouped product's price is unchanged when the cheapest product is updated.

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 a grouped product with 1 (min required) or more products.
  2. View source on grouped product for JSON output, or call grouped product via API
  3. Find "price": value, note the value equals the price of the cheapest product
  4. Update the price of the cheapest product, repeat steps 2 & 3,_ note no change_.
  5. Remove that product from the group and update, still no change.
  6. Add back that product (or another), and now the grouped product's price updates.

Screenshots
n/a

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

  • 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.

WordPress Environment
We use the WooCommerce System Status Report to help us evaluate the issue.
Without this report we won't be able to fully evaluate this issue.

``` ` ### WordPress Environment ###

WordPress address (URL): https://woo.tst
Site address (URL): https://woo.tst
WC Version: 4.5.2
REST API Version: ✔ 4.5.2
WC Blocks Version: ✔ 3.1.0
Action Scheduler Version: ✔ 3.1.6
WC Admin Version: ✔ 1.5.0
Log Directory Writable: ✔
WP Version: 5.5.1
WP Multisite: –
WP Memory Limit: 999 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –

Server Environment

Server Info: Apache/2.4.41 (Unix) OpenSSL/1.1.1f PHP/7.4.1
PHP Version: 7.4.1
PHP Post Max Size: 64 MB
PHP Time Limit: 300
PHP Max Input Vars: 4000
cURL Version: 7.67.0
OpenSSL/1.1.1f

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

Database

WC Database Version: 4.5.2
WC Database Prefix: wp_
Total Database Size: 9.50MB
Database Data Size: 6.10MB
Database Index Size: 3.40MB
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.08MB + Index: 0.09MB + 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.11MB + 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.09MB + Index: 0.06MB + Engine InnoDB
wp_automatewoo_abandoned_carts: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_automatewoo_customers: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_automatewoo_customer_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_events: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_automatewoo_guests: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_automatewoo_guest_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_automatewoo_log_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_queue: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_automatewoo_queue_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_comments: Data: 0.05MB + Index: 0.09MB + Engine InnoDB
wp_followup_coupons: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_coupon_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_followup_customers: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_followup_customer_carts: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_customer_notes: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_customer_orders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_followup_email_excludes: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_followup_email_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_followup_email_orders: Data: 0.05MB + Index: 0.09MB + Engine InnoDB
wp_followup_email_tracking: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_followup_followup_history: Data: 0.06MB + Index: 0.05MB + Engine InnoDB
wp_followup_order_categories: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_order_items: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_followup_subscribers: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_subscribers_to_lists: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_followup_subscriber_lists: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_jckwds: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_options: Data: 2.03MB + Index: 0.11MB + Engine InnoDB
wp_postmeta: Data: 0.41MB + Index: 0.39MB + Engine InnoDB
wp_posts: Data: 0.16MB + 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_wcpv_commissions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcpv_per_product_shipping_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcs_payment_retries: Data: 0.02MB + Index: 0.02MB + 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_bookings_availability: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_bookings_availabilitymeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_booking_relationships: Data: 0.02MB + Index: 0.03MB + 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_deposits_payment_plans: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_deposits_payment_plans_schedule: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_gpf_render_cache: Data: 0.02MB + Index: 0.02MB + 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_points_rewards_user_points: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_points_rewards_user_points_log: Data: 0.02MB + Index: 0.05MB + 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
wp_woocommerce_bundled_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_bundled_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_gpf_google_taxonomy: Data: 1.52MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_shipping_table_rates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_software_activations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_software_licenses: Data: 0.02MB + Index: 0.00MB + Engine InnoDB

Post Type Counts

attachment: 18
aw_workflow: 1
custom_css: 1
customize_changeset: 21
follow_up_email: 2
nav_menu_item: 20
page: 14
post: 3
product: 50
product_variation: 16
revision: 15
shipping_package: 1
shop_coupon: 6
shop_order: 38
shop_subscription: 12
wc_booking: 1
wcpf_item: 7
wcpf_project: 3

Security

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

Active Plugins (1)

WooCommerce: by Automattic – 4.5.2

Inactive Plugins (185)

Must Use Plugins (1)

Health Check Troubleshooting Mode: by – 1.7.1

Settings

API Enabled: –
Force SSL: –
Currency: USD ($)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: booking (booking)
bundle (bundle)
external (external)
grouped (grouped)
simple (simple)
subscription (subscription)
variable (variable)
variable subscription (variable-subscription)

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: #29 - /shop/
Cart: #30 - /cart/
Checkout: #31 - /checkout/
My account: #32 - /my-account/
Terms and conditions: ❌ Page not set

Theme

Name: Storefront
Version: 2.7.0 (update to version 2.8.0 is available)
Author URL: https://woocommerce.com/
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: 273
Oldest: 2020-09-23 12:43:38 +0200
Newest: 2020-09-30 11:49:18 +0200

Pending: 10
Oldest: 2020-10-14 06:50:17 +0200
Newest: 2021-01-03 12:16:33 +0200

`

</details>

@rrennick
Copy link
Contributor

Hi @Jensonbruins,

Thank you for taking the time to report this bug, we really appreciate your help. I can reproduce it on my end using the steps you provided.

We’re going to solve this bug as soon as possible. Stay tuned for updates.

@jacoswan I was not able to reproduce the issue with the REST API. Changes in the lowest products prices were reflected in subsequent calls to the API.

@rrennick rrennick added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Jan 21, 2021
@ObliviousHarmony ObliviousHarmony added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 21, 2022
@marcgmm
Copy link

marcgmm commented Feb 2, 2023

Hello, @rrennick
Do you know if there is any news about this bug?
Thanks a lot.

@rrennick
Copy link
Contributor

rrennick commented Feb 3, 2023

@marcgmm It's on the high priority list.

@rrennick rrennick added focus: shop Issues related to shop page. team: Kirigami & Origami labels Nov 28, 2023
@mt8
Copy link
Contributor

mt8 commented Dec 14, 2023

The problem seems to be that even if you change the price of the included product from 100 to 50 after creating a group product, the amount saved in the group product's meta remains at 100.

> select * from wp_postmeta where post_id = 54;
+---------+---------+--------------------+--------------------------+
| meta_id | post_id | meta_key           | meta_value               |
+---------+---------+--------------------+--------------------------+
...
|     657 |      54 | _price             | 50                       |
|     658 |      54 | _price             | 200                      |
+---------+---------+--------------------+--------------------------+

@mt8
Copy link
Contributor

mt8 commented Dec 14, 2023

I have reviewed this issue and created a pull request to resolve it.

That is, when outputting the price of a group product to structured data, it refers to the latest price of the child product, not the meta stored in the group product.

This is the same approach as product listings and product pages.

Normally, when the price of a child product is changed, the meta of the "parent product" should also be updated, but the child product does not contain the information of the "parent product".
This is because it is difficult to obtain information about the parent product.
(It is not easy to get the serialized child product information of a parent product)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: shop Issues related to shop page. plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. team: Kirigami & Origami
Projects
Status: Done
6 participants