Ungetestet und 1:1 aus Deinem Posting übernommen (keine Prüfung durchgeführt)
Code
function sv_wc_measurement_price_calculator_input_min_max() {
if ( ! ( is_product() && class_exists( 'WC_Price_Calculator_Product' ) ) ) {
return;
}
global $product;
if ( ! WC_Price_Calculator_Product::calculator_enabled( $product ) ) {
return;
}
// ab hier für jedes Kategorie oder einzelne Produkte einen eigenen IF Block einfügen
// kategorie
if ( has_term( 'deine_kategorie', 'product_cat', $product ) ) {
wc_enqueue_js("
$('#length_needed').attr({ type: 'number', min: '5', max: '10', step: '.1' }).addClass('input-text');
$('#width_needed').attr({ type: 'number', min: '10', max: '50', step: '.1' }).addClass('input-text');
");
}
// product id
if ( 'deine_produkt_id' == $product->id ) {
wc_enqueue_js("
$('#length_needed').attr({ type: 'number', min: '100', max: '200', step: '.1' }).addClass('input-text');
$('#width_needed').attr({ type: 'number', min: '50', max: '700', step: '.1' }).addClass('input-text');
");
}
}
add_action( 'wp_print_footer_scripts', 'sv_wc_measurement_price_calculator_input_min_max' );
Alles anzeigen