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

WC: fix attribute edit page hidden fields #1161

Merged
merged 4 commits into from
May 7, 2022

Conversation

spleen1981
Copy link
Contributor

@spleen1981 spleen1981 commented May 3, 2022

Display the set of QTS slugs when editing (or adding) a WC product attribute.
Hide the regular slug.

@herrvigg herrvigg added the module: WC Integration with Woo Commerce label May 7, 2022
Copy link
Collaborator

@herrvigg herrvigg left a comment

Choose a reason for hiding this comment

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

OK this looks better, but when we edit a product attribute, we just get one slug field.
Shouldn't we have all the set of QTS slugs for each language?

@herrvigg
Copy link
Collaborator

herrvigg commented May 7, 2022

Shouldn't that qts_show_edit_term_fields also apply to WC product attributes?

@herrvigg
Copy link
Collaborator

herrvigg commented May 7, 2022

This seems to work:

function qts_taxonomies_hooks() {
    ...
    if ( QTX_Module_Loader::is_module_active( 'woo-commerce' ) ) {
        add_action( 'woocommerce_after_add_attribute_fields', 'qts_show_add_term_fields' );
        add_action( 'woocommerce_after_edit_attribute_fields', 'qts_show_edit_term_fields' );  <--- new
    }`

@herrvigg
Copy link
Collaborator

herrvigg commented May 7, 2022

Oh but we have the LSB switch buttons, that's a bit confusing having the list + switches. But I don't know how this is supposed to work, I haven't really tested it yet.

@spleen1981
Copy link
Contributor Author

OK this looks better, but when we edit a product attribute, we just get one slug field. Shouldn't we have all the set of QTS slugs for each language?

Support for multi slugs seems was missing for this page.
added here fd168ee

Oh but we have the LSB switch buttons, that's a bit confusing having the list + switches. But I don't know how this is supposed to work, I haven't really tested it yet.

LSB is only working for Name field, not for slugs here or in any other page. This needs to be implemented, but it's a big change in slugs module, it will need time to figure out and test. It's a 'to do' for next releases.

@herrvigg herrvigg merged commit bad39c2 into qtranslate:master May 7, 2022
@spleen1981 spleen1981 deleted the wc_fix_edit_attribute branch May 8, 2022 03:50
@herrvigg
Copy link
Collaborator

herrvigg commented May 8, 2022

I've rewritten a bit the functions to clarify the signatures. I'm afraid this doesn't work as expected for the WP attributes.
Problem on edit:

  • the usual edit_form_fields action sends the WP_Term
  • the woocommerce_after_edit_attribute_fields action doesn't. If you search in the code, you can find this do_action( 'woocommerce_after_edit_attribute_fields' );

We need the term ID to retrieve the values from the meta, but I don't know if this also applies to WP product attributes (where are they stored?). Related to this, the qts_save_term is supposed to work with product attributes, might be something there as well (add/edit)

@herrvigg
Copy link
Collaborator

herrvigg commented May 8, 2022

Imo if we can't find a fix, better hide the language slugs until a solution is found.

@herrvigg
Copy link
Collaborator

herrvigg commented May 8, 2022

Also note that add_form_fields action sends a taxonomy (string), not a WP_Term object. I have clarified this in this commit 5b46dff.
With WC the action do_action( 'woocommerce_after_add_attribute_fields' ); doesn't send anything, but we don't really need. What matters is qts_save_term but it's not triggered, neither for add or for edit WC attribute.

@spleen1981
Copy link
Contributor Author

Yes it seems this is not applicable for custom taxonomies base slugs.
However this is already handled in slugs module through modules settings, I think it is enough to redirect there to set up the multilingual slugs, same as it is done for in-built base slugs taxonomies (e.g. posts category).
Ref #1164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: WC Integration with Woo Commerce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants