-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Make OSA fields extendable, simplify naming #41690
Make OSA fields extendable, simplify naming #41690
Conversation
Hi @message-dimke, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Hi @layoutd, @woocommerce/ventures Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: c53cc88
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
8cfa6a2
to
88e7e3c
Compare
cb733d7
to
19bb2a3
Compare
Remove the need for translating it back and forth.
using `wc_order_attribution_tracking_fields`. Propagate the fileds config to the client-side as well. Disambiguate `fields` in variables and functions.
88e7e3c
to
9fb2291
Compare
Hey, @tomalec ! I am curious what should the value be, I am getting Block: Classic: |
The value of the then when processed in browser's runtime it should be resolved to the value of "sbjs.get.the.accessor.you.have.given". Which in the example should be the value of
So, the results you see are correct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you, @tomalec !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These looks like they're working well! I tested with block and shortcode checkouts, and with several types of source types. The template version needs to be updated to match the current trunk version.
I was going to suggest we add metadata migration in another PR to allow sites that already have OA data work with these changes, but I realized that the OA feature already maps the type and url to source_type
and referrer
meta keys:
woocommerce/plugins/woocommerce/src/Internal/Traits/OrderAttributionMeta.php
Lines 154 to 170 in 2749ceb
/** | |
* Get the field name with the meta prefix. | |
* | |
* @param string $field The field name. | |
* | |
* @return string The prefixed field name. | |
*/ | |
private function get_meta_prefixed_field( string $field ): string { | |
// Map some of the fields to the correct meta name. | |
if ( 'type' === $field ) { | |
$field = 'source_type'; | |
} elseif ( 'url' === $field ) { | |
$field = 'referrer'; | |
} | |
return "_{$this->get_prefixed_field( $field )}"; | |
} |
So that's one fewer thing to do!
plugins/woocommerce/templates/order/attribution-data-fields.php
Outdated
Show resolved
Hide resolved
I'm marking it as high-impact as:
|
Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>
Hi there! The E2E tests are failing here, I triggered a re-run just in case the failure was introduced by these changes. Will keep an eye on this. Update: They passed 👍 |
…-fields Resolve conflicts, redo some work in `plugins/woocommerce/client/legacy/js/frontend/order-attribution.js`,.
2fdfb6d
to
e887ea3
Compare
This PR is mostly with developer-facing tweaks. Also, may require some follow-up action to double-check if tracking- and meta- data migrate well. As #43012 got full approval and analysis, while #41856 (its version based on this PR) didn't, I merged #43012, to deliver the customer-facing fix ASAP. The above means, Maybe another pair of eyes could check if those changes didn't break anything? |
- Use `referrer` & `source_type` field names consistently Remove the need to translate it back and forth. - Make fields actually extendable using `wc_order_attribution_tracking_fields`. Propagate the field configuration to the client side as well. Disambiguate fields in variables and functions. Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>
This is an add-on to #39701
Submission Review Guidelines:
Changes proposed in this Pull Request:
Use
referrer
&source_type
field names consistentlyRemove the need to translate it back and forth.
Make fields actually extendable
using
wc_order_attribution_tracking_fields
.Propagate the field configuration to the client side as well.
Disambiguate
fields
in variables and functions.How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
<input type="hidden" name="wc_order_attribution_new_field" value="" />
is in the source code.document.querySelector('input[name="wc_order_attribution_new_field"]').value === sbjs.get.first_add.fd
/checkout
ajax request payload contains the new fieldfield
-related names are understandableChangelog entry
Significance
Type
Message
Comment