заменить короткое описание на описание из вариации
Wed Nov 16 2022 08:41:00 GMT+0000 (Coordinated Universal Time)
Saved by
@mastaklance
/**
* replace variable product short description by the selected variation description if it's not empty
*/
add_action( 'woocommerce_before_variations_form', 'variable_product_jquery_script' );
function variable_product_jquery_script() {
?>
<style>.woocommerce-variation-description {display:none !important}</style>
<script>
(function($) {
var selector = '.woocommerce-product-details__short-description',
form = $('form.cart'),
shortDesc = $(selector).html();
form.on('show_variation', function(event, data){
var varDesc = data.variation_description;
$(selector).html( varDesc ? varDesc : shortDesc );
});
form.on('hide_variation', function(){
$(selector).html(shortDesc);
});
})(jQuery);
</script>
<?php
}
content_copyCOPY
Comments