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

Added product ID to target single products #26

Merged
merged 3 commits into from
May 1, 2017

Conversation

NatachaMenjibar
Copy link
Contributor

I'm using your plugin for displaying variations in archive pages in conjunction with "Woocommerce Add to cart Ajax for variable products" plugin.

I've found a problem when selecting variable atributes in archive pages for different products with same atributes because inputs of different products has the same name in all products, and the javascript wasn't working well (was always targeting the input of the first product).

I solved it adding some customization in your variable.php, in print_attribute_radio function, adding product ids to inputs id names. That way, javascript can properly target the product imputs from every product. Maybe you can update your plugin with a similar modification.

Kelp added 2 commits April 19, 2017 19:53
added product ID at the end of the name to target every products in archive pages
added product ID to target single products
// This handles < 2.4.0 bw compatibility where text attributes were not sanitized.
$checked = sanitize_title( $checked_value ) === $checked_value ? checked( $checked_value, sanitize_title( $value ), false ) : checked( $checked_value, $value, false );

$input_name = 'attribute_' . esc_attr( $name ) ;
$esc_value = esc_attr( $value );
$id = esc_attr( $name . '_v_' . $value );
$id = esc_attr( $name . '_v_' . $value . $product->id ); //added product ID at the end of the name to target single products
Copy link
Member

Choose a reason for hiding this comment

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

we should use ->get_id() instead of ->id as this is deprecated in the latest woocommerce version

Replaced deprecated $product->id() by $product->get_id()
@Mantish Mantish merged commit 7ff7872 into 8manos:master May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants