Repository navigation
Conversation
…sale dates With WooCommerce as system of record, update_catalog_variation() sent get_sale_price() ?: get_regular_price(), with no check of the sale dates. WooCommerce 10.5.0+ keeps sale_price on the product after a scheduled sale ends, so Square kept charging the sale price. A sale scheduled for the future was also sent to Square before it started. - Add Woo_SOR::get_active_price() and use it for price_money. - Stage the product for sync when core starts or ends a scheduled sale. A variation is staged through its parent. - Unit tests for the price choice. Fixes woocommerce#605 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
With WooCommerce as system of record,
Woo_SOR::update_catalog_variation()sendsget_sale_price() ?: get_regular_price(). The stored sale price is sent whenever it exists, with no check of the sale dates.Since WooCommerce 10.5.0, core no longer clears
sale_pricewhen a scheduled sale ends (wc_apply_sale_state_for_product()only setspriceback). So after every scheduled sale, Square keeps charging the sale price while the store charges the regular price. A re-sync sends the stale sale price again. The same line also sends a sale price to Square before a future-dated sale has started.This PR:
Woo_SOR::get_active_price()and uses it forprice_money. The sale price is sent only whileis_on_sale()is true. Two existing behaviours are kept: a product with only a sale price still sends it, and a product with no price still sends 0.wc_product_start_scheduled_sale,wc_product_end_scheduled_sale, and the dailywc_after_products_starting_sales/wc_after_products_ending_sales), at priority 20, after core has applied the price at 10. A variation is staged through its parent, because saving a variation does not firewoocommerce_update_product.maybe_stage_product_for_sync()already de-duplicates within a request, so a simple product that core has just saved is not staged twice.Not in this PR: a one-time re-push for stores that already hold stale prices in Square. Those need a re-sync after the update. Happy to add an upgrade routine if you want one.
Closes #605.
Steps to test the changes in this Pull Request:
trunk: the Square variation price is 80. On this branch: 100.trunk: Square is 80 at once. On this branch: 100 until the sale starts, then 80.composer test-unit -- --filter Woo_SOR_Active_Price_TestChangelog entry
🤖 Generated with Claude Code