8manos / wc-variations-radio-buttons

Let your customers choose product variations using radio buttons instead of dropdowns.
https://wordpress.org/plugins/wc-variations-radio-buttons/
GNU General Public License v2.0
62 stars 34 forks source link

Show Price and SKU next to each label #21

Open Mantish opened 7 years ago

Mantish commented 7 years ago

This would only work for products with a single variable attribute, and we would probably need a setting to enable it

JiveDig commented 7 years ago

Came here looking for the same thing. A simple solution that's very easy to implement is to pass the variation ID to the woocommerce_variation_option_name filter here https://github.com/8manos/wc-variations-radio-buttons/blob/master/templates/single-product/add-to-cart/variable.php#L25. That way we can add whatever variation specific data we want to each variation.

yaniv691 commented 6 years ago

@Mantish, any thoughts of adding support for showing the price for each variation? @JiveDig, can you please explain how this can be done using your suggestion? Thanks!

JiveDig commented 6 years ago

Barely remember what I was going for, but based on my comment I think it means to change this: $filtered_label = apply_filters( 'woocommerce_variation_option_name', $label ); to this: $filtered_label = apply_filters( 'woocommerce_variation_option_name', $label, $id );

yaniv691 commented 6 years ago

Thank your very much, but how would I go about showing the price for each variation using your code? I'm a Woocommerce rookie :-)

Mantish commented 6 years ago

@yaniv691 I haven't made any progress to support this.

I think we would need to match the attribute to the corresponding variation in $available_variations. Maybe using the woocommerce_variation_option_name as JiveDig suggest, but it can also be coded as part of the print_attribute_radio function.

The other way to do this is via Javascript. I haven't really look at how to do it, but it should be possible.

Anyway, I don't think there's a straightforward solution. Let us know if you make any progress.