Unverified

Name

Add to Cart JS Variation

About

Used with the Single Product Variation Radio Buttons

Language

Javascript

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Add this to a HTML Widget above the Add to Cart Widget on a Single Product Tempkate

Codevault

WebSquadron

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

12/03/2024

Important Note

This snippet has the following status:

Unverified

This snippet has not been verified, use with caution and at your own risk. See details provided by author in sidebar and click below to find out more.

Add to Cart JS Variation

 
                    
1<script>
2jQuery(function($) {
3 // Listen for changes on radio buttons within the '.variation-changes-container'
4 $('.variation-changes-container').on('change', 'input[type="radio"]', function() {
5 // Get the name and value of the changed radio button
6 var radioName = $(this).attr('name');
7 var radioValue = $(this).val();
8 
9 // Find the corresponding select element and change its value to match the radio button
10 $('select[name="' + radioName + '"]').val(radioValue).trigger('change');
11 });
12});
13</script>

0

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

WooCommerce Show Product Tags On Loop Items

Added: 1 year ago

Last Updated: 1 year ago

Showing product tags on the loop items is something you may wish to implement if you want to allow customers easier navigation between groups of products which are all tagged with the same tag. This q...

WooCommerce

AI Verified

0

WooCommerce Change Coupon Code To Promo Code

Added: 1 year ago

Last Updated: 1 year ago

We’ve written a handful of guides on changing the coupon code wording to specific text. This is because some users find editing code snippets not particularly intuitive, especially non-coders. Do let...

WooCommerce

AI Verified

0

Set Username based on Email - WooCommerce

Added: 1 year ago

Last Updated: 8 months ago

This code adds a filter to the WooCommerce new customer data, so that the user login is automatically set to the user's email address.

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

32

Remove Unused Javascript

Added: 1 year ago

Last Updated: 3 days ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

10

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 2 weeks ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 8 months ago

Last Updated: 1 month ago

This can be used for any WordPress Builder to aid working with CSS Grids.