Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add support for Order Source Attribution #11506

Closed
wants to merge 6 commits into from

Conversation

JPry
Copy link

@JPry JPry commented Oct 30, 2023

This PR is an effort to bring Order Source Attribution support to the Cart and checkout blocks.
For reference: pe2C5g-JD-p2

Order Source Attribution is a new core feature that will show merchants additional information about the order ( Order Information ):

image

The core implementation of the Order Source Attribution will be delivered using the following PR woocommerce/woocommerce#39701

Why

Since Blocks-based checkout is now the default we need to provide compatibility with the Order Source Attribution feature.

Testing Instructions

To fully test one needs the WooCommerce core woocommerce/woocommerce#39701. Please use the testing instructions there with the combination of Cart & Checkout blocks instead of the classic flow.

After an order is made:

  • The Orders page will have a new column labeled "Origin" that will display the source of the order.
  • The Order Edit page will have 2 new meta boxes: Order information and Customer History. These boxes will have more details about the origin of the order, and the complete history for the customer of the order.
  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively

Screenshots or screencast

Before After

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a [type] label or a [skip-changelog] label.
  • This PR is assigned to a milestone.

Conditional:

  • This PR has a changelog description (if [skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces, and I've updated this doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

Add suggested changelog entry here.

@JPry JPry self-assigned this Oct 30, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-11506.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 576
  • Total errors: 2488

⚠️ ⚠️ This PR introduces new TS errors on 1 files:

assets/js/extensions/order-source-attribution/index.ts

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2023

Size Change: +265 B (0%)

Total Size: 1.58 MB

Filename Size Change
build/wc-blocks-order-source-attribution.js 265 B +265 B (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/3810-frontend.js 18.3 kB
build/4124-frontend.js 23.9 kB
build/8280-frontend.js 8.48 kB
build/active-filters-frontend.js 6.69 kB
build/active-filters-rtl.css 1.68 kB
build/active-filters-wrapper-frontend.js 6.9 kB
build/active-filters-wrapper-rtl.css 1.53 kB
build/active-filters-wrapper.css 1.53 kB
build/active-filters.css 1.68 kB
build/active-filters.js 6.06 kB
build/add-to-cart-form-rtl.css 444 B
build/add-to-cart-form.css 444 B
build/all-products-frontend.js 9.67 kB
build/all-products-rtl.css 4.54 kB
build/all-products.css 4.54 kB
build/all-products.js 39.7 kB
build/all-reviews-rtl.css 1.75 kB
build/all-reviews.css 1.75 kB
build/all-reviews.js 7.8 kB
build/attribute-filter-frontend.js 19.9 kB
build/attribute-filter-rtl.css 4.03 kB
build/attribute-filter-wrapper-frontend.js 21.1 kB
build/attribute-filter-wrapper-rtl.css 3.89 kB
build/attribute-filter-wrapper.css 3.88 kB
build/attribute-filter.css 4.01 kB
build/attribute-filter.js 11.3 kB
build/blocks-checkout.js 33.9 kB
build/blocks-components.js 31.8 kB
build/breadcrumbs-rtl.css 234 B
build/breadcrumbs.css 234 B
build/breadcrumbs.js 2.13 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.4 kB
build/cart-blocks/cart-accepted-payment-methods-style.js 153 B
build/cart-blocks/cart-cross-sells-frontend.js 267 B
build/cart-blocks/cart-cross-sells-products-frontend.js 5.56 kB
build/cart-blocks/cart-cross-sells-products-style.js 153 B
build/cart-blocks/cart-cross-sells-style.js 269 B
build/cart-blocks/cart-express-payment-frontend.js 5.38 kB
build/cart-blocks/cart-express-payment-style.js 155 B
build/cart-blocks/cart-items-frontend.js 281 B
build/cart-blocks/cart-items-style.js 240 B
build/cart-blocks/cart-line-items-frontend.js 9.24 kB
build/cart-blocks/cart-line-items-style.js 153 B
build/cart-blocks/cart-order-summary-frontend.js 20.6 kB
build/cart-blocks/cart-order-summary-style.js 339 B
build/cart-blocks/cart-totals-frontend.js 296 B
build/cart-blocks/cart-totals-style.js 253 B
build/cart-blocks/empty-cart-frontend.js 376 B
build/cart-blocks/empty-cart-style.js 375 B
build/cart-blocks/filled-cart-frontend.js 614 B
build/cart-blocks/filled-cart-style.js 332 B
build/cart-blocks/order-summary-coupon-form-frontend.js 21 kB
build/cart-blocks/order-summary-coupon-form-style.js 155 B
build/cart-blocks/order-summary-discount-frontend.js 21 kB
build/cart-blocks/order-summary-discount-style.js 155 B
build/cart-blocks/order-summary-fee-frontend.js 288 B
build/cart-blocks/order-summary-fee-style.js 153 B
build/cart-blocks/order-summary-heading-frontend.js 347 B
build/cart-blocks/order-summary-heading-style.js 351 B
build/cart-blocks/order-summary-shipping-frontend.js 20.6 kB
build/cart-blocks/order-summary-shipping-style.js 154 B
build/cart-blocks/order-summary-subtotal-frontend.js 291 B
build/cart-blocks/order-summary-subtotal-style.js 154 B
build/cart-blocks/order-summary-taxes-frontend.js 456 B
build/cart-blocks/order-summary-taxes-style.js 202 B
build/cart-blocks/proceed-to-checkout-frontend.js 7.64 kB
build/cart-blocks/proceed-to-checkout-style.js 1.09 kB
build/cart-frontend.js 29 kB
build/cart-rtl.css 9.27 kB
build/cart.css 9.25 kB
build/cart.js 39.7 kB
build/catalog-sorting-rtl.css 259 B
build/catalog-sorting.css 259 B
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/actions-frontend.js 8.15 kB
build/checkout-blocks/actions-style.js 1.02 kB
build/checkout-blocks/billing-address-frontend.js 9.85 kB
build/checkout-blocks/billing-address-style.js 639 B
build/checkout-blocks/contact-information-frontend.js 1.67 kB
build/checkout-blocks/contact-information-style.js 653 B
build/checkout-blocks/express-payment-frontend.js 5.82 kB
build/checkout-blocks/fields-frontend.js 375 B
build/checkout-blocks/fields-style.js 342 B
build/checkout-blocks/order-note-frontend.js 681 B
build/checkout-blocks/order-summary-cart-items-frontend.js 6.49 kB
build/checkout-blocks/order-summary-cart-items-style.js 153 B
build/checkout-blocks/order-summary-coupon-form-frontend.js 21 kB
build/checkout-blocks/order-summary-coupon-form-style.js 155 B
build/checkout-blocks/order-summary-discount-frontend.js 21.1 kB
build/checkout-blocks/order-summary-discount-style.js 154 B
build/checkout-blocks/order-summary-fee-frontend.js 291 B
build/checkout-blocks/order-summary-fee-style.js 155 B
build/checkout-blocks/order-summary-frontend.js 20.6 kB
build/checkout-blocks/order-summary-shipping-frontend.js 20.6 kB
build/checkout-blocks/order-summary-shipping-style.js 154 B
build/checkout-blocks/order-summary-style.js 341 B
build/checkout-blocks/order-summary-subtotal-frontend.js 289 B
build/checkout-blocks/order-summary-subtotal-style.js 155 B
build/checkout-blocks/order-summary-taxes-frontend.js 455 B
build/checkout-blocks/order-summary-taxes-style.js 201 B
build/checkout-blocks/payment-frontend.js 14.5 kB
build/checkout-blocks/payment-style.js 500 B
build/checkout-blocks/pickup-options-frontend.js 11.2 kB
build/checkout-blocks/pickup-options-style.js 481 B
build/checkout-blocks/shipping-address-frontend.js 9.81 kB
build/checkout-blocks/shipping-address-style.js 517 B
build/checkout-blocks/shipping-method-frontend.js 1.97 kB
build/checkout-blocks/shipping-method-style.js 1.44 kB
build/checkout-blocks/shipping-methods-frontend.js 19 kB
build/checkout-blocks/shipping-methods-style.js 456 B
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/terms-style.js 1.03 kB
build/checkout-blocks/totals-frontend.js 338 B
build/checkout-blocks/totals-style.js 301 B
build/checkout-frontend.js 30.6 kB
build/checkout-rtl.css 8.37 kB
build/checkout.css 8.35 kB
build/checkout.js 42.6 kB
build/classic-shortcode-rtl.css 242 B
build/classic-shortcode.css 241 B
build/classic-shortcode.js 4.66 kB
build/collection-filters.js 2.69 kB
build/collection-price-filter-frontend.js 591 B
build/collection-price-filter-rtl.css 1.07 kB
build/collection-price-filter.css 1.07 kB
build/collection-price-filter.js 2.15 kB
build/collection-stock-filter-frontend.js 396 B
build/collection-stock-filter-rtl.css 4.03 kB
build/collection-stock-filter.css 4.03 kB
build/collection-stock-filter.js 4.18 kB
build/customer-account-rtl.css 410 B
build/customer-account.css 409 B
build/customer-account.js 3.19 kB
build/featured-category-rtl.css 974 B
build/featured-category.css 973 B
build/featured-category.js 13.6 kB
build/featured-product-rtl.css 1.02 kB
build/featured-product.css 1.02 kB
build/featured-product.js 13.8 kB
build/filter-wrapper-frontend.js 14.6 kB
build/filter-wrapper-rtl.css 378 B
build/filter-wrapper.css 378 B
build/filter-wrapper.js 2.38 kB
build/handpicked-products.js 7.33 kB
build/legacy-template-rtl.css 240 B
build/legacy-template.css 240 B
build/legacy-template.js 7.85 kB
build/mini-cart-component-frontend.js 30.8 kB
build/mini-cart-contents-block/cart-button-frontend.js 1.86 kB
build/mini-cart-contents-block/cart-button-style.js 1.23 kB
build/mini-cart-contents-block/checkout-button-frontend.js 1.95 kB
build/mini-cart-contents-block/checkout-button-style.js 1.44 kB
build/mini-cart-contents-block/empty-cart-frontend.js 383 B
build/mini-cart-contents-block/empty-cart-style.js 387 B
build/mini-cart-contents-block/filled-cart-frontend.js 284 B
build/mini-cart-contents-block/filled-cart-style.js 287 B
build/mini-cart-contents-block/footer-frontend.js 3.87 kB
build/mini-cart-contents-block/footer-style.js 1.96 kB
build/mini-cart-contents-block/items-frontend.js 246 B
build/mini-cart-contents-block/items-style.js 250 B
build/mini-cart-contents-block/products-table-frontend.js 8.59 kB
build/mini-cart-contents-block/shopping-button-frontend.js 501 B
build/mini-cart-contents-block/shopping-button-style.js 361 B
build/mini-cart-contents-block/title-frontend.js 2.04 kB
build/mini-cart-contents-block/title-items-counter-frontend.js 1.74 kB
build/mini-cart-contents-block/title-items-counter-style.js 1.2 kB
build/mini-cart-contents-block/title-label-frontend.js 1.68 kB
build/mini-cart-contents-block/title-label-style.js 1.14 kB
build/mini-cart-contents-block/title-style.js 1.38 kB
build/mini-cart-contents-rtl.css 3.23 kB
build/mini-cart-contents.css 3.22 kB
build/mini-cart-contents.js 16 kB
build/mini-cart-frontend.js 2.35 kB
build/mini-cart-rtl.css 2.44 kB
build/mini-cart.css 2.44 kB
build/mini-cart.js 6.09 kB
build/order-confirmation-additional-information-rtl.css 367 B
build/order-confirmation-additional-information.css 367 B
build/order-confirmation-additional-information.js 1.58 kB
build/order-confirmation-billing-address-rtl.css 398 B
build/order-confirmation-billing-address.css 397 B
build/order-confirmation-billing-address.js 1.56 kB
build/order-confirmation-billing-wrapper.js 1.51 kB
build/order-confirmation-downloads-rtl.css 477 B
build/order-confirmation-downloads-wrapper.js 1.58 kB
build/order-confirmation-downloads.css 478 B
build/order-confirmation-downloads.js 1.91 kB
build/order-confirmation-shipping-address-rtl.css 399 B
build/order-confirmation-shipping-address.css 398 B
build/order-confirmation-shipping-address.js 1.56 kB
build/order-confirmation-shipping-wrapper.js 1.52 kB
build/order-confirmation-status-rtl.css 280 B
build/order-confirmation-status.css 280 B
build/order-confirmation-status.js 1.55 kB
build/order-confirmation-summary-rtl.css 460 B
build/order-confirmation-summary.css 460 B
build/order-confirmation-summary.js 1.76 kB
build/order-confirmation-totals-rtl.css 594 B
build/order-confirmation-totals-wrapper.js 1.8 kB
build/order-confirmation-totals.css 593 B
build/order-confirmation-totals.js 2.18 kB
build/packages-style-rtl.css 5.19 kB
build/packages-style.css 5.19 kB
build/page-content-wrapper.js 1.96 kB
build/price-filter-frontend.js 7.94 kB
build/price-filter-rtl.css 2.68 kB
build/price-filter-wrapper-frontend.js 8.11 kB
build/price-filter-wrapper-rtl.css 2.53 kB
build/price-filter-wrapper.css 2.53 kB
build/price-filter.css 2.67 kB
build/price-filter.js 7.53 kB
build/price-format.js 913 B
build/product-add-to-cart-frontend.js 8.12 kB
build/product-add-to-cart-rtl.css 1.37 kB
build/product-add-to-cart.css 1.38 kB
build/product-add-to-cart.js 8.36 kB
build/product-average-rating-frontend.js 1.88 kB
build/product-average-rating.js 1.4 kB
build/product-best-sellers.js 7.07 kB
build/product-button-frontend.js 4.94 kB
build/product-button-interactivity-frontend.js 8.47 kB
build/product-button-rtl.css 1.14 kB
build/product-button.css 1.14 kB
build/product-button.js 4.66 kB
build/product-categories-rtl.css 654 B
build/product-categories.css 654 B
build/product-categories.js 2.6 kB
build/product-category.js 8 kB
build/product-collection.js 13.9 kB
build/product-details-rtl.css 397 B
build/product-details.css 394 B
build/product-gallery-frontend.js 858 B
build/product-gallery-large-image-frontend.js 648 B
build/product-gallery-large-image-next-previous.js 4.25 kB
build/product-gallery-large-image.js 2.47 kB
build/product-gallery-pager.js 3.48 kB
build/product-gallery-rtl.css 1.26 kB
build/product-gallery-thumbnails.js 3.9 kB
build/product-gallery.css 1.26 kB
build/product-gallery.js 9.56 kB
build/product-image-frontend.js 2.89 kB
build/product-image-gallery-rtl.css 307 B
build/product-image-gallery.css 306 B
build/product-image-rtl.css 996 B
build/product-image.css 994 B
build/product-image.js 2.57 kB
build/product-new.js 7.33 kB
build/product-on-sale.js 7.32 kB
build/product-price-frontend.js 2.82 kB
build/product-price-rtl.css 644 B
build/product-price.css 643 B
build/product-price.js 2.34 kB
build/product-query-rtl.css 350 B
build/product-query.css 349 B
build/product-query.js 11.7 kB
build/product-rating-counter-frontend.js 2.19 kB
build/product-rating-counter.js 1.7 kB
build/product-rating-frontend.js 2.53 kB
build/product-rating-rtl.css 247 B
build/product-rating-stars-frontend.js 2.43 kB
build/product-rating-stars-rtl.css 899 B
build/product-rating-stars.css 900 B
build/product-rating-stars.js 1.95 kB
build/product-rating.css 246 B
build/product-rating.js 2.04 kB
build/product-results-count-rtl.css 230 B
build/product-results-count.css 230 B
build/product-results-count.js 1.66 kB
build/product-reviews-rtl.css 458 B
build/product-reviews.css 458 B
build/product-sale-badge-frontend.js 2.01 kB
build/product-sale-badge-rtl.css 437 B
build/product-sale-badge.css 437 B
build/product-sale-badge.js 1.52 kB
build/product-search-rtl.css 419 B
build/product-search.css 417 B
build/product-search.js 2.62 kB
build/product-sku-frontend.js 2.02 kB
build/product-sku-rtl.css 240 B
build/product-sku.css 239 B
build/product-sku.js 1.53 kB
build/product-stock-indicator-frontend.js 2.2 kB
build/product-stock-indicator-rtl.css 232 B
build/product-stock-indicator.css 232 B
build/product-stock-indicator.js 1.71 kB
build/product-summary-frontend.js 2.36 kB
build/product-summary-rtl.css 549 B
build/product-summary.css 549 B
build/product-summary.js 1.88 kB
build/product-tag.js 7.52 kB
build/product-template-rtl.css 536 B
build/product-template.css 535 B
build/product-template.js 2.81 kB
build/product-title-frontend.js 2.31 kB
build/product-title-rtl.css 693 B
build/product-title.css 694 B
build/product-title.js 2.05 kB
build/product-top-rated.js 7.6 kB
build/products-by-attribute.js 8.05 kB
build/rating-filter-frontend.js 18.8 kB
build/rating-filter-rtl.css 4.09 kB
build/rating-filter-wrapper-frontend.js 19.7 kB
build/rating-filter-wrapper-rtl.css 3.95 kB
build/rating-filter-wrapper.css 3.95 kB
build/rating-filter.css 4.08 kB
build/rating-filter.js 5.8 kB
build/reviews-by-category-rtl.css 1.75 kB
build/reviews-by-category.css 1.75 kB
build/reviews-by-category.js 11.4 kB
build/reviews-by-product-rtl.css 1.75 kB
build/reviews-by-product.css 1.75 kB
build/reviews-by-product.js 12.7 kB
build/reviews-frontend.js 6.44 kB
build/single-product-rtl.css 378 B
build/single-product.css 378 B
build/single-product.js 11.1 kB
build/stock-filter-frontend.js 19 kB
build/stock-filter-rtl.css 3.88 kB
build/stock-filter-wrapper-frontend.js 20 kB
build/stock-filter-wrapper-rtl.css 3.75 kB
build/stock-filter-wrapper.css 3.74 kB
build/stock-filter.css 3.87 kB
build/stock-filter.js 6.44 kB
build/store-notices.js 1.68 kB
build/wc-blocks-classic-template-revert-button-style-rtl.css 240 B
build/wc-blocks-classic-template-revert-button-style.css 239 B
build/wc-blocks-classic-template-revert-button.js 1.19 kB
build/wc-blocks-data.js 19.7 kB
build/wc-blocks-editor-style-rtl.css 7.06 kB
build/wc-blocks-editor-style.css 7.06 kB
build/wc-blocks-google-analytics.js 1.13 kB
build/wc-blocks-jetpack-woocommerce-analytics.js 750 B
build/wc-blocks-middleware.js 735 B
build/wc-blocks-registry.js 2.75 kB
build/wc-blocks-rtl.css 2.48 kB
build/wc-blocks-shared-context.js 860 B
build/wc-blocks-shared-hocs.js 1.41 kB
build/wc-blocks-vendors.js 61.7 kB
build/wc-blocks.css 2.48 kB
build/wc-blocks.js 2.63 kB
build/wc-interactivity-dropdown.js 453 B
build/wc-interactivity.js 10.7 kB
build/wc-payment-method-bacs.js 405 B
build/wc-payment-method-cheque.js 402 B
build/wc-payment-method-cod.js 508 B
build/wc-payment-method-paypal.js 439 B
build/wc-settings.js 2.42 kB
build/wc-shipping-method-pickup-location.js 29.4 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Nov 2, 2023

Save the data to the order here.

Save the data to the order here.


// todo: Save the data to the order here.
},
]
);
} catch ( Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement
// Do nothing.
}
}
/**
* Get the schema callback.
*

🚀 This comment was generated by the automations bot based on a todo comment in f71ba32 in #11506. cc @JPry

@JPry JPry added the type: enhancement The issue is a request for an enhancement. label Nov 3, 2023
@JPry JPry force-pushed the feature/order_source_attribution branch from 8d69dc5 to a8cb8ea Compare November 3, 2023 14:32
Copy link
Contributor

github-actions bot commented Nov 7, 2023

Remove this try/catch once the PR is merged.

Remove this try/catch once the PR is merged.


* @todo Remove this try/catch once the PR is merged.
*/
}
// Load assets in admin and on the frontend.
if ( ! $is_rest ) {
$this->add_build_notice();

🚀 This comment was generated by the automations bot based on a todo comment in 3d14f8c in #11506. cc @JPry

@JPry JPry force-pushed the feature/order_source_attribution branch from 3d14f8c to 8d876ee Compare November 7, 2023 19:49
Copy link
Contributor

This PR has been marked as stale because it has not seen any activity within the past 7 days. Our team uses this tool to help surface pull requests that have slipped through review.

If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label.

@github-actions github-actions bot added the status: stale Stale issues and PRs have had no updates for 60 days. label Nov 15, 2023
@budzanowski budzanowski force-pushed the feature/order_source_attribution branch 2 times, most recently from 1bf5be1 to a880396 Compare November 15, 2023 10:56
@mikejolley
Copy link
Member

It would be very useful to add the scope of the project and more context to the PR description to aid in review, including:

  • What this PR is integrating with and why
  • How to install/setup/testing steps
  • If this relies on a 3rd party/external extension to function, and if so, why the integration code is needed within the blocks codebase and not hosted within the source plugin.

@@ -134,6 +139,18 @@ function() {
$this->container->get( TasksController::class )->init();
$this->container->get( JetpackWooCommerceAnalytics::class )->init();

try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is temporary but wouldn't it be better to gate this based on class existence either here or within the init method?

return true;
};

$sanitize_callback = function( $value ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is unlikely to change you can just pass sanitize_text_field as the sanitize_callback instead of using an inline function.

@mikejolley
Copy link
Member

I believe that rather than introducing this feature via two repositories (blocks and core) this integration should be made directly into core, in the same way this feature supports WC.Com, via this integration:

https://github.com/woocommerce/woocommerce/pull/39701/files#diff-8216eb2b2a6dfcc76b73c9a6f0b329daf2e1684eb12d72c3918228fb6e62cd07

The reasons being:

  • Blocks will be merged into the core codebase soon
  • Blocks are installed/provided via a package in core, so any integration code can work with the core provided version independent of this feature plugin
  • Depending on when this PR is merged and what version that lands in, there is potential for a period where blocks would not be supported by the new feature

I don't see anything in this PR that specifically requires it to be bundled with blocks plugin. Everything seems to be using extensibility interfaces that are available to 3rd parties. it does currently make use of the build process in blocks but this is not required.

JavaScript

  • bin/webpack-entries.js - For blocks build process. Can be removed.
  • assets/js/extensions/order-source-attribution/index.ts - Module can be moved to a JS file and loaded via wp_enqueue_script.
  • assets/js/extensions/order-source-attribution/sourcebuster.d.ts - Module can be moved to a JS file in core and be loaded as a dependency.

PHP

  • src/Domain/Bootstrap.php - Move to the core provided DI container.
  • src/Domain/Services/OrderSourceAttribution.php - Main integration class. Move to core in the same way there is a WCCom integration. Everything in there uses extensibility hooks.

For the main JS module which is currently:

/**
 * External dependencies
 */
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
import { dispatch } from '@wordpress/data';

/**
 * Internal dependencies
 */
import { sbjs } from './sourcebuster.d.ts';

dispatch( CHECKOUT_STORE_KEY ).__internalSetExtensionData(
	'order-source-attribution',
	sbjs.get()
);

You can avoid the use of imports/the blocks build process by accessing the window properties. e.g.

const { CHECKOUT_STORE_KEY } = window.wc.wcBlocksData;
const { dispatch } = window.wp.data;

dispatch( CHECKOUT_STORE_KEY ).__internalSetExtensionData(
	'order-source-attribution',
	{}
);

I think thats the correct method but @opr or @senadir can chime in here. I tested in console successfully.

cc @ralucaStan

@opr
Copy link
Contributor

opr commented Nov 15, 2023

I think thats the correct method but @opr or @senadir can chime in here. I tested in console successfully.

Yep, that's it.

We really need to remove the __internal prefix from that. Many use cases where people want to do this without registering a block (which is currently the only way to get the "public" version of setExtensionData).

@github-actions github-actions bot removed the status: stale Stale issues and PRs have had no updates for 60 days. label Nov 16, 2023
@senadir
Copy link
Member

senadir commented Nov 16, 2023

Discussion about why this would live here: p1698288117402579-slack-C8X6Q7XQU The reasoning would be that it's easier to integrate here directly than to do it in core.

My reasoning given this is a core feature, it doesn't need any third party code, it should be just part of Checkout Block source code than live externally.

@mikejolley
Copy link
Member

@senadir I saw your reasoning. If blocks were in the monorepo I'd agree, but as the feature is being introduced in core to support both block and legacy checkouts it should be done there and moved after the core merge. This cannot be tested without the core feature branch and the code would be near identical, just in a different repository.

@tomalec tomalec assigned tomalec and unassigned JPry Nov 20, 2023
tomalec added a commit to woocommerce/woocommerce that referenced this pull request Nov 20, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
tomalec added a commit to woocommerce/woocommerce that referenced this pull request Nov 20, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
@tomalec
Copy link
Member

tomalec commented Nov 20, 2023

I started migrating this PR to the monorepo. My WIP is at https://github.com/woocommerce/woocommerce/pull/41592/files

tomalec added a commit to woocommerce/woocommerce that referenced this pull request Nov 21, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
tomalec added a commit to woocommerce/woocommerce that referenced this pull request Nov 21, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
@budzanowski
Copy link
Contributor

Closing in favour of woocommerce/woocommerce#41592

@budzanowski budzanowski deleted the feature/order_source_attribution branch November 22, 2023 10:15
layoutd pushed a commit to woocommerce/woocommerce that referenced this pull request Nov 24, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
layoutd pushed a commit to woocommerce/woocommerce that referenced this pull request Nov 24, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
layoutd pushed a commit to woocommerce/woocommerce that referenced this pull request Nov 27, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
layoutd pushed a commit to woocommerce/woocommerce that referenced this pull request Nov 27, 2023
woocommerce/woocommerce-blocks#11506
Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team: Kirigami & Origami type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants