<?php/** Funkce přidá tlačítko pro přiřazení stejné ceny všem variacím** https://www.gowp.com/blog/apply-the-price-of-a-woocommerce-product-variation-to-all-variations-of-the-same-product/*/add_action('woocommerce_product_data_panels','gowp_global_variation_price');functiongowp_global_variation_price(){global$woocommerce;?><scripttype="text/javascript"> function addVariationLinks() {
a = jQuery( '<ahref="#">Apply to all Variations</a>' );
b = jQuery( 'input[name^="variable_regular_price"]' );
a.click( function( c ) {
d = jQuery( this ).parent( 'label' ).next( 'input[name^="variable_regular_price"]' ).val();
e = confirm( "Change the price of all variations to " + d + "?" );
if ( e ) b.val( d ).trigger( 'change' );
c.preventDefault();
} );
b.prev( 'label' ).append( " " ).append( a );
}
<?phpif(version_compare($woocommerce->version,'2.4','>=')):?> jQuery( document ).ready( function() {
jQuery( document ).ajaxComplete( function( event, request, settings ) {
if ( settings.data.lastIndexOf( "action=woocommerce_load_variations", 0 ) === 0 ) {
addVariationLinks();
}
} );
} );
<?phpelse:?> addVariationLinks();
<?phpendif;?></script><?php}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.