Skip to content

Instantly share code, notes, and snippets.

@karpstrucking
Created May 2, 2015 14:08
Show Gist options
  • Save karpstrucking/a0803d7a8900a5e10be9 to your computer and use it in GitHub Desktop.
Save karpstrucking/a0803d7a8900a5e10be9 to your computer and use it in GitHub Desktop.
Add ability to apply one WC product variation price to all variations of the same product
<?php
add_action( 'woocommerce_product_data_panels', 'gowp_global_variation_price' );
function gowp_global_variation_price() {
?>
<script type="text/javascript">
jQuery( document ).ready( function() {
a = jQuery( '<a href="#">Apply to all Variations</a>' );
b = jQuery( 'input[name^="variable_regular_price"]' );
a.click( function( c ) {
d = b.val();
e = confirm( "Change the price of all variations to " + d + "?" );
if ( e ) b.val( d );
c.preventDefault();
} );
b.prev( 'label' ).append( " " ).append( a );
} );
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment