This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_before_add_to_cart_form', 'woocommerce_variations_sold_out_filter' ); | |
function woocommerce_variations_sold_out_filter() { | |
// disable and add "sold out" to product variations | |
wc_enqueue_js( ' | |
var product_variations = $( "form.variations_form" ).data( "product_variations" ); | |
// dont disable with multiple drop-downs | |
if ( product_variations && $( "form.variations_form" ).find( "select" ).length === 1 ) { | |
var attribute_name = $( "form.variations_form" ).find( "select" ).attr( "name" ); | |
$.each( product_variations, function( key, value ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ps_wp_prepare_attachment_for_js($response, $attachment, $meta) { | |
if($response['type'] == 'image') { | |
$image_src = wp_get_attachment_image_src( $response['id'], 'thumbnail' ); //Use any image size added to your wordpress installation | |
if( is_array($image_src) ) { | |
$response['url'] = $image_src[0]; | |
} | |
} | |
return $response; |