Add additional global attributes and local attributes information when saving product attributes (#36858)
* Add additional global attributes and local attributes information when saving product attributes * Log only local attributes Add attribute name Fix issue with attribute_value and names selectors * Save name and slug for global attributes and global terms
This commit is contained in:
parent
48c8db8ade
commit
41eab0d669
|
@ -34,8 +34,12 @@ function addActionButtonListeners() {
|
|||
addActionButtonListeners();
|
||||
|
||||
addNewTag?.addEventListener( 'click', function () {
|
||||
const name = document.querySelector( '#tag-name' );
|
||||
const slug = document.querySelector( '#tag-slug' );
|
||||
recordEvent( 'product_attributes_add_term', {
|
||||
page: 'tags',
|
||||
name: name?.value,
|
||||
slug: slug?.value,
|
||||
} );
|
||||
setTimeout( () => {
|
||||
addActionButtonListeners();
|
||||
|
|
|
@ -11,9 +11,13 @@ const configureTerms = document.querySelectorAll( '.configure-terms' );
|
|||
addNewAttribute?.addEventListener( 'click', function () {
|
||||
const archiveInput = document.querySelector( '#attribute_public' );
|
||||
const sortOrder = document.querySelector( '#attribute_orderby' );
|
||||
const name = document.querySelector( '#attribute_label' );
|
||||
const slug = document.querySelector( '#attribute_name' );
|
||||
recordEvent( 'product_attributes_add', {
|
||||
enable_archive: archiveInput?.checked ? 'yes' : 'no',
|
||||
default_sort_order: sortOrder?.value,
|
||||
name: name?.value,
|
||||
slug: slug?.value,
|
||||
page: 'attributes',
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -418,10 +418,31 @@ export const initProductScreenTracks = () => {
|
|||
'.woocommerce_attribute'
|
||||
).length;
|
||||
if ( newAttributesCount > attributesCount ) {
|
||||
const local_attributes = [
|
||||
...document.querySelectorAll(
|
||||
'.woocommerce_attribute:not(.pa_glbattr)'
|
||||
),
|
||||
].map( ( attr ) => {
|
||||
const terms =
|
||||
(
|
||||
attr.querySelector(
|
||||
"[name^='attribute_values']"
|
||||
) as HTMLTextAreaElement
|
||||
)?.value.split( '|' ).length ?? 0;
|
||||
return {
|
||||
name: (
|
||||
attr.querySelector(
|
||||
'[name^="attribute_names"]'
|
||||
) as HTMLInputElement
|
||||
)?.value,
|
||||
terms,
|
||||
};
|
||||
} );
|
||||
recordEvent( 'product_attributes_add', {
|
||||
page: 'product',
|
||||
enable_archive: '',
|
||||
default_sort_order: '',
|
||||
local_attributes,
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Add additional global attributes and local attributes information when saving product attributes
|
Loading…
Reference in New Issue